Back to index

radiance  4R0+20100331
Functions | Variables
resolu.c File Reference
#include "copyright.h"
#include <stdlib.h>
#include <stdio.h>
#include "resolu.h"

Go to the source code of this file.

Functions

void fputresolu (int ord, int sl, int ns, FILE *fp)
int fgetresolu (int *sl, int *ns, FILE *fp)
char * resolu2str (char *buf, RESOLU *rp)
int str2resolu (RESOLU *rp, char *buf)

Variables

static const char RCSid [] = "$Id: resolu.c,v 2.6 2006/06/07 17:52:03 schorsch Exp $"
char resolu_buf [RESOLU_BUFLEN]

Function Documentation

int fgetresolu ( int *  sl,
int *  ns,
FILE *  fp 
)

Definition at line 41 of file resolu.c.

{
       RESOLU  rs;

       if (!fgetsresolu(&rs, fp))
              return(-1);
       if (rs.rt & YMAJOR) {
              *sl = rs.xr;
              *ns = rs.yr;
       } else {
              *sl = rs.yr;
              *ns = rs.xr;
       }
       return(rs.rt);
}

Here is the caller graph for this function:

void fputresolu ( int  ord,
int  sl,
int  ns,
FILE *  fp 
)

Definition at line 22 of file resolu.c.

{
       RESOLU  rs;

       if ((rs.rt = ord) & YMAJOR) {
              rs.xr = sl;
              rs.yr = ns;
       } else {
              rs.xr = ns;
              rs.yr = sl;
       }
       fputsresolu(&rs, fp);
}

Here is the caller graph for this function:

char* resolu2str ( char *  buf,
RESOLU rp 
)

Definition at line 61 of file resolu.c.

{
       if (rp->rt&YMAJOR)
              sprintf(buf, "%cY %d %cX %d\n",
                            rp->rt&YDECR ? '-' : '+', rp->yr,
                            rp->rt&XDECR ? '-' : '+', rp->xr);
       else
              sprintf(buf, "%cX %d %cY %d\n",
                            rp->rt&XDECR ? '-' : '+', rp->xr,
                            rp->rt&YDECR ? '-' : '+', rp->yr);
       return(buf);
}
int str2resolu ( RESOLU rp,
char *  buf 
)

Definition at line 78 of file resolu.c.

{
       register char  *xndx, *yndx;
       register char  *cp;

       if (buf == NULL)
              return(0);
       xndx = yndx = NULL;
       for (cp = buf; *cp; cp++)
              if (*cp == 'X')
                     xndx = cp;
              else if (*cp == 'Y')
                     yndx = cp;
       if (xndx == NULL || yndx == NULL)
              return(0);
       rp->rt = 0;
       if (xndx > yndx) rp->rt |= YMAJOR;
       if (xndx[-1] == '-') rp->rt |= XDECR;
       if (yndx[-1] == '-') rp->rt |= YDECR;
       if ((rp->xr = atoi(xndx+1)) <= 0)
              return(0);
       if ((rp->yr = atoi(yndx+1)) <= 0)
              return(0);
       return(1);
}

Variable Documentation

const char RCSid[] = "$Id: resolu.c,v 2.6 2006/06/07 17:52:03 schorsch Exp $" [static]

Definition at line 2 of file resolu.c.

Definition at line 18 of file resolu.c.