⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcl3opts.c

📁 openmeetings组件之GS openmeetings组件之GS openmeetings组件之GS
💻 C
📖 第 1 页 / 共 3 页
字号:
	fputs(" (", ip->out);	if (strcmp(unit, "bp") == 0)	  fprintf(ip->out, "%.0f x %.0f bp", size->dimen[0],	    size->dimen[1]);	else if (strcmp(unit, "in") == 0)	  fprintf(ip->out, "%.1f x %.1f in", size->dimen[0]/BP_PER_IN,	    size->dimen[1]/BP_PER_IN);	else	  fprintf(ip->out, "%.0f x %.0f mm", size->dimen[0]/BP_PER_MM,	    size->dimen[1]/BP_PER_MM);	fputc(')', ip->out);      }      fputs(".\n", ip->out);    }  }  if (ip->fdata.media_source != 0 && ip->fdata.media_source != 1)    imessage(ip->out, 19, "The media source (input tray) selected is %d.\n",      ip->fdata.media_source);  if (ip->fdata.media_destination != 0)    imessage(ip->out, 17,      "The media destination (output tray) selected is %d.\n",      ip->fdata.media_destination);  if (ip->fdata.media_source != 0 && ip->fdata.media_source != 1 ||      ip->fdata.media_destination != 0)    imessage(ip->out, 18,      "To be able to select a media position (input or output) you will have "	"to\n"      "configure the `InputAttributes' or `OutputAttributes' dictionaries\n"      "appropriately. See the manual page gs-pcl3(1).\n");  return;}/*****************************************************************************/static int action_PageSize(FILE *in, const pcl_Command *cmd, void *i){  CollectedInfo *ip = i;  ip->fdata.size = cmd->i;  return 0;}/*****************************************************************************/static int action_dry_time(FILE *in, const pcl_Command *cmd, void *i){  CollectedInfo *ip = i;  ip->fdata.dry_time = cmd->i;  return 0;}/*****************************************************************************/static int action_destination(FILE *in, const pcl_Command *cmd, void *i){  CollectedInfo *ip = i;  ip->fdata.media_destination = cmd->i;  return 0;}/*****************************************************************************/static int action_source(FILE *in, const pcl_Command *cmd, void *i){  CollectedInfo *ip = i;  if (cmd->i != 0 && cmd->i != -2) {    if (cmd->i == 2) ip->fdata.manual_feed = TRUE;    else ip->fdata.media_source = cmd->i;  }  return 0;}/*****************************************************************************/static int action_media_type(FILE *in, const pcl_Command *cmd, void *i){  CollectedInfo *ip = i;  ip->seen_new_quality = TRUE;  ip->fdata.media_type = cmd->i;  return 0;}/*****************************************************************************/static int action_duplex(FILE *in, const pcl_Command *cmd, void *i){								/* NLS: 60 */  CollectedInfo *ip = i;  ip->fdata.duplex = cmd->i;  if (ip->fdata.duplex < 0 || 2 < ip->fdata.duplex)    imessage(ip->out, 60, "I've found an unknown value for the command to "      "select\nsimplex/duplex printing: %d.\n", ip->fdata.duplex);  return 0;}/*****************************************************************************//* PJL white space. Note: no expressions with side effects permitted. */#define PJL_ws(c)	((c) == ' ' || (c) == '\t')/******************************************************************************  Function to check "@PJL" prefix    Return codes:   0: starts correctly, prefix has been read,   1: starts wrong, read characters have been pushed back,  -1: starts wrong, read characters could not be pushed back and an error      message has been issued.*/static int check_prefix(FILE *in){  static const pcl_Octet prefix[] = "@PJL";    /* Note that the "@PJL" prefix is required to be uppercase in PJL. */  int c, j;  /* Check for prefix followed by white space or EOL */  j = 0;	/* number of matching characters read */  while (j < 4 && (c = fgetc(in)) == prefix[j]) j++;  if (j == 4) {    c = fgetc(in);    if (PJL_ws(c) || c == '\r' || c == '\n') j++;    /* I'm assuming that we're dealing with legal PJL, i.e., the CR is followed       by LF. It is not the responsibility of this program to discover PJL       syntax errors. */  }  if (j < 5) {    /* Keep in mind that one byte of push-back is guaranteed to work. */    if (c != EOF) ungetc(c, in);    while (j > 0) {      j--;      if (ungetc(prefix[j], in) == EOF) {	emessage(80,	  "Error trying to push back characters while parsing PJL:\n  %s.\n",	  strerror(errno));	/* This should only happen for unprofessional PJL, i.e., without a	   terminating ENTER LANGUAGE. */	return -1;      }    }    return 1;  }  /* Ensure we've not read past the end of the line */  if (c == '\n') ungetc(c, in);  return 0;}/*****************************************************************************/#define PJL_letter(c) ('a' <= (c) && (c) <= 'z' || 'A' <= (c) && (c) <= 'Z')/*****************************************************************************/#define TILE_SIZE	200static int action_UEL(FILE *in, const pcl_Command *cmd, void *i){  CollectedInfo *ip = i;  int c;  pcl_Octet *buffer, *s;  size_t allocated, used;  if (cmd->i != 12345) return 1;  /* As we have entered PJL, the previous personality is irrelevant. */  if (ip->fdata.PJL_language != NULL) {    free(ip->fdata.PJL_language); ip->fdata.PJL_language = NULL;  }  buffer = (pcl_Octet *)malloc(TILE_SIZE);  check(buffer);  allocated = TILE_SIZE;  /* Read one PJL command at a time (necessary in order to catch ENTER) */  do {    c = check_prefix(in);    if (c != 0) c = EOF;    else {      /* Read up to EOL or EOF */      used = 0;      while ((c = fgetc(in)) != EOF && c != '\n') {	if (used >= allocated - 1) {	  allocated += TILE_SIZE;	  buffer = (pcl_Octet *)realloc(buffer, allocated);	  check(buffer);	}	buffer[used] = c;	used++;      }      /* Remove an optional trailing CR */      if (used > 0 && buffer[used-1] == 'r') used--;      buffer[used] = '\0';      /* Skip optional whitespace */      s = buffer;      while (PJL_ws(*s)) s++;      if (PJL_letter(*s)) {	pcl_Octet *t;	int l;	/* Isolate command and convert to upper case. Note that we're running	   in an internationalized environment, hence we can't use toupper(). */	t = s;	do {	  if ('a' <= *t && *t <= 'z') *t -= 'a' - 'A';	  t++;	} while (*t != '\0' && !PJL_ws(*t));	/* Identify command */	l = t - s;#if 0	fprintf(stderr, "Command (length %d): `", l);	fwrite(s, 1, l, stderr);	fprintf(stderr, "'.\n");#endif	if (l == sizeof("ENTER") - 1 && strncmp(s, "ENTER", l) == 0 &&	    PJL_ws(*t)) {	  /* Check for "LANGUAGE" */	  s = t + 1;	  while (PJL_ws(*s)) s++;	  t = s;	  while (*t != '\0' && !PJL_ws(*t) && *t != '=') {	    if ('a' <= *t && *t <= 'z') *t -= 'a' - 'A';	    t++;	  }	  l = t - s;	  if (l == sizeof("LANGUAGE") - 1 && strncmp(s, "LANGUAGE", t - s) == 0	      && (PJL_ws(*t) || *t == '=')) {	    s = strchr(t, '=');	/* again assuming legal PJL */	    if (s != NULL) {	      s++;	      while (PJL_ws(*s)) s++;	      if (PJL_letter(*s)){		t = s + 1;		while (*t != '\0' && !PJL_ws(*t)) t++;		ip->fdata.PJL_language = (char *)malloc(t - s + 1);		check(ip->fdata.PJL_language);		strncpy(ip->fdata.PJL_language, s, t - s);		ip->fdata.PJL_language[t - s] = '\0';	      }	    }	    c = EOF;	/* exit PJL and this loop */	  }	}	else if (l == 3 && strncmp(s, "JOB", 3) == 0) {	  /* Don't bother to identify the job name; let the user create an	     unnamed job. */	  static char jobname[] = "";	  ip->fdata.PJL_job = jobname;	}      }    }  }  while (c != EOF);  free(buffer);  return 0;}/*****************************************************************************/								/* NLS: 20 */static int action_compression(FILE *in, const pcl_Command *cmd, void *i){  CollectedInfo *ip = i;  if (cmd->i != pcl_cm_none && cmd->i != pcl_cm_rl && cmd->i != pcl_cm_tiff &&      cmd->i != pcl_cm_delta && cmd->i != pcl_cm_crdr) {    if (!ip->seen_unknown_compression)      imessage(ip->out, 20,	"This file uses at least one compression method for raster data (%d)\n"	"which pcl3 does not know.\n", cmd->i);    ip->seen_unknown_compression = TRUE;  }  else {    if (cmd->i > ip->fdata.compression) ip->fdata.compression = cmd->i;  }  return 0;}/*****************************************************************************//* The following function is only called for "*bV" and "*bW". */static int action_raster_data(FILE *in, const pcl_Command *cmd, void *i){  CollectedInfo *ip = i;  int j;  ip->seen_raster_data = TRUE;  if (!ip->seen_first_colorant && cmd->i > 0 &&      ip->next_plane < ip->first_colorant_planes)    ip->seen_first_colorant = TRUE;  for (j = cmd->i; j > 0; j--) fgetc(in);  if (cmd->chars[2] == 'W') ip->next_plane = 0; else ip->next_plane++;  return 0;}/*****************************************************************************/#define two_octets(index)	(buffer[index]*256 + buffer[(index) + 1])/*****************************************************************************/static void print_CRD(FILE *out, const pcl_Octet *buffer){  int j;  for (j = 0; j < buffer[1]; j++)    imessage(out, 12, "    colorant %d: %4d x %4d ppi %2d levels\n",      j + 1, two_octets(2 + 6*j), two_octets(4 + 6*j),      two_octets(6 + 6*j));  return;}/*****************************************************************************/static int action_CRD(FILE *in, const pcl_Command *cmd, void *i) /* NLS: 30 */{  CollectedInfo *ip = i;  pcl_Octet *buffer;  int errors = 0;  ip->seen_CRD = TRUE;  if (cmd->i <= 0) {    ip->CRD_active = FALSE;    ip->fdata.palette = pcl_no_palette;    ip->fdata.number_of_colorants = 1;    ip->fdata.colorant_array[0].hres = ip->fdata.colorant_array[0].vres = 75;    ip->fdata.colorant_array[0].levels = 2;    ip->first_colorant_planes = 1;    return 0;  }  ip->CRD_active = TRUE;  buffer = (pcl_Octet *)malloc(cmd->i);  check(buffer);  fread(buffer, sizeof(pcl_Octet), cmd->i, in);  if (buffer[0] == 2) {    /* Just occasionally, a little paranoia is good for the soul, let alone for       for the reliability of the program! */    if (2 + buffer[1]*6 != cmd->i) {      emessage(30, "Illegal field length in Configure Raster Data command.\n");      return -1;    }    if (buffer[1] == 1 || buffer[1] == 3 || buffer[1] == 4) {      int j;      ip->fdata.number_of_colorants = buffer[1];      switch (ip->fdata.number_of_colorants) {	case 1:	  ip->fdata.palette = pcl_black; break;	case 3:	  ip->fdata.palette = pcl_CMY; break;	case 4:	  ip->fdata.palette = pcl_CMYK; break;      }      for (j = 0; j < ip->fdata.number_of_colorants; j++) {	ip->fdata.colorant_array[j].hres = two_octets(2 + 6*j);	ip->fdata.colorant_array[j].vres = two_octets(4 + 6*j);	ip->fdata.colorant_array[j].levels = two_octets(6 + 6*j);      }      {	int power = 1;	ip->first_colorant_planes = 0;	while (power < ip->fdata.colorant_array[0].levels) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -