home *** CD-ROM | disk | FTP | other *** search
- /* $RCSfile: amp.c,v $ $Revision: 2.0 $ */
-
- #include <stdio.h>
- #include "gdefs.h"
- #include "externals.h"
- #include "protos.h"
-
- extern FILE *ifile,*ofile;
-
- static char *macro_func[] =
- {
- "Start macro definition",
- "Stop macro definition",
- "Execute macro",
- "Call macro",
- "Enable auto macro overlay",
- "Disable auto macro overlay",
- "Delete all macros",
- "Delete all temporary macros",
- "Delete macro",
- "Make macro temporary",
- "Make macro permanent",
- };
-
- static char *eol[] =
- {
- "CR=CR; LF=LF; FF=FF",
- "CR=CR+LF; LF=LF; FF=FF",
- "CR=CR; LF=CR+LF; FF=CR+FF",
- "CR=CR+LF; LF=CR+LF; FF=CR+FF",
- };
-
- static char *paper[] =
- {
- "Eject Page",
- "Default. (LaserJet=Input Cassette, IIP=MP tray)",
- "Manual Feed",
- "Manual Envelope Feed",
- "Lower Tray",
- "???",
- "Envelope Feeder",
- };
-
- static char *perf[] =
- {
- "disable",
- "enable",
- };
-
- static char *orient[] =
- {
- "Portrait",
- "Landscape",
- };
-
- static char *offset[] =
- {
- "Set stacking position to default",
- "Toggle stacking position",
- };
-
- static char *pitch[] =
- {
- "Default (80 chars per line, printer specific)",
- "Expanded (ThinkJet)",
- "Compressed (16-21 cpi, printer specific)",
- "Expanded-Compressed (10-11 cpi, printer specific)",
- "18 cpi, 144 cpl (PaintJet)",
- };
-
- static char *print_mode[] =
- {
- "Left to right unidirectional text printing",
- "Bidirectional text printing",
- "Right to left unidirectional text printing",
- "Transparency (PaintJet)",
- "???",
- "Text Scale OFF",
- "Text Scale ON (put 66 lines on page)",
- };
-
- static char *color[] =
- {
- "Black (default)",
- "Red",
- "Green",
- "Yellow",
- "Blue",
- "Magenta",
- "Cyan",
- "White (no text)",
- };
-
- static char *wrap[] =
- {
- "enabled",
- "disabled",
- };
-
- static char *underline[] =
- {
- "enable fixed",
- "single fixed",
- "double fixed",
- "single float",
- "double float",
- };
-
- static char *enh_ctl[] =
- {
- "Line-by-line ON",
- "Line-by-line OFF",
- };
-
- static char *page_side[] =
- {
- "Next",
- "Front",
- "Back",
- };
-
- static char *duplex[] =
- {
- "Simplex",
- "Duplex long-edge binding",
- "Duplex short-edge binding",
- };
-
- void decode_ampersand(void) /* <Esc>& */
- {
- int start_pos;
- int stop_pos;
- int i;
- int done;
- char c1,c2,c3;
-
- c1 = esc_string[1];
- c2 = esc_string[2];
- c3 = esc_string[3];
- if (c2 == 'a') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'c':
- case 'C':
- if (plus) {
- if (is_float) {
- fprintf(ofile,
- "Move cursor right %d.%s columns\n",
- num, fraction);
- }
- else {
- fprintf(ofile,
- "Move cursor right %d columns\n",num);
- }
- current_col += num;
- }
- else if (minus) {
- if (is_float) {
- fprintf(ofile,
- "Move cursor left %d.%s columns\n",
- -num, fraction);
- }
- else {
- fprintf(ofile,
- "Move cursor left %d columns\n",-num);
- }
- current_col += num;
- if (current_col < 0){
- current_col = 0;
- }
- }
- else {
- if (is_float) {
- fprintf(ofile,
- "Move cursor to column %d.%s. ",
- num, fraction);
- fprintf(ofile,"First column is column 0\n");
- }
- else {
- fprintf(ofile,"Move cursor to column %d. ",num);
- fprintf(ofile,"First column is column 0\n");
- }
- current_col = num;
- if (current_col < 0){
- current_col = 0;
- }
- }
- break;
- case 'g':
- case 'G':
- fprintf(ofile,
- "Page side selection (LaserJet IID) = ");
- if ((num >= 0) && (num <= 2)) {
- fprintf(ofile,"%s %s\n",page_side[num],"side");
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'h':
- case 'H':
- if (plus) {
- fprintf(ofile,"Move cursor right %d/720 inch\n",num);
- }
- else if (minus) {
- fprintf(ofile,"Move cursor left %d/720 inch\n",-num);
- }
- else {
- fprintf(ofile,
- "Move cursor to %d/720 inch from left print limit.\n",
- num);
- }
- break;
- case 'l':
- case 'L':
- fprintf(ofile,"Set left margin to %d (columns). ", num);
- fprintf(ofile,"First column is 0\n");
- if ((num >= 0) && (num <= last_col)) {
- first_col = num;
- }
- else {
- indent(1);
- fprintf(ofile,
- "WARNING!!! There may be a problem setting this margin\n");
- }
- break;
- case 'm':
- case 'M':
- fprintf(ofile,"Set right margin to %d (columns)\n",num);
- if ((num > 0) && (num >= first_col)) {
- last_col = num;
- }
- else {
- indent(1);
- fprintf(ofile,
- "WARNING!!! There may be a problem setting this margin\n");
- }
- break;
- case 'r':
- case 'R':
- if (plus) {
- if (is_float) {
- fprintf(ofile,
- "Move cursor down %d.%s rows\n",
- num, fraction);
- }
- else {
- fprintf(ofile,"Move cursor down %d rows\n",num);
- }
- }
- else if (minus) {
- if (is_float) {
- fprintf(ofile,
- "Move cursor up %d.%s rows\n",
- -num, fraction);
- }
- else {
- fprintf(ofile,"Move cursor up %d rows\n",-num);
- }
- }
- else {
- if (is_float) {
- fprintf(ofile,"Move cursor to row %d.%s. ",
- num, fraction);
- fprintf(ofile,
- "First row from top margin is row 0\n");
- }
- else {
- fprintf(ofile,
- "Move cursor to row %d. ",num);
- fprintf(ofile,
- "First row from top margin is row 0\n");
- }
- }
- break;
- case 'v':
- case 'V':
- if (plus) {
- fprintf(ofile,"Move cursor down %d/720 inch\n",num);
- }
- else if (minus) {
- fprintf(ofile,"Move cursor up %d/720 inch\n",-num);
- }
- else {
- fprintf(ofile,
- "Move cursor to %d/720 inch from top margin.\n",
- num);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'd') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- c3 = esc_string[stop_pos];
- if (c3 == '@') {
- print_sub_string(2, start_pos, stop_pos);
- fprintf(ofile,"Disable Underline\n");
- done = TRUE;
- }
- else {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'd':
- case 'D':
- fprintf(ofile,"Underline control = ");
- if ((num >= 0) && (num <= 4)) {
- fprintf(ofile,"%s\n",underline[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'f') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 's':
- case 'S':
- if (num == 0) {
- fprintf(ofile,"Push (store) current position\n");
- }
- else if (num == 1) {
- fprintf(ofile,"Pop (restore) last pushed position\n");
- }
- else {
- fprintf(ofile,"Push/Pop control ");
- fprintf(ofile,questions);
- }
- break;
- case 'x':
- case 'X':
- fprintf(ofile,"Macro control = ");
- if ((num >= 0) && (num <= 10)) {
- fprintf(ofile,"%s\n",macro_func[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'y':
- case 'Y':
- fprintf(ofile,"Macro ID # = %d\n",num);
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'k') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'e':
- case 'E':
- fprintf(ofile,"Enhancement (underlining) control = ");
- if ((num >= 0) && (num <= 1)) {
- fprintf(ofile,"%s\n",enh_ctl[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'f':
- case 'F':
- fprintf(ofile,"SI/SO control = ");
- if ((num >= 0) && (num <= 1)) {
- fprintf(ofile,"%s\n",enh_ctl[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'g':
- case 'G':
- fprintf(ofile,"Line termination. ");
- if ((num >= 0) && (num <= 3)) {
- fprintf(ofile,"%s\n",eol[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'h':
- case 'H':
- fprintf(ofile,"Set Horizontal Motion Index (HMI) to ");
- if ((num >= 0) && (num <= 126)) {
- fprintf(ofile,"%d/120 inch\n",num);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 's':
- case 'S':
- fprintf(ofile,"Print pitch = ");
- if ((num >= 0) && (num <= 4)) {
- fprintf(ofile,"%s\n",pitch[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'w':
- case 'W':
- fprintf(ofile,"Print mode = ");
- if ((num >= 0) && (num <= 6)) {
- fprintf(ofile,"%s\n",print_mode[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'l') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'a':
- case 'A':
- fprintf(ofile,"Job (page) size = ");
- switch (num) {
- case 0:
- fprintf(ofile,"Default\n");
- break;
- case 1:
- fprintf(ofile,"Executive\n");
- break;
- case 2:
- fprintf(ofile,"Letter\n");
- break;
- case 3:
- fprintf(ofile,"Legal\n");
- break;
- case 26:
- fprintf(ofile,"A4\n");
- break;
- case 80:
- fprintf(ofile,"Monarch Envelope\n");
- break;
- case 81:
- fprintf(ofile,"COM 10 Envelope\n");
- break;
- case 90:
- fprintf(ofile,"DL Envelope\n");
- break;
- case 91:
- fprintf(ofile,"C5 Envelope\n");
- break;
- default:
- fprintf(ofile,questions);
- break;
- }
- break;
- case 'c':
- case 'C':
- fprintf(ofile,"Set Vertical Motion Index (VMI) to ");
- if ((num >= 0) && (num <= 126)) {
- fprintf(ofile,"%d/48 inch\n",num);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'd':
- case 'D':
- fprintf(ofile,"Lines per inch = ");
- switch (num) {
- case 1:
- case 2:
- case 4:
- case 6:
- case 8:
- case 12:
- case 16:
- case 24:
- case 48:
- fprintf(ofile,"%d\n",num);
- break;
- default:
- fprintf(ofile,
- "??? %d not supported. Command ignored.\n",
- num);
- break;
- }
- break;
- case 'e':
- case 'E':
- fprintf(ofile,"Top margin = %d lines. ", num);
- fprintf(ofile,"Text length defaults to:\n");
- indent(5);
- fprintf(ofile,"page_length - top_margin - half_inch\n");
- if (num < 2) {
- indent(5);
- fprintf(ofile,"Avoid using values of 0 and 1.\n");
- }
- break;
- case 'f':
- case 'F':
- if (num == 0) {
- fprintf(ofile,"Default text length\n");
- }
- else {
- fprintf(ofile,"Text length = %d lines\n",num);
- }
- break;
- case 'h':
- case 'H':
- fprintf(ofile,"Paper source = ");
- if ((num >= 0) && (num <= 6)) {
- fprintf(ofile,"%s\n",paper[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'l':
- case 'L':
- fprintf(ofile,"Perforation skip ");
- if ((num >= 0) && (num <= 1)) {
- fprintf(ofile,"%s\n",perf[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'o':
- case 'O':
- fprintf(ofile,"Orientation = ");
- if ((num >= 0) && (num <= 1)) {
- fprintf(ofile,"%s\n",orient[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'p':
- case 'P':
- fprintf(ofile,"Text length = ");
- if ((num >= 5) && (num <= 128)) {
- fprintf(ofile,"%d lines\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 's':
- case 'S':
- fprintf(ofile,"Simplex/Duplex print (LaserJet IID) = ");
- if ((num >= 0) && (num <= 2)) {
- fprintf(ofile,"%s\n",duplex[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 't':
- case 'T':
- fprintf(ofile,"Job offset control (LaserJet 500+).\n");
- indent(5);
- if ((num >= 0) && (num <= 1)) {
- fprintf(ofile,"%s\n",offset[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'u':
- case 'U':
- fprintf(ofile,
- "Long edge offset registration = %d/720 inch\n",num);
- break;
- case 'x':
- case 'X':
- fprintf(ofile,"Number of copies = ");
- if ((num >= 1) && (num <= 99)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'z':
- case 'Z':
- fprintf(ofile,
- "Short (top) edge offset registration = %d/720 inch\n",
- num);
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'p') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'X': /* Can't have 'x' */
- fprintf(ofile,"Transparent print data for next ");
- fprintf(ofile,"%d characters\n",num);
- for (i=0; i<num; i++) {
- c1 = getc(ifile);
- }
- done = TRUE;
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 's') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'c':
- case 'C':
- fprintf(ofile,"End of line wrap ");
- if ((num >= 0) && (num <= 1)) {
- fprintf(ofile,"%s\n",wrap[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'v') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 's':
- case 'S':
- fprintf(ofile,"Text color (PaintJet) = ");
- if ((num >= 0) && (num <= 7)) {
- fprintf(ofile,"%s\n",color[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else {
- fprintf(ofile,"%s",bad_esc);
- }
- }
-