Back to index

radiance  4R0+20100331
Functions | Variables
devmain.c File Reference
#include "copyright.h"
#include "standard.h"
#include "color.h"
#include "driver.h"

Go to the source code of this file.

Functions

int r_clear ()
int r_paintr ()
int r_getcur ()
int r_comout ()
int r_comin ()
int r_flush ()
 main (int argc, argv)
void quit (int code)
 mygets (char *s, FILE *fp)
 myputs (char *s, FILE *fp)
void eputs (char *s)
 sendstate ()

Variables

static const char RCSid [] = "$Id: devmain.c,v 2.4 2003/02/25 02:47:22 greg Exp $"
struct driverdev = NULL
FILE * devin
FILE * devout
char * progname
int(* dev_func [NREQUESTS])()

Function Documentation

void eputs ( char *  s)

Definition at line 182 of file devmain.c.

{
       static int  midline = 0;

       if (!*s)
              return;
       if (!midline++) {
              fputs(progname, stderr);
              fputs(": ", stderr);
       }
       fputs(s, stderr);
       if (s[strlen(s)-1] == '\n') {
              fflush(stderr);
              midline = 0;
       }
}
main ( int  argc,
argv   
)

Definition at line 33 of file devmain.c.

{
       extern struct driver *dinit();
       int  com;
                                          /* set up I/O */
       progname = argv[0];
       if (argc < 3) {
              eputs("arg count\n");
              quit(1);
       }
       devin = fdopen(atoi(argv[1]), "r");
       devout = fdopen(atoi(argv[2]), "w");
       if (devin == NULL || devout == NULL || getw(devin) != COM_SENDM) {
              eputs("connection failure\n");
              quit(1);
       }
                                          /* open device */
       if ((dev = dinit(argv[0], argv[3])) == NULL)
              quit(1);
       putw(COM_RECVM, devout);           /* verify initialization */
       sendstate();
       fflush(devout);
                                          /* loop on requests */
       while ((com = getc(devin)) != EOF) {
              if (com >= NREQUESTS || dev_func[com] == NULL) {
                     eputs("invalid request\n");
                     quit(1);
              }
              (*dev_func[com])();         /* process request */
       }
       quit(0);                    /* all done, clean up and exit */
}

Here is the call graph for this function:

mygets ( char *  s,
FILE *  fp 
)

Definition at line 158 of file devmain.c.

{
       register int  c;

       while ((c = getc(fp)) != EOF)
              if ((*s++ = c) == '\0')
                     return;
       *s = '\0';
}

Here is the caller graph for this function:

myputs ( char *  s,
FILE *  fp 
)

Definition at line 171 of file devmain.c.

{
       do
              putc(*s, fp);
       while (*s++);
}

Here is the caller graph for this function:

void quit ( int  code)

Definition at line 70 of file devmain.c.

{
       if (dev != NULL)
              (*dev->close)();
       exit(code);
}
r_clear ( )

Definition at line 79 of file devmain.c.

{
       int    xres, yres;

       xres = getw(devin);
       yres = getw(devin);
       (*dev->clear)(xres, yres);
}
r_comin ( )

Definition at line 139 of file devmain.c.

{
       char   buf[256], *prompt;
                                   /* get prompt */
       if (getc(devin)) {
              mygets(buf, devin);
              prompt = buf;
       } else
              prompt = NULL;
                                   /* get string */
       (*dev->comin)(buf, prompt);
                                   /* reply */
       putc(COM_COMIN, devout);
       myputs(buf, devout);
       sendstate();
       fflush(devout);
}

Here is the call graph for this function:

r_comout ( )

Definition at line 130 of file devmain.c.

{
       char   str[256];

       mygets(str, devin);
       (*dev->comout)(str);
}

Here is the call graph for this function:

r_flush ( )

Definition at line 101 of file devmain.c.

{
       if (dev->flush != NULL)
              (*dev->flush)();
       putc(COM_FLUSH, devout);
       sendstate();
       fflush(devout);
}

Here is the call graph for this function:

r_getcur ( )

Definition at line 111 of file devmain.c.

{
       int    c;
       int    x, y;
                                   /* get it if we can */
       if (dev->getcur == NULL) {
              c = ABORT;
              x = y = 0;
       } else
              c = (*dev->getcur)(&x, &y);
                                   /* reply */
       putc(COM_GETCUR, devout);
       putc(c, devout);
       putw(x, devout);
       putw(y, devout);
       fflush(devout);
}
r_paintr ( )

Definition at line 89 of file devmain.c.

{
       COLOR  col;
       int    xmin, ymin, xmax, ymax;

       fread((char *)col, sizeof(COLOR), 1, devin);
       xmin = getw(devin); ymin = getw(devin);
       xmax = getw(devin); ymax = getw(devin);
       (*dev->paintr)(col, xmin, ymin, xmax, ymax);
}
sendstate ( )

Definition at line 201 of file devmain.c.

{
       fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout);
       putw(dev->xsiz, devout);
       putw(dev->ysiz, devout);
       putw(dev->inpready, devout);
}

Here is the caller graph for this function:


Variable Documentation

struct driver* dev = NULL

Definition at line 18 of file devmain.c.

int(* dev_func[NREQUESTS])()
Initial value:

Definition at line 26 of file devmain.c.

FILE* devin

Definition at line 20 of file devmain.c.

FILE * devout

Definition at line 20 of file devmain.c.

char* progname

Definition at line 22 of file devmain.c.

const char RCSid[] = "$Id: devmain.c,v 2.4 2003/02/25 02:47:22 greg Exp $" [static]

Definition at line 2 of file devmain.c.