예제 #1
0
파일: header.c 프로젝트: outbackdingo/uBSD
void
WriteDefinesHeader(FILE *file, statement_t *stats)
{
	register statement_t *stat;
    const char *protect = strconcat(SubsystemName, "_defines");

	WriteProlog(file, protect, FALSE, FALSE);
	fprintf(file, "\n/*\tDefines related to the Subsystem %s\t*/\n\n", SubsystemName);
	for (stat = stats; stat != stNULL; stat = stat->stNext) {
		switch (stat->stKind)
		{
		case skRoutine:
			WriteDefinesRoutine(file, stat->stRoutine);
			break;
		case skImport:
		case skSImport:
		case skUImport:
			break;
		default:
			fatal("WriteDefinesHeader(): bad statement_kind_t (%d)",
				  (int) stat->stKind);
		}
	}
	WriteEpilog(file, protect, FALSE);
}
예제 #2
0
파일: header.c 프로젝트: Prajna/mach
void
WriteServerHeader(FILE *file, const statement_t *stats)
{
    register const statement_t *stat;
    const char *protect = strconcat(SubsystemName, "_server_");

    WriteProlog(file, protect);
    for (stat = stats; stat != stNULL; stat = stat->stNext)
	switch (stat->stKind)
	{
	  case skRoutine:
	    WriteServerRoutine(file, stat->stRoutine);
	    break;
	  case skImport:
	  case skSImport:
	    WriteImport(file, stat->stFileName);
	    break;
	  case skUImport:
	    break;
	  default:
	    fatal("WriteServerHeader(): bad statement_kind_t (%d)",
		  (int) stat->stKind);
	}
    WriteEpilog(file, protect);
}
예제 #3
0
파일: header.c 프로젝트: outbackdingo/uBSD
void
WriteUserHeader(FILE *file, statement_t *stats)
{
	register statement_t *stat;
    const char *protect = strconcat(SubsystemName, "_user_");

	WriteProlog(file, protect, TRUE, TRUE);
	for (stat = stats; stat != stNULL; stat = stat->stNext)
		switch (stat->stKind)
		{
		case skImport:
		case skUImport:
		case skDImport:
			WriteImport(file, stat->stFileName);
			break;
		case skRoutine:
		case skSImport:
		case skIImport:
			break;
		default:
			fatal("WriteHeader(): bad statement_kind_t (%d)",
				  (int) stat->stKind);
		}
    fprintf(file, "\n#ifdef __BeforeMigUserHeader\n");
	fprintf(file, "__BeforeMigUserHeader\n");
	fprintf(file, "#endif /* __BeforeMigUserHeader */\n");
	fprintf(file, "\n");
	fprintf(file, "#include <sys/cdefs.h>\n");
	fprintf(file, "__BEGIN_DECLS\n");
	fprintf(file, "\n");
	for (stat = stats; stat != stNULL; stat = stat->stNext) {
		if (stat->stKind == skRoutine)
			WriteUserRoutine(file, stat->stRoutine);
	}
	fprintf(file, "\n");
	fprintf(file, "__END_DECLS\n");

	fprintf(file, "\n");
	fprintf(file, "/********************** Caution **************************/\n");
	fprintf(file, "/* The following data types should be used to calculate  */\n");
	fprintf(file, "/* maximum message sizes only. The actual message may be */\n");
	fprintf(file, "/* smaller, and the position of the arguments within the */\n");
	fprintf(file, "/* message layout may vary from what is presented here.  */\n");
	fprintf(file, "/* For example, if any of the arguments are variable-    */\n");
	fprintf(file, "/* sized, and less than the maximum is sent, the data    */\n");
	fprintf(file, "/* will be packed tight in the actual message to reduce  */\n");
	fprintf(file, "/* the presence of holes.                                */\n");
	fprintf(file, "/********************** Caution **************************/\n");
	fprintf(file, "\n");

	WriteRequestTypes(file, stats);
	WriteUserRequestUnion(file, stats);

	WriteReplyTypes(file, stats);
	WriteUserReplyUnion(file, stats);

	WriteEpilog(file, protect, TRUE);
}
예제 #4
0
파일: header.c 프로젝트: outbackdingo/uBSD
void
WriteServerHeader(FILE *file, statement_t *stats)
{
	register statement_t *stat;
    const char *protect = strconcat(SubsystemName, "_server_");

	WriteProlog(file, protect, TRUE, FALSE);
	for (stat = stats; stat != stNULL; stat = stat->stNext)
		switch (stat->stKind)
		{
		case skImport:
		case skSImport:
		case skDImport:
			WriteImport(file, stat->stFileName);
			break;
		case skRoutine:
		case skUImport:
		case skIImport:
			break;
		default:
			fatal("WriteServerHeader(): bad statement_kind_t (%d)",
				  (int) stat->stKind);
		}
	fprintf(file, "\n#ifdef __BeforeMigServerHeader\n");
	fprintf(file, "__BeforeMigServerHeader\n");
	fprintf(file, "#endif /* __BeforeMigServerHeader */\n\n");
	for (stat = stats; stat != stNULL; stat = stat->stNext) {
		if (stat->stKind == skRoutine)
			WriteServerRoutine(file, stat->stRoutine);
	}

	for (stat = stats; stat != stNULL; stat = stat->stNext) {
		if (stat->stKind == skRoutine)
			WriteServerRoutine(file, stat->stRoutine);
	}
	WriteDispatcher(file);

	WriteRequestTypes(file, stats);
	WriteServerRequestUnion(file, stats);

	WriteReplyTypes(file, stats);
	WriteServerReplyUnion(file, stats);

	WriteEpilog(file, protect, FALSE);
}
예제 #5
0
void DoPsCal(void)
{
    char month[40], year[40];
    char prevm[40], nextm[40];
    int days, wkday, prevdays, nextdays;
    int sfirst;
    int i;
    int is_ps;
    int firstcol;
    char const *startOfBody;
    char passthru[PASSTHRU_LEN+1];
    DynamicBuffer buf;
    CalEntry *c, *d, *p;

/* Read the month and year name, followed by # days in month and 1st day of
   month */
    DBufInit(&buf);
    DBufGets(&buf, stdin);
    sscanf(DBufValue(&buf), "%s %s %d %d %d", month, year, &days, &wkday,
	   &MondayFirst);

    /* Get day names */
    DBufGets(&buf, stdin);
    sscanf(DBufValue(&buf), "%32s %32s %32s %32s %32s %32s %32s",
	   DayName[0], DayName[1], DayName[2], DayName[3],
	   DayName[4], DayName[5], DayName[6]);

    /* We write the prolog here because it's only at this point that
       MondayFirst is set correctly. */
    if (validfile == 1) {
	WriteProlog();
    }

    DBufGets(&buf, stdin);
    sscanf(DBufValue(&buf), "%s %d", prevm, &prevdays);
    DBufGets(&buf, stdin);
    sscanf(DBufValue(&buf), "%s %d", nextm, &nextdays);
    DBufFree(&buf);
    MaxDay = days;
    FirstWkDay = wkday;

/* Print a message for the user */
    if (Verbose) fprintf(stderr, "        %s %s\n", month, year);

    printf("%%%%Page: %c%c%c%c%c %d\n", month[0], month[1], month[2],
	   year[2], year[3], validfile);

/* Emit PostScript to do the heading */
    if (!PortraitMode) printf("90 rotate 0 XSIZE neg translate\n");
    printf("/SAVESTATE save def (%s) (%s) PreCal SAVESTATE restore\n", month, year);
    printf("(%s %s) doheading\n", month, year);

/* Figure out the column of the first day in the calendar */

    if (MondayFirst) {
	firstcol = wkday-1;
	if (firstcol < 0) firstcol = 6;
    } else {
	firstcol = wkday;
    }

/* Calculate the minimum box size */
    if (!FillPage) {
	printf("/MinBoxSize ytop MinY sub 7 div def\n");
    } else {
	if ((days == 31 && firstcol >= 5) || (days == 30 && firstcol == 6))
	    printf("/MinBoxSize ytop MinY sub 6 div def\n");
	else if (days == 28 && firstcol == 0 && NoSmallCal)
	    printf("/MinBoxSize ytop MinY sub 4 div def\n");
	else
	    printf("/MinBoxSize ytop MinY sub 5 div def\n");
    }

    printf("/ysmalltop ytop def\n");

/* Do each entry */

    CurEntries = NULL;
    CurDay = 1;
    WkDayNum = wkday;

    while(1) {
	if (feof(stdin)) {
	    fprintf(stderr, "Input from REMIND is corrupt!\n");
	    exit(1);
	}

	DBufGets(&buf, stdin);
	if (!strcmp(DBufValue(&buf), PSEND)) {
	    DBufFree(&buf);
	    break;
	}

	/* Ignore lines beginning with '#' */
	if (DBufValue(&buf)[0] == '#') {
	    continue;
	}
	/* Read the day number - a bit of a hack! */
	DayNum = (DBufValue(&buf)[8] - '0') * 10 + DBufValue(&buf)[9] - '0';
	if (DayNum != CurDay) {
	    for(; CurDay<DayNum; CurDay++) {
		WriteCalEntry();
		WkDayNum = (WkDayNum + 1) % 7;
	    }
	}
	/* Add the text */
	c = NEW(CalEntry);
	if (!c) {
	    fprintf(stderr, "malloc failed - aborting.\n");
	    exit(1);
	}
	c->next = NULL;
	c->special = SPECIAL_NORMAL;

	/* Skip the tag, duration and time */
	startOfBody = DBufValue(&buf)+10;

	/* Eat the passthru */
	startOfBody = EatToken(startOfBody, passthru, PASSTHRU_LEN);

	/* Eat the tag */
	startOfBody = EatToken(startOfBody, NULL, 0);

	/* Eat the duration */
	startOfBody = EatToken(startOfBody, NULL, 0);

	/* Eat the time */
	startOfBody = EatToken(startOfBody, NULL, 0);

	is_ps = 0;
	if (!strcmp(passthru, "PostScript") ||
	    !strcmp(passthru, "PSFile") ||
	    !strcmp(passthru, "MOON") ||
	    !strcmp(passthru, "WEEK") ||
	    !strcmp(passthru, "SHADE")) {
	    is_ps = 1;
	}
	c->entry = malloc(strlen(startOfBody) + 1);
	if (!c->entry) {
	    fprintf(stderr, "malloc failed - aborting.\n");
	    exit(1);
	}
	strcpy(c->entry, startOfBody);

	if (is_ps) {
	    /* Save the type of SPECIAL */
	    if (!strcmp(passthru, "PostScript")) {
		c->special = SPECIAL_POSTSCRIPT;
	    } else if (!strcmp(passthru, "SHADE")) {
		c->special = SPECIAL_SHADE;
	    } else if (!strcmp(passthru, "MOON")) {
		c->special = SPECIAL_MOON;
	    } else if (!strcmp(passthru, "WEEK")) {
		c->special = SPECIAL_WEEK;
	    } else {
		c->special = SPECIAL_PSFILE;
	    }

	    if (!PsEntries[DayNum]) {
		PsEntries[DayNum] = c;
	    } else {
		d = PsEntries[DayNum];
		p = NULL;
		/* Slot it into the right place */
		while (d->next && (SpecialSortOrder[c->special] <= SpecialSortOrder[d->special])) {
		    p = d;
		    d = d->next;
		}
		if (SpecialSortOrder[c->special] <= SpecialSortOrder[d->special]) {
		    c->next = d->next;
		    d->next = c;
		} else {
		    if (p) {
			p->next = c;
		    } else {
			PsEntries[DayNum] = c;
		    }
		    c->next = d;
		}
	    }
	} else if (!strcmp(passthru, "*") ||
		   !strcmp(passthru, "COLOUR") ||
	           !strcmp(passthru, "COLOR")) {
	    /* Put on linked list */
	    if (!CurEntries) {
		CurEntries = c;
	    } else {
		d = CurEntries;
		while(d->next) d = d->next;
		d->next = c;
	    }
	    if (!strcmp(passthru, "COLOR") ||
		!strcmp(passthru, "COLOUR")) {
		c->special = SPECIAL_COLOR;
	    }
	}
    }
    for(; CurDay<=days; CurDay++) {
	WriteCalEntry();
	WkDayNum = (WkDayNum + 1) % 7;
    }

/* If wkday < 2, set ysmall.  If necessary (only for feb) increase cal size. */
    printf("/ysmallbot ylast def\n");

/* Now draw the vertical lines */
    GetSmallLocations();
    for (i=0; i<=7; i++) {
	printf("%d xincr mul MinX add ymin %d xincr mul MinX add topy L\n",
	       i, i);
    }

/* print the small calendars */
    if (!NoSmallCal) {
	sfirst = wkday - (prevdays % 7);
	if (sfirst < 0) sfirst += 7;
	DoSmallCal(prevm, prevdays, sfirst, SmallCol1, 1);
	sfirst = wkday + (days % 7);
	if (sfirst >6) sfirst -= 7;
	DoSmallCal(nextm, nextdays, sfirst, SmallCol2, 2);
    }
/* Do it! */
    printf("showpage\n");
}
예제 #6
0
int				/* O - Exit status */
TextMain(const char *name,	/* I - Name of filter */
         int        argc,	/* I - Number of command-line arguments */
         char       *argv[])	/* I - Command-line arguments */
{
  FILE		*fp;		/* Print file */
  ppd_file_t	*ppd;		/* PPD file */
  int		i,		/* Looping var */
		ch,		/* Current char from file */
		lastch,		/* Previous char from file */
		attr,		/* Current attribute */
		line,		/* Current line */
  		column,		/* Current column */
  		page_column;	/* Current page column */
  int		num_options;	/* Number of print options */
  cups_option_t	*options;	/* Print options */
  const char	*val;		/* Option value */
  char		keyword[64],	/* Keyword string */
		*keyptr;	/* Pointer into string */
  int		keycol;		/* Column where keyword starts */
  int		ccomment;	/* Inside a C-style comment? */
  int		cstring;	/* Inside a C string */


 /*
  * Make sure status messages are not buffered...
  */

  setbuf(stderr, NULL);

 /*
  * Check command-line...
  */

  if (argc < 6 || argc > 7)
  {
    fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
            name);
    return (1);
  }

 /*
  * If we have 7 arguments, print the file named on the command-line.
  * Otherwise, send stdin instead...
  */

  if (argc == 6)
    fp = stdin;
  else
  {
   /*
    * Try to open the print file...
    */

    if ((fp = fopen(argv[6], "rb")) == NULL)
    {
      perror("DEBUG: unable to open print file - ");
      return (1);
    }
  }

 /*
  * Process command-line options and write the prolog...
  */

  options     = NULL;
  num_options = cupsParseOptions(argv[5], 0, &options);

  if ((val = cupsGetOption("prettyprint", num_options, options)) != NULL &&
      strcasecmp(val, "no") && strcasecmp(val, "off") &&
      strcasecmp(val, "false"))
  {
    PageLeft     = 72.0f;
    PageRight    = PageWidth - 36.0f;
    PageBottom   = PageBottom > 36.0f ? PageBottom : 36.0f;
    PageTop      = PageLength - 36.0f;
    CharsPerInch = 12;
    LinesPerInch = 8;

    if ((val = getenv("CONTENT_TYPE")) == NULL)
    {
      PrettyPrint = PRETTY_PLAIN;
      NumKeywords = 0;
      Keywords    = NULL;
    }
    else if (strcasecmp(val, "application/x-cshell") == 0)
    {
      PrettyPrint = PRETTY_SHELL;
      NumKeywords = sizeof(csh_keywords) / sizeof(csh_keywords[0]);
      Keywords    = csh_keywords;
    }
    else if (strcasecmp(val, "application/x-csource") == 0)
    {
      PrettyPrint = PRETTY_CODE;
      NumKeywords = sizeof(code_keywords) / sizeof(code_keywords[0]);
      Keywords    = code_keywords;
    }
    else if (strcasecmp(val, "application/x-perl") == 0)
    {
      PrettyPrint = PRETTY_PERL;
      NumKeywords = sizeof(perl_keywords) / sizeof(perl_keywords[0]);
      Keywords    = perl_keywords;
    }
    else if (strcasecmp(val, "application/x-shell") == 0)
    {
      PrettyPrint = PRETTY_SHELL;
      NumKeywords = sizeof(sh_keywords) / sizeof(sh_keywords[0]);
      Keywords    = sh_keywords;
    }
    else
    {
      PrettyPrint = PRETTY_PLAIN;
      NumKeywords = 0;
      Keywords    = NULL;
    }
  }

  ppd = SetCommonOptions(num_options, options, 1);

  if ((val = cupsGetOption("wrap", num_options, options)) == NULL)
    WrapLines = 1;
  else
    WrapLines = !strcasecmp(val, "true") || !strcasecmp(val, "on") ||
                !strcasecmp(val, "yes");

  if ((val = cupsGetOption("columns", num_options, options)) != NULL)
    PageColumns = atoi(val);

  if ((val = cupsGetOption("cpi", num_options, options)) != NULL)
    CharsPerInch = atof(val);

  if ((val = cupsGetOption("lpi", num_options, options)) != NULL)
    LinesPerInch = atof(val);

  if (PrettyPrint)
    PageTop -= 216.0f / LinesPerInch;

  Copies = atoi(argv[4]);

  WriteProlog(argv[3], argv[2], getenv("CLASSIFICATION"),
              cupsGetOption("page-label", num_options, options), ppd);

 /*
  * Read text from the specified source and print it...
  */

  lastch       = 0;
  column       = 0;
  line         = 0;
  page_column  = 0;
  attr         = 0;
  keyptr       = keyword;
  keycol       = 0;
  ccomment     = 0;
  cstring      = 0;

  while ((ch = getutf8(fp)) >= 0)
  {
   /*
    * Control codes:
    *
    *   BS	Backspace (0x08)
    *   HT	Horizontal tab; next 8th column (0x09)
    *   LF	Line feed; forward full line (0x0a)
    *   VT	Vertical tab; reverse full line (0x0b)
    *   FF	Form feed (0x0c)
    *   CR	Carriage return (0x0d)
    *   ESC 7	Reverse full line (0x1b 0x37)
    *   ESC 8	Reverse half line (0x1b 0x38)
    *   ESC 9	Forward half line (0x1b 0x39)
    */

    switch (ch)
    {
      case 0x08 :		/* BS - backspace for boldface & underline */
          if (column > 0)
            column --;

          keyptr = keyword;
	  keycol = column;
          break;

      case 0x09 :		/* HT - tab to next 8th column */
          if (PrettyPrint && keyptr > keyword)
	  {
	    *keyptr = '\0';
	    keyptr  = keyword;

	    if (bsearch(&keyptr, Keywords, NumKeywords, sizeof(char *),
	                compare_keywords))
            {
	     /*
	      * Put keywords in boldface...
	      */

	      i = page_column * (ColumnWidth + ColumnGutter);

	      while (keycol < column)
	      {
	        Page[line][keycol + i].attr |= ATTR_BOLD;
		keycol ++;
	      }
	    }
	  }

          column = (column + 8) & ~7;

          if (column >= ColumnWidth && WrapLines)
          {			/* Wrap text to margins */
            line ++;
            column = 0;

            if (line >= SizeLines)
            {
              page_column ++;
              line = 0;

              if (page_column >= PageColumns)
              {
                WritePage();
		page_column = 0;
              }
            }
          }

	  keycol = column;

          attr &= ~ATTR_BOLD;
          break;

      case 0x0d :		/* CR */
#ifndef __APPLE__
         /*
	  * All but MacOS/Darwin treat CR as was intended by ANSI
	  * folks, namely to move to column 0/1.  Some programs still
	  * use this to do boldfacing and underlining...
	  */

          column = 0;
          break;
#else
         /*
	  * MacOS/Darwin still need to treat CR as a line ending.
	  */

          {
	    int nextch;
            if ((nextch = getc(fp)) != 0x0a)
	      ungetc(nextch, fp);
	    else
	      ch = nextch;
	  }
#endif /* !__APPLE__ */

      case 0x0a :		/* LF - output current line */
          if (PrettyPrint && keyptr > keyword)
	  {
	    *keyptr = '\0';
	    keyptr  = keyword;

	    if (bsearch(&keyptr, Keywords, NumKeywords, sizeof(char *),
	                compare_keywords))
            {
	     /*
	      * Put keywords in boldface...
	      */

	      i = page_column * (ColumnWidth + ColumnGutter);

	      while (keycol < column)
	      {
	        Page[line][keycol + i].attr |= ATTR_BOLD;
		keycol ++;
	      }
	    }
	  }

          line ++;
          column = 0;
	  keycol = 0;

          if (!ccomment && !cstring)
	    attr &= ~(ATTR_ITALIC | ATTR_BOLD | ATTR_RED | ATTR_GREEN | ATTR_BLUE);

          if (line >= SizeLines)
          {
            page_column ++;
            line = 0;

            if (page_column >= PageColumns)
            {
              WritePage();
	      page_column = 0;
            }
          }
          break;

      case 0x0b :		/* VT - move up 1 line */
          if (line > 0)
	    line --;

          keyptr = keyword;
	  keycol = column;

          if (!ccomment && !cstring)
	    attr &= ~(ATTR_ITALIC | ATTR_BOLD | ATTR_RED | ATTR_GREEN | ATTR_BLUE);
          break;

      case 0x0c :		/* FF - eject current page... */
          if (PrettyPrint && keyptr > keyword)
	  {
	    *keyptr = '\0';
	    keyptr  = keyword;

	    if (bsearch(&keyptr, Keywords, NumKeywords, sizeof(char *),
	                compare_keywords))
            {
	     /*
	      * Put keywords in boldface...
	      */

	      i = page_column * (ColumnWidth + ColumnGutter);

	      while (keycol < column)
	      {
	        Page[line][keycol + i].attr |= ATTR_BOLD;
		keycol ++;
	      }
	    }
	  }

          page_column ++;
	  column = 0;
	  keycol = 0;
          line   = 0;

          if (!ccomment && !cstring)
	    attr &= ~(ATTR_ITALIC | ATTR_BOLD | ATTR_RED | ATTR_GREEN | ATTR_BLUE);

          if (page_column >= PageColumns)
          {
            WritePage();
            page_column = 0;
          }
          break;

      case 0x1b :		/* Escape sequence */
          ch = getutf8(fp);
	  if (ch == '7')
	  {
	   /*
	    * ESC 7	Reverse full line (0x1b 0x37)
	    */

            if (line > 0)
	      line --;
	  }
	  else if (ch == '8')
	  {
           /*
	    *   ESC 8	Reverse half line (0x1b 0x38)
	    */

            if ((attr & ATTR_RAISED) && line > 0)
	    {
	      attr &= ~ATTR_RAISED;
              line --;
	    }
	    else if (attr & ATTR_LOWERED)
	      attr &= ~ATTR_LOWERED;
	    else
	      attr |= ATTR_RAISED;
	  }
	  else if (ch == '9')
	  {
           /*
	    *   ESC 9	Forward half line (0x1b 0x39)
	    */

            if ((attr & ATTR_LOWERED) && line < (SizeLines - 1))
	    {
	      attr &= ~ATTR_LOWERED;
              line ++;
	    }
	    else if (attr & ATTR_RAISED)
	      attr &= ~ATTR_RAISED;
	    else
	      attr |= ATTR_LOWERED;
	  }
	  break;

      default :			/* All others... */
          if (ch < ' ')
            break;		/* Ignore other control chars */

          if (PrettyPrint > PRETTY_PLAIN)
	  {
	   /*
	    * Do highlighting of C/C++ keywords, preprocessor commands,
	    * and comments...
	    */

	    if (ch == ' ' && (attr & ATTR_BOLD))
	    {
	     /*
	      * Stop bolding preprocessor command...
	      */

	      attr &= ~ATTR_BOLD;
	    }
	    else if (!(isalnum(ch & 255) || ch == '_') && keyptr > keyword)
	    {
	     /*
	      * Look for a keyword...
	      */

	      *keyptr = '\0';
	      keyptr  = keyword;

	      if (!(attr & ATTR_ITALIC) &&
	          bsearch(&keyptr, Keywords, NumKeywords, sizeof(char *),
	                  compare_keywords))
              {
	       /*
	        * Put keywords in boldface...
		*/

	        i = page_column * (ColumnWidth + ColumnGutter);

		while (keycol < column)
		{
	          Page[line][keycol + i].attr |= ATTR_BOLD;
		  keycol ++;
		}
	      }
	    }
	    else if ((isalnum(ch & 255) || ch == '_') && !ccomment && !cstring)
	    {
	     /*
	      * Add characters to the current keyword (if they'll fit).
	      */

              if (keyptr == keyword)
	        keycol = column;

	      if (keyptr < (keyword + sizeof(keyword) - 1))
	        *keyptr++ = ch;
            }
	    else if (ch == '\"' && lastch != '\\' && !ccomment && !cstring)
	    {
	     /*
	      * Start a C string constant...
	      */

	      cstring = -1;
              attr    = ATTR_BLUE;
	    }
            else if (ch == '*' && lastch == '/' && !cstring &&
	             PrettyPrint != PRETTY_SHELL)
	    {
	     /*
	      * Start a C-style comment...
	      */

	      ccomment = 1;
	      attr     = ATTR_ITALIC | ATTR_GREEN;
	    }
	    else if (ch == '/' && lastch == '/' && !cstring &&
	             PrettyPrint == PRETTY_CODE)
	    {
	     /*
	      * Start a C++-style comment...
	      */

	      attr = ATTR_ITALIC | ATTR_GREEN;
	    }
	    else if (ch == '#' && !cstring && PrettyPrint != PRETTY_CODE)
	    {
	     /*
	      * Start a shell-style comment...
	      */

	      attr = ATTR_ITALIC | ATTR_GREEN;
	    }
	    else if (ch == '#' && column == 0 && !ccomment && !cstring &&
	             PrettyPrint == PRETTY_CODE)
	    {
	     /*
	      * Start a preprocessor command...
	      */

	      attr = ATTR_BOLD | ATTR_RED;
	    }
          }

          if (column >= ColumnWidth && WrapLines)
          {			/* Wrap text to margins */
            column = 0;
	    line ++;

            if (line >= SizeLines)
            {
              page_column ++;
              line = 0;

              if (page_column >= PageColumns)
              {
        	WritePage();
        	page_column = 0;
              }
            }
          }

         /*
	  * Add text to the current column & line...
	  */

          if (column < ColumnWidth)
	  {
	    i = column + page_column * (ColumnWidth + ColumnGutter);

            if (PrettyPrint)
              Page[line][i].attr = attr;
	    else if (ch == ' ' && Page[line][i].ch)
	      ch = Page[line][i].ch;
            else if (ch == Page[line][i].ch)
              Page[line][i].attr |= ATTR_BOLD;
            else if (Page[line][i].ch == '_')
              Page[line][i].attr |= ATTR_UNDERLINE;
            else if (ch == '_')
	    {
              Page[line][i].attr |= ATTR_UNDERLINE;

              if (Page[line][i].ch)
	        ch = Page[line][i].ch;
	    }
	    else
              Page[line][i].attr = attr;

            Page[line][i].ch = ch;
	  }

          if (PrettyPrint)
	  {
	    if ((ch == '{' || ch == '}') && !ccomment && !cstring &&
	        column < ColumnWidth)
	    {
	     /*
	      * Highlight curley braces...
	      */

	      Page[line][column].attr |= ATTR_BOLD;
	    }
	    else if ((ch == '/' || ch == '*') && lastch == '/' &&
	             column < ColumnWidth && PrettyPrint != PRETTY_SHELL)
	    {
	     /*
	      * Highlight first comment character...
	      */

	      Page[line][column - 1].attr = attr;
	    }
	    else if (ch == '\"' && lastch != '\\' && !ccomment && cstring > 0)
	    {
	     /*
	      * End a C string constant...
	      */

	      cstring = 0;
	      attr    &= ~ATTR_BLUE;
            }
	    else if (ch == '/' && lastch == '*' && ccomment)
	    {
	     /*
	      * End a C-style comment...
	      */

	      ccomment = 0;
	      attr     &= ~(ATTR_ITALIC | ATTR_GREEN);
	    }

            if (cstring < 0)
	      cstring = 1;
	  }

          column ++;
          break;          
    }

   /*
    * Save this character for the next cycle.
    */

    lastch = ch;
  }

 /*
  * Write any remaining page data...
  */

  if (line > 0 || page_column > 0 || column > 0)
    WritePage();

 /*
  * Write the epilog and return...
  */

  WriteEpilogue();

  if (ppd != NULL)
    ppdClose(ppd);

  return (0);
}