home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 443.lha / pcl2english_v2.0 / asterisk.c < prev    next >
C/C++ Source or Header  |  1990-12-02  |  12KB  |  549 lines

  1. /* $RCSfile: asterisk.c,v $  $Revision: 2.0 $ */
  2.  
  3. #include <stdio.h>
  4. #include "gdefs.h"
  5. #include "externals.h"
  6. #include "protos.h"
  7.  
  8. extern FILE *ifile,*ofile;
  9.  
  10. static int    fill_area = 0; /* Start with set to black fill (default) */
  11.  
  12. static char        *compress[] = {
  13.     "Unencoded",
  14.     "Run-Length Encoded",
  15.     "Tagged Image File Format (TIFF)",
  16. };
  17.  
  18. static char        *font_ctl[] = {
  19.     "Delete all soft fonts",
  20.     "Delete all temporary soft fonts",
  21.     "Delete soft font (last ID specified)",
  22.     "Delete character code (last ID and character code)",
  23.     "Make soft font temporary (last font ID specified)",
  24.     "Make soft font permanent (last font ID specified)",
  25.     "Copy/Assign current invoked font as temporary",
  26. };
  27.  
  28. static char        *fill_patterns[] = {
  29.     "???",
  30.     "Horizontal Lines",
  31.     "Vertical Lines",
  32.     "Diagonal Lines ///",
  33.     "Diagonal Lines \\\\\\",
  34.     "Square Grid",
  35.     "Diagonal Grid",
  36. };
  37.  
  38. static char        *fill_types[] = {
  39.     "Solid area (black)",
  40.     "White",
  41.     "Shaded",
  42.     "HP defined pattern",
  43. };
  44.  
  45. static char        *fill_pct[] = {
  46.     "0",
  47.     "1-2",
  48.     "2-10",
  49.     "10-20",
  50.     "20-35",
  51.     "35-55",
  52.     "55-80",
  53.     "80-99",
  54.     "100",
  55. };
  56.  
  57. static char        *graphics_mode[] = {
  58.     "Image in orientation of logical page (rotate image)",
  59.     "???",
  60.     "???",
  61.     "Image along width of physical page (landscape compatible)",
  62. };
  63.  
  64. static char        *graphics_quality[] = {
  65.     "Default (high)",
  66.     "Draft",
  67.     "High",
  68. };
  69.  
  70. void decode_asterisk(void)        /* <Esc>* */
  71. {
  72.     int         start_pos;
  73.     int         stop_pos;
  74.     int         i;
  75.     int         done;
  76.     char     c1,c2,c3;
  77.  
  78.     c1 = esc_string[1];
  79.     c2 = esc_string[2];
  80.     c3 = esc_string[3];
  81.     if (c2 == 'b') {
  82.         start_pos = stop_pos = 3;
  83.         done = FALSE;
  84.         while (done == FALSE) {
  85.             get_num(&stop_pos,0);
  86.             c3 = esc_string[stop_pos];
  87.             if (raster_mode == NO_RASTER) {
  88.                 print_sub_string(2, start_pos, stop_pos);
  89.             }
  90.             switch (c3) {
  91.                 case 'm':
  92.                 case 'M':
  93.                     fprintf(ofile,"Compression mode = ");
  94.                     if ((num >= 0) && (num <= 2)) {
  95.                         fprintf(ofile,"%s\n",compress[num]);
  96.                     }
  97.                     else {
  98.                         fprintf(ofile,questions);
  99.                     }
  100.                     break;
  101.                 case 'V':    /* Can't have 'v' */
  102.                 case 'W':    /* Can't have 'w' */
  103.                     if (raster_mode != NO_RASTER) {
  104.                         /* Count number of "extra" (other than first)
  105.                            like lines */
  106.                         raster_count++;    
  107.                     }
  108.                     else {
  109.                         if (c3 == 'V') {
  110.                             raster_mode = V_RASTER;
  111.                             fprintf(ofile,
  112.                                 "Next %d bytes form one plane ",num);
  113.                             fprintf(ofile,
  114.                                 "of raster graphics data (PaintJet).\n");
  115.                         }
  116.                         else {
  117.                             raster_mode = W_RASTER;
  118.                             fprintf(ofile,
  119.                                 "Next %d bytes form (final) plane ",num);
  120.                             fprintf(ofile,
  121.                                 "of raster graphics data.\n");
  122.                         }
  123.                         for (i=0; i<=stop_pos; i++) {
  124.                             raster_header[i] = esc_string[i];
  125.                         }
  126.                         raster_header[i] = 0;
  127.                         raster_count = 0;
  128.                     }
  129.                     for (i=0; i<num; i++) {
  130.                         c1 = getc(ifile);
  131.                     }
  132.                     done = TRUE;
  133.                     break;
  134.                 case 'x':
  135.                 case 'X':
  136.                     fprintf(ofile,"Horizontal offset = ");
  137.                     if ((num >= 0) && (num <= 32767)) {
  138.                         fprintf(ofile,"%d pixels\n",num);
  139.                     }
  140.                     else {
  141.                         fprintf(ofile,out_of_range,num);
  142.                     }
  143.                     break;
  144.                 case 'y':
  145.                 case 'Y':
  146.                     fprintf(ofile,"Vertical offset = ");
  147.                     if ((num >= -5) && (num <= 32767)) {
  148.                         fprintf(ofile,"%d pixels\n",num);
  149.                     }
  150.                     else {
  151.                         fprintf(ofile,out_of_range,num);
  152.                     }
  153.                     break;
  154.                 default:
  155.                     fprintf(ofile,"%s",bad_esc);
  156.                     break;
  157.             }
  158.             stop_pos++;
  159.             start_pos = stop_pos;
  160.             if (esc_string[start_pos] == 0) {
  161.                 done = TRUE;
  162.             }
  163.         }
  164.     }
  165.     else if (c2 == 'c') {
  166.         start_pos = stop_pos = 3;
  167.         done = FALSE;
  168.         while (done == FALSE) {
  169.             get_num(&stop_pos,0);
  170.             c3 = esc_string[stop_pos];
  171.             print_sub_string(2, start_pos, stop_pos);
  172.             switch (c3) {
  173.                 case 'a':
  174.                 case 'A':
  175.                     fprintf(ofile,"Horizontal rectangle size = ");
  176.                     if ((num >= 0)) {
  177.                         fprintf(ofile,"%d dots (300 dpi)\n",num);
  178.                     }
  179.                     else {
  180.                         fprintf(ofile,out_of_range,num);
  181.                     }
  182.                     break;
  183.                 case 'b':
  184.                 case 'B':
  185.                     fprintf(ofile,"Vertical rectangle size = ");
  186.                     if ((num >= 0)) {
  187.                         fprintf(ofile,"%d dots (300 dpi)\n",num);
  188.                     }
  189.                     else {
  190.                         fprintf(ofile,out_of_range,num);
  191.                     }
  192.                     break;
  193.                 case 'd':
  194.                 case 'D':
  195.                     fprintf(ofile,"Specify Font ID to be ");
  196.                     if ((num >= 0) && (num <= 32767)) {
  197.                         fprintf(ofile,"%d\n",num);
  198.                     }
  199.                     else {
  200.                         fprintf(ofile,out_of_range,num);
  201.                     }
  202.                     break;
  203.                 case 'e':
  204.                 case 'E':
  205.                     fprintf(ofile,"Specify the character code to be ");
  206.                     if ((num >= 0) && (num <= 255)) {
  207.                         fprintf(ofile,"%d\n",num);
  208.                     }
  209.                     else {
  210.                         fprintf(ofile,out_of_range,num);
  211.                     }
  212.                     break;
  213.                 case 'f':
  214.                 case 'F':
  215.                     fprintf(ofile,"Font/character control =\n");
  216.                     indent(5);
  217.                     if ((num >= 0) && (num <= 6)) {
  218.                         fprintf(ofile,"%s\n",font_ctl[num]);
  219.                     }
  220.                     else {
  221.                         fprintf(ofile,questions);
  222.                     }
  223.                     break;
  224.                 case 'g':
  225.                 case 'G':
  226.                     fprintf(ofile,"Area fill ID = ");
  227.                     switch (fill_area) {
  228.                         case 0:
  229.                             fprintf(ofile,
  230.                                 "Not appropriate for solid fill\n");
  231.                             break;
  232.                         case 1:
  233.                             fprintf(ofile,
  234.                                 "Not appropriate for white fill\n");
  235.                             break;
  236.                         case 2:
  237.                             if ((num >= 0) && (num <= 100)) {
  238.                                 i = 0;
  239.                                 if (num < 1) num = 0;
  240.                                 else if (num <= 2) i = 1;
  241.                                 else if (num <= 10) i = 2;
  242.                                 else if (num <= 20) i = 3;
  243.                                 else if (num <= 35) i = 4;
  244.                                 else if (num <= 55) i = 5;
  245.                                 else if (num <= 80) i = 6;
  246.                                 else if (num <= 99) i = 7;
  247.                                 else i = 8;
  248.                                 fprintf(ofile,"%s %s\n",fill_pct[i],"%");
  249.                             }
  250.                             else {
  251.                                 fprintf(ofile,questions);
  252.                             }
  253.                             break;
  254.                         case 3:
  255.                             if ((num >= 0) && (num <= 6)) {
  256.                                 fprintf(ofile,"%s\n",fill_patterns[num]);
  257.                             }
  258.                             else {
  259.                                 fprintf(ofile,questions);
  260.                             }
  261.                             break;
  262.                         default:    /* Shouldn't happen */
  263.                             fprintf(ofile,"%s",bad_esc);
  264.                             break;
  265.                     } /* end switch */
  266.                     break;
  267.                 case 'h':
  268.                 case 'H':
  269.                     fprintf(ofile,"Horizontal rectangle size = ");
  270.                     if ((num >= 0)) {
  271.                         fprintf(ofile,"%d/720 inch\n",num);
  272.                     }
  273.                     else {
  274.                         fprintf(ofile,out_of_range,num);
  275.                     }
  276.                     break;
  277.                 case 'p':
  278.                 case 'P':
  279.                     fprintf(ofile,"Fill rectangular area = ");
  280.                     if ((num >= 0) && (num <= 3)) {
  281.                         fill_area = num;
  282.                         fprintf(ofile,"%s fill\n",fill_types[num]);
  283.                     }
  284.                     else {
  285.                         fprintf(ofile,questions);
  286.                     }
  287.                     break;
  288.                 case 'v':
  289.                 case 'V':
  290.                     fprintf(ofile,"Vertical rectangle size = ");
  291.                     if ((num >= 0)) {
  292.                         fprintf(ofile,"%d/720 inch\n",num);
  293.                     }
  294.                     else {
  295.                         fprintf(ofile,out_of_range,num);
  296.                     }
  297.                     break;
  298.                 default:
  299.                     fprintf(ofile,"%s",bad_esc);
  300.                     break;
  301.             }
  302.             stop_pos++;
  303.             start_pos = stop_pos;
  304.             if (esc_string[start_pos] == 0) {
  305.                 done = TRUE;
  306.             }
  307.         }
  308.     }
  309.     else if (c2 == 'p') {
  310.         start_pos = stop_pos = 3;
  311.         done = FALSE;
  312.         while (done == FALSE) {
  313.             get_num(&stop_pos,0);
  314.             c3 = esc_string[stop_pos];
  315.             print_sub_string(2, start_pos, stop_pos);
  316.             switch (c3) {
  317.                 case 'x':
  318.                 case 'X':
  319.                     if (plus) {
  320.                         fprintf(ofile,
  321.                             "Move cursor right %d dots (300 dpi)\n",num);
  322.                     }
  323.                     else if (minus) {
  324.                         fprintf(ofile,
  325.                             "Move cursor left %d dots (300 dpi)\n",-num);
  326.                     }
  327.                     else {
  328.                         fprintf(ofile,
  329.                             "Move cursor to %d/300 inch ",num);
  330.                         fprintf(ofile,
  331.                             "from left boundary of page.\n");
  332.                     }
  333.                     break;
  334.                 case 'y':
  335.                 case 'Y':
  336.                     if (plus) {
  337.                         fprintf(ofile,
  338.                             "Move cursor down %d dots (300 dpi)\n",num);
  339.                     }
  340.                     else if (minus) {
  341.                         fprintf(ofile,
  342.                             "Move cursor up %d dots (300 dpi)\n",-num);
  343.                     }
  344.                     else {
  345.                         fprintf(ofile,
  346.                             "Move cursor to %d/300 inch ",num);
  347.                         fprintf(ofile, "down from top margin.\n");
  348.                     }
  349.                     break;
  350.                 default:
  351.                     fprintf(ofile,"%s",bad_esc);
  352.                     break;
  353.             }
  354.             stop_pos++;
  355.             start_pos = stop_pos;
  356.             if (esc_string[start_pos] == 0) {
  357.                 done = TRUE;
  358.             }
  359.         }
  360.     }
  361.     else if (c2 == 'r') {
  362.         start_pos = stop_pos = 3;
  363.         done = FALSE;
  364.         while (done == FALSE) {
  365.             get_num(&stop_pos,0);
  366.             c3 = esc_string[stop_pos];
  367.             print_sub_string(2, start_pos, stop_pos);
  368.             switch (c3) {
  369.                 case 'a':
  370.                 case 'A':
  371.                     fprintf(ofile,"Start raster graphics.\n");
  372.                     indent(5);
  373.                     if (num == 0) {
  374.                         fprintf(ofile,
  375.                             "Graphics start at left-most printable region.\n");
  376.                     }
  377.                     else if (num == 1) {
  378.                         fprintf(ofile,
  379.                             "Set starting position and left graphics margin\n");
  380.                         indent(5);
  381.                         fprintf(ofile,"to current position.\n");
  382.                     }
  383.                     else {
  384.                         fprintf(ofile,questions);
  385.                     }
  386.                     break;
  387.                 case 'b':
  388.                 case 'B':
  389.                     fprintf(ofile,"End raster graphics.\n");
  390.                     if (num != 0) {
  391.                         fprintf(ofile,questions);
  392.                     }
  393.                     break;
  394.                 case 'f':
  395.                 case 'F':
  396.                     fprintf(ofile,"Raster graphics mode =\n");
  397.                     indent(5);
  398.                     if ((num >= 0) && (num <= 3)) {
  399.                         fprintf(ofile,"%s\n",graphics_mode[num]);
  400.                     }
  401.                     else {
  402.                         fprintf(ofile,questions);
  403.                     }
  404.                     break;
  405.                 case 'k':
  406.                 case 'K':
  407.                     fprintf(ofile,"Return Model number\n");
  408.                     if (num != 0) {
  409.                         fprintf(ofile,questions);
  410.                     }
  411.                     break;
  412.                 case 'q':
  413.                 case 'Q':
  414.                     fprintf(ofile,"Graphics quality = ");
  415.                     if ((num >= 0) && (num <= 2)) {
  416.                         fprintf(ofile,"%s\n",graphics_quality[num]);
  417.                     }
  418.                     else {
  419.                         fprintf(ofile,questions);
  420.                     }
  421.                     break;
  422.                 case 's':
  423.                 case 'S':
  424.                     fprintf(ofile,"Image width (pixels/row) = ");
  425.                     if ((num >= 0) && (num <= 32767)) {
  426.                         fprintf(ofile,"%d\n",num);
  427.                     }
  428.                     else {
  429.                         fprintf(ofile,out_of_range,num);
  430.                     }
  431.                     break;
  432.                 case 'u':
  433.                 case 'U':
  434.                     fprintf(ofile,"Number of color planes per row = ");
  435.                     if ((num >= 1) && (num <= 4)) {
  436.                         fprintf(ofile,"%d\n",num);
  437.                     }
  438.                     else {
  439.                         fprintf(ofile,out_of_range,num);
  440.                     }
  441.                     break;
  442.                 default:
  443.                     fprintf(ofile,"%s",bad_esc);
  444.                     break;
  445.             }
  446.             stop_pos++;
  447.             start_pos = stop_pos;
  448.             if (esc_string[start_pos] == 0) {
  449.                 done = TRUE;
  450.             }
  451.         }
  452.     }
  453.     else if (c2 == 't') {
  454.         start_pos = stop_pos = 3;
  455.         done = FALSE;
  456.         while (done == FALSE) {
  457.             get_num(&stop_pos,0);
  458.             c3 = esc_string[stop_pos];
  459.             print_sub_string(2, start_pos, stop_pos);
  460.             switch (c3) {
  461.                 case 'r':
  462.                 case 'R':
  463.                     fprintf(ofile,"Resolution (dots per inch) = ");
  464.                     switch (num) {
  465.                         case 75:
  466.                         case 100:
  467.                         case 150:
  468.                         case 300:
  469.                         case 90:
  470.                         case 180:
  471.                             fprintf(ofile,"%d\n",num);
  472.                             break;
  473.                         default:
  474.                             fprintf(ofile,"%d ???\n",num);
  475.                             break;
  476.                         }
  477.                     break;
  478.                 default:
  479.                     fprintf(ofile,"%s",bad_esc);
  480.                     break;
  481.             }
  482.             stop_pos++;
  483.             start_pos = stop_pos;
  484.             if (esc_string[start_pos] == 0) {
  485.                 done = TRUE;
  486.             }
  487.         }
  488.     }
  489.     else if (c2 == 'v') {
  490.         start_pos = stop_pos = 3;
  491.         done = FALSE;
  492.         while (done == FALSE) {
  493.             get_num(&stop_pos,0);
  494.             c3 = esc_string[stop_pos];
  495.             print_sub_string(2, start_pos, stop_pos);
  496.             switch (c3) {
  497.                 case 'a':
  498.                 case 'A':
  499.                     fprintf(ofile,"Red component = ");
  500.                     if ((num >= 4) && (num <= 90)) {
  501.                         fprintf(ofile,"%d\n",num);
  502.                     }
  503.                     else {
  504.                         fprintf(ofile,out_of_range,num);
  505.                     }
  506.                     break;
  507.                 case 'b':
  508.                 case 'B':
  509.                     fprintf(ofile,"Green component = ");
  510.                     if ((num >= 4) && (num <= 88)) {
  511.                         fprintf(ofile,"%d\n",num);
  512.                     }
  513.                     else {
  514.                         fprintf(ofile,out_of_range,num);
  515.                     }
  516.                     break;
  517.                 case 'c':
  518.                 case 'C':
  519.                     fprintf(ofile,"Blue component = ");
  520.                     if ((num >= 6) && (num <= 85)) {
  521.                         fprintf(ofile,"%d\n",num);
  522.                     }
  523.                     else {
  524.                         fprintf(ofile,out_of_range,num);
  525.                     }
  526.                     break;
  527.                 case 'i':
  528.                 case 'I':
  529.                     fprintf(ofile,"Put color into palette at index ");
  530.                     if ((num >= 0) && (num <= 15)) {
  531.                         fprintf(ofile,"%d\n",num);
  532.                     }
  533.                     else {
  534.                         fprintf(ofile,out_of_range,num);
  535.                     }
  536.                     break;
  537.                 default:
  538.                     fprintf(ofile,"%s",bad_esc);
  539.                     break;
  540.             }
  541.             stop_pos++;
  542.             start_pos = stop_pos;
  543.             if (esc_string[start_pos] == 0) {
  544.                 done = TRUE;
  545.             }
  546.         }
  547.     }
  548. }
  549.