#include #include #include parse_display(argc, argv, p, num, s1, s2, s3, s4, s5, s6, s7, s8, s9) int argc; char *argv[]; struct dparse *p; int num; char s1[], s2[], s3[], s4[], s5[], s6[], s7[], s8[], s9[]; { ERRTYPE err; /* for propagating errors */ int index=1; /* for ordarg */ int got=1; int luts, olays, writemodes; char str[22]; char t1[9], t2[9], t3[9], t4[9], t5[9]; char t6[9], t7[9], t8[9], t9[9]; char *sprintf(); struct umipscf a, olda; getuenv(&olda); p->any_orflag=0; p->any_mode=0; p->any_region=0; p->any_view=0; p->any_table=0; p->any_interch=0; p->any_color=0; p->any_color2=0; p->any_colorstr=0; p->any_colorstr2=0; p->any_debug=0; p->any_escape=0; p->any1=0; p->any2=0; p->any3=0; p->any4=0; p->any5=0; p->any6=0; p->any7=0; p->any8=0; p->any9=0; p->orflag = '='; p->colorch = 'G'; p->colornum = -1; p->colorch2 = 'o'; p->colornum2 = -1; p->colorstr = 0; p->colorstr2 = 0; p->by_rows = 1; p->row_inc = 1; p->col_inc = 1; p->view = 0; p->interch = 'I'; p->debug=0; p->escape=0; p->device = getdevice(argc, argv, &index); if (err = dd_rddevice(p->device, DEV_TABLE, &p->table)) errprnt(dd_err(err)); if (err = dd_rddevice(p->device, DEV_LUTS, &luts)) errprnt(dd_err(err)); if (err = dd_rddevice(p->device, DEV_OLAYS, &olays)) errprnt(dd_err(err)); if (err = dd_rddevice(p->device, DEV_WRITEMODES, &writemodes)) errprnt(dd_err(err)); while (got) { got = 0; if (!p->any_escape) got |= p->any_escape = ordarg(argc, argv, &index, "C/", &p->escape); if (!p->any_orflag) got |= p->any_orflag =ordarg(argc, argv, &index, "C!+=^", &p->orflag); if (!p->any_orflag2) got |=p->any_orflag2=ordarg(argc, argv, &index, "C!+=^", &p->orflag2); if (!p->any_color) { got |= p->any_color = ordarg(argc, argv, &index, "CrgbGAaCco",&p->colorch); if (p->any_color) p->colornum = -1; } if (!p->any_color) if (p->any_color = ordarg(argc, argv, &index, "Io-", &p->colornum)) { p->colorch = argv[index-1][0]; got = 1; } if (!p->any_color2) { got |= p->any_color2 = ordarg(argc, argv, &index, "CrgbGAaCco",&p->colorch2); if (p->any_color2) p->colornum2 = -1; } if (!p->any_color2) if (p->any_color2 = ordarg(argc, argv, &index, "Io-", &p->colornum2)){ p->colorch2 = argv[index-1][0]; got = 1; } if (!p->any_colorstr) got |= p->any_colorstr = ordarg(argc, argv, &index, "IIi", &p->colorstr); if (!p->any_colorstr) got |= p->any_colorstr2 = ordarg(argc, argv, &index, "IIi", &p->colorstr2); if (!p->any_mode) got |= p->any_mode=getmode(argc,argv,&index,&p->by_rows,&p->row_inc,&p->col_inc); if (!p->any_region) got |= p->any_region= getregion(argc,argv,&index,&p->fx,&p->fy,&p->nx,&p->ny, p->device); if (!p->any_view) got |= p->any_view = ordarg(argc, argv, &index, "CVv", &p->view); if (!p->any_table) { got |= p->any_table = ordarg(argc, argv, &index, "ITt", &p->table); if (p->table >= luts) errprnt("Only %d tables on this device",luts); } if (!p->any1 && (num >= 1)) got |= p->any1 = ordarg(argc, argv, &index, s1, &p->f1); if (!p->any2 && (num >= 2)) got |= p->any2 = ordarg(argc, argv, &index, s2, &p->f2); if (!p->any3 && (num >= 3)) got |= p->any3 = ordarg(argc, argv, &index, s3, &p->f3); if (!p->any4 && (num >= 4)) got |= p->any4 = ordarg(argc, argv, &index, s4, &p->f4); if (!p->any5 && (num >= 5)) got |= p->any5 = ordarg(argc, argv, &index, s5, &p->f5); if (!p->any6 && (num >= 6)) got |= p->any6 = ordarg(argc, argv, &index, s6, &p->f6); if (!p->any7 && (num >= 7)) got |= p->any7 = ordarg(argc, argv, &index, s7, &p->f7); if (!p->any8 && (num >= 8)) got |= p->any8 = ordarg(argc, argv, &index, s8, &p->f8); if (!p->any9 && (num >= 9)) got |= p->any9 = ordarg(argc, argv, &index, s9, &p->f9); if (!p->any_interch) got |= p->any_interch=ordarg(argc, argv,&index,"CIiNn",&p->interch); if (!p->any_debug) got |= p->any_debug = ordarg(argc, argv, &index, "CDd", &p->debug); } if (!p->any_orflag2) p->orflag2 = p->orflag; if ((p->colorch == 'o') && (olays == 0) && (writemodes & DD_XOR)) { p->colorch = 'c'; p->orflag = '^'; } if ((p->colorch2 == 'o') && (olays == 0) && (writemodes & DD_XOR)) { p->colorch2 = 'c'; p->orflag2 = '^'; } if ((p->colorch != 'o') && (p->colorch != '-')) p->colornum = -1; if ((p->colorch2 != 'o') && (p->colorch2 != '-')) p->colornum2 = -1; if (!p->any_colorstr) { switch (p->colorch) { case 'r' : case 'g' : case 'b' : case 'G' : p->colorstr = 0xff; break; case 'a' : p->colorstr = 0xfff; break; case 'A' : p->colorstr = 0xffff; break; case 'c' : p->colorstr = 0xffffff; break; case 'C' : p->colorstr = 0xffffffff; break; case '-' : p->colorstr = 1; break; case 'o' : if (p->colornum == -1) p->colorstr = (1 << olays) - 1; else p->colorstr = 1; break; } } if (!p->any_colorstr2) { switch (p->colorch2) { case 'r' : case 'g' : case 'b' : case 'G' : p->colorstr2 = 0xff; break; case 'a' : p->colorstr2 = 0xfff; break; case 'A' : p->colorstr2 = 0xffff; break; case 'c' : p->colorstr2 = 0xffffff; break; case 'C' : p->colorstr2 = 0xffffffff; break; case '-' : p->colorstr2 = 1; break; case 'o' : if (p->colornum2 == -1) p->colorstr2 = (1 << olays) -1; else p->colorstr2 = 1; break; } } strcpy(t1, (num < 1) && (!p->f1) ? "" : (s1[0] == 'C' ? sprintf(str,"%c ",p->f1) : sprintf(str, "%c%d ", s1[1], p->f1))); strcpy(t2, (num < 2) && (!p->f2) ? "" : (s2[0] == 'C' ? sprintf(str,"%c ",p->f2) : sprintf(str, "%c%d ", s2[1], p->f2))); strcpy(t3, (num < 3) && (!p->f3) ? "" : (s3[0] == 'C' ? sprintf(str,"%c ",p->f3) : sprintf(str, "%c%d ", s3[1], p->f3))); strcpy(t4, (num < 4) && (!p->f4) ? "" : (s4[0] == 'C' ? sprintf(str,"%c ",p->f4) : sprintf(str, "%c%d ", s4[1], p->f4))); strcpy(t5, (num < 5) && (!p->f5) ? "" : (s5[0] == 'C' ? sprintf(str,"%c ",p->f5) : sprintf(str, "%c%d ", s5[1], p->f5))); strcpy(t6, (num < 6) && (!p->f6) ? "" : (s6[0] == 'C' ? sprintf(str,"%c ",p->f6) : sprintf(str, "%c%d ", s6[1], p->f6))); strcpy(t7, (num < 7) && (!p->f7) ? "" : (s7[0] == 'C' ? sprintf(str,"%c ",p->f7) : sprintf(str, "%c%d ", s7[1], p->f7))); strcpy(t8, (num < 8) && (!p->f8) ? "" : (s8[0] == 'C' ? sprintf(str,"%c ",p->f8) : sprintf(str, "%c%d ", s8[1], p->f8))); strcpy(t9, (num < 9) && (!p->f9) ? "" : (s9[0] == 'C' ? sprintf(str,"%c ",p->f9) : sprintf(str, "%c%d ", s9[1], p->f9))); sprintf(p->argstr, "%s %s %s%c%s I0x%x %c%s I0x%x %c%c %d %d %d %d %sT", argv[0], dd_dispstring(p->device), (p->orflag ? "! " : ""), p->colorch, ((p->colornum == -1) ? "" : sprintf(str,"%d", p->colornum)), p->colorstr, p->colorch2, ((p->colornum2 == -1) ? "" : sprintf(str,"%d", p->colornum2)), p->colorstr2, (p->by_rows?((p->col_inc == 1)?'l':'r' ):((p->row_inc == 1)?'t':'b')), (p->by_rows?((p->row_inc == 1)?'t':'b' ):((p->col_inc == 1)?'l':'r')), p->fx,p->fy,p->nx,p->ny, (p->view?"V ":"")); sprintf(p->argstr, "%d %c %s%s%s%s%s%s%s%s%s\n", p->table, p->interch, t1,t2,t3,t4,t5,t6,t7,t8,t9); if (p->debug) fprintf(stderr, "%s", p->argstr); if (p->debug == 'D') dd_set(0,DD_DEBUG,1); if (index < argc) { fprintf(stderr,"Bad usage, see manual entry for %s or intro_display\n",argv[0]); errprnt("Couldn't do anything with %s",argv[index]); } if (p->view) if ((p->colorch == '-') || (p->colorch == 'o') || (p->colorch == 'A') || (p->colorch == 'C')) errprnt("Overlays and single bitplanes incompatible with view option"); getuenv(&a); if (p->escape) { a.fx = olda.fx; a.fy = olda.fy; a.nx = olda.nx; a.ny = olda.ny; } setuenv(&a); switch (p->colorch) { case 'r' : p->band = RED_BAND; break; case 'g' : p->band = GREEN_BAND; break; case 'b' : p->band = BLUE_BAND; break; case 'G' : p->band = GRAY_BAND; break; default : p->band = -1; } return(0); }