Back to index

radiance  4R0+20100331
Defines | Functions | Variables
psort.c File Reference
#include "meta.h"

Go to the source code of this file.

Defines

#define MAXALLOC   1100 /* must be >= PBSIZE in sort.c */

Functions

static int pcompare (PRIMITIVE **pp1, PRIMITIVE **pp2)
int main (int argc, char **argv)

Variables

static const char RCSid [] = "$Id: psort.c,v 1.3 2003/11/15 02:13:37 schorsch Exp $"
char * progname
int maxalloc = MAXALLOC
static int val [5]
static int extrema [5]

Define Documentation

#define MAXALLOC   1100 /* must be >= PBSIZE in sort.c */

Definition at line 11 of file psort.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file psort.c.

{
 FILE  *fp;
 int  i;

 progname = *argv++;
 argc--;

 for (i = 0; i < 4 && argc && (**argv == '+' || **argv == '-'); i++)  {
    val[i] = (**argv == '+') ? 1 : -1;
    switch (*(*argv+1))  {
       case 'x':
         extrema[i] = XMN;
         break;
       case 'y':
         extrema[i] = YMN;
         break;
       case 'X':
         extrema[i] = XMX;
         break;
       case 'Y':
         extrema[i] = YMX;
         break;
       default:
          sprintf(errmsg, "unknown option \"%s\"", *argv);
         error(USER, errmsg);
         break;
       }
    argv++;
    argc--;
    }

 val[i] = 0;

 if (argc)
    while (argc)  {
       fp = efopen(*argv, "r");
       sort(fp, pcompare);
       fclose(fp);
       argv++;
       argc--;
       }
 else
    sort(stdin, pcompare);

 writeof(stdout);

 return(0);
 }

Here is the call graph for this function:

int pcompare ( PRIMITIVE **  pp1,
PRIMITIVE **  pp2 
) [static]

Definition at line 85 of file psort.c.

{
 register PRIMITIVE  *p1 = *pp1, *p2 = *pp2;
 register int  i;

 for (i = 0; val[i]; i++)
    if (p1->xy[extrema[i]] > p2->xy[extrema[i]])
       return(val[i]);
    else if (p1->xy[extrema[i]] < p2->xy[extrema[i]])
       return(-val[i]);

 return(0);
 }

Here is the caller graph for this function:


Variable Documentation

int extrema[5] [static]

Definition at line 21 of file psort.c.

Definition at line 19 of file psort.c.

char* progname

Definition at line 17 of file psort.c.

const char RCSid[] = "$Id: psort.c,v 1.3 2003/11/15 02:13:37 schorsch Exp $" [static]

Definition at line 2 of file psort.c.

int val[5] [static]

Definition at line 21 of file psort.c.