home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / dots151.zip / GRAPHSRC.ZIP / GHI.C < prev    next >
C/C++ Source or Header  |  1990-07-15  |  17KB  |  586 lines

  1. /*    plot - interface routine for Houstin Instruments plotter
  2.  
  3.     history...
  4.         15 Jul 90    ver 1.30: can get parameters from configuration file
  5.         20 Jun 90    ver 1.27: Adapted to Turbo C.  Improved file handling
  6.                     (using only stream functions now, so output file need
  7.                     not exist).  Revised message wording.
  8.         25 Apr 89    dummy routines for flipping lines and setting background
  9.                     color.
  10.         11 Sep 86    No logic seeking (starting at near end of line segment)
  11.                     for dashed lines.
  12.         3 May 86    Default height corrected: size code 2.
  13.                     Default plot height now 6 inches.
  14.         25 Apr 86    Implementing dashed lines in hardware.
  15.         19 Apr 86    Velocity is adjustable.
  16.         15 Apr 86    Assuming distance (and plot time) is proportional to
  17.                         maximum of delx and dely.
  18.                     Asking user to set origin with plotter controls.
  19.                     Assuming pen is up after printing text.
  20.                     Defining prim_attr.
  21.  
  22.     bugs...
  23. Should add some line feeds.
  24. default file name should not be a port?
  25.  
  26. displayed text must not have '%', and '_', CR, LF, or TAB are replaced by ' '.
  27. Could use \000 to terminate text strings.
  28. Could delay getting pen until plotting is actually required.
  29. needs test for presence of plotter...what's command ER  "report"?
  30. needs way to set character orientation.
  31. Doesn't correctly get to near end of line segment.
  32.  
  33. bench needs to check for "erasing"
  34. g3x needs to call set_height to set character size.
  35.  
  36. */
  37.  
  38. #include <stdio.h>
  39. #include <string.h>
  40. #include <math.h>
  41. #include "g.h"
  42. #include "config.h"
  43.  
  44. #define streq !strcmp
  45. #define EOT '_'
  46.                 /* default margins, defined assuming portrait orientation */
  47. #define LMARGIN 1.125
  48. #define RMARGIN 1.125
  49. #define TMARGIN 1.5
  50. #define BMARGIN 1.5
  51. #define BUFSIZE 80
  52.  
  53. /*    imported variables    */
  54.  
  55. extern char *default_script_file;
  56.  
  57. /*    exported graphics variables    */
  58.  
  59. char *machine        =    "Houstin Instruments DMP-29";
  60. char *interface_version    =    "1.30";
  61. char *config_file    =    NULL;
  62. static char default_config_file[] = "GRAPHHI.CFG";
  63. int plotting_device    =    1;
  64. int erasing            =    0;
  65. int flipping        =    0;
  66.  
  67. int max_color        =    7;
  68.  
  69. int current_color    =    1;
  70. int pixels_wide        =    320;        /* width of plot area in pixels */
  71. int pixels_high        =    200;        /* height of plot area in pixels */
  72. double best_width    =    1.;
  73. double best_height    =    .648;        /* relative height/width parameters */
  74. int pen_diameter    =    3;
  75.  
  76.  
  77. int char_rows        =    25;            /* text parameters */
  78. int    char_columns    =    40;
  79. int    char_height        =    8;
  80. int    char_width        =    8;
  81. int    x_offset        =    0;
  82. int    y_offset        =    7;
  83. int    char_v_adjusted    =    1;
  84. int    char_h_adjusted    =    1;
  85.  
  86. int has_cursor_keys    =    0;
  87. int    up_arrow        =    0x48;        /* cursor keys */
  88. int    down_arrow        =    0x50;
  89. int    left_arrow        =    0x4b;
  90. int    right_arrow        =    0x4d;
  91. int    escaped_arrows    =    1;            /* cursor keys are preceded by 0 */
  92. int    escape_char        =    0;
  93.  
  94. /* an 'A' on row r, column c  has lower left corner on raster 
  95.                 r*char_height + y_offset 
  96.     at pixel
  97.                 c*char_width + x_offset            */
  98.  
  99.  
  100. struct PRIM_ATTR prim_attr=
  101.     {8,     /* # colors                          */
  102.     1,      /* # intensities                     */
  103.     0,      /* nonzero if supported in hardware  */
  104.     11,     /* # linestyles in hardware          */
  105.     0,      /* # linestyles in software          */
  106.     1,      /* # linewidths                      */
  107.     0,      /* nonzero if supported in hardware  */
  108.     1,      /* minimum linewidth                 */
  109.     1,      /* maximum linewidth                 */
  110.     8,      /* # pens in hardware                */
  111.     0,      /* # pens in software                */
  112.     8,      /* # fonts                           */
  113.     9,      /* # character sizes                 */
  114.     1,      /* nonzero if supported in hardware  */
  115.     14,     /* minimum character height (pixels) */
  116.     224,    /* maximum character height (pixels) */
  117.     6,      /* # markers in hardware             */
  118.     0,      /* # markers in software             */
  119.     0       /* # pick IDs in hardware            */
  120.     };
  121.  
  122.  
  123. static draw();
  124. static erase();
  125. static text();
  126. static character();
  127. char *getenv();
  128.  
  129. static font=2;
  130. static int plotter_type;
  131. FILE *plot_file;
  132. static file_open = 0;
  133. static int style_code=1;
  134. static int color_code=0;
  135. static char styles[]=" 0123456789:";
  136.  
  137. static set_style(style) int style;
  138. {    if(style<1) style=1;
  139.     else if(style>11) style=11;
  140.     if(style_code==style) return;
  141.     style_code=style;
  142.     fprintf(plot_file,"L%c ",styles[style_code]);
  143. }
  144.  
  145. set_color(color) int color;
  146. {    if(color<0) color=0;
  147.     else if(color>7) color=7;
  148.     if(color_code==color+1) return;
  149.     color_code=color+1;
  150.     fprintf(plot_file,"P%d ",color_code);
  151. }
  152.  
  153. /*    If no color has been set, use default (1st pen) */
  154. static get_pen()
  155. {    if(color_code==0) set_color(0);
  156. }    
  157.  
  158. set_intensity(intensity) double intensity; {}
  159. set_background_color(color) int color; {}
  160. set_background_intensity(intensity) double intensity; {}
  161.  
  162. inquire_color() {return (color_code-1);}
  163. double inquire_intensity() {return 1.;}
  164.  
  165. /*    draw - draw a straight line     */
  166.  
  167. static cx=0,cy=0,down=0;
  168. static int draw(x1,y1,x2,y2) int x1,y1,x2,y2;
  169. {    int t,d1,d2;
  170.     get_pen();
  171.     y1= pixels_high-1-y1; y2= pixels_high-1-y2;
  172.     d1=maximum(abs(cx-x1),abs(cy-y1));
  173.     d2=maximum(abs(cx-x2),abs(cy-y2));
  174. #ifdef DEBUG
  175.     printf("\nat (%d,%d)  drawing (%d,%d)(%d away) to (%d,%d)(%d away)",
  176.      cx,cy,x1,y1,d1,x2,y2,d2);
  177. #endif
  178.     if(d2<d1 && style_code==1)
  179.         {t=x1; x1=x2; x2=t; t=y1; y1=y2; y2=t; t=d1; d1=d2; d2=t;
  180. #ifdef DEBUG
  181.         puts("swapping");
  182. #endif
  183.         }
  184. #ifdef DEBUG
  185.     putchar('\n');
  186. #endif
  187.     if(d1)
  188.         {if(down) fprintf(plot_file,"U ");
  189.         fprintf(plot_file,"%d,%d D ",x1,y1); down=1;
  190.         }
  191.     else if (!down) {fprintf(plot_file,"D "); down=1;}
  192.     fprintf(plot_file,"%d,%d ",x2,y2);
  193.     cx=x2; cy=y2;
  194. }
  195.  
  196. /*    gotoxy - move pen to new position (used before text display) */
  197.  
  198. gotoxy(x,y) int x,y;
  199. {    y= pixels_high-1-y;
  200.     if (x<0) x=0; else if (x>=pixels_wide) x=pixels_wide-1;
  201.     if (y<0) y=0; else if (y>=pixels_high) y=pixels_high-1;
  202.     if(x==cx && y==cy) return;
  203.     if(down) {fprintf(plot_file,"U "); down=0;}
  204.     fprintf(plot_file,"%d,%d ",x,y);
  205.     cx=x; cy=y;
  206. }
  207.  
  208. static nil() {}
  209.  
  210. /* exported function pointers */
  211. int (*draw_line)()    =    draw;
  212. int (*erase_line)()    =    nil;
  213. int (*draw_text)()    =    text;
  214. int (*draw_char)()    =    character;
  215. int (*flip_line)()    =    draw;
  216.  
  217. /*        init - initialize the graphics system    */
  218. init_graphics()
  219. {    int d1,d2,c,i,vel;
  220.     double w,h,left,bottom,hmax,wmax,xx,yy;
  221.     char buf[BUFSIZE],inbuf[BUFSIZE], *setup_string, *s;
  222.     static char *plotter_name = NULL;
  223.  
  224.     static int offset_ask = 1,
  225.         size_ask = 1,
  226.         plotter_ask = 1,
  227.         velocity_ask = 1,
  228.         file_ask = 0;
  229.     static double offset[2] = {BMARGIN, RMARGIN};
  230.     static double velocity = {8.};
  231.     static double size[2] = {11. - BMARGIN - TMARGIN, 8.5 - LMARGIN - RMARGIN};
  232.     static char *port_name = NULL;
  233.  
  234.  
  235.     static PARAM parmv[] = {
  236.                 {'o', REAL, &offset_ask, offset, 2},
  237.                 {'l', REAL, &offset_ask, &offset[0]},
  238. /*                {'b', REAL, &offset_ask, &offset[1]}, */
  239.                 {'s', REAL, &size_ask, size, 2},
  240.                 {'w', REAL, &size_ask, &size[0]},
  241.                 {'h', REAL, &size_ask, &size[1]},
  242. /*                {'p', BOOLEAN, &orientation_ask, &portrait, 0}, */
  243. /*                {'l', BOOLEAN, &orientation_ask, &landscape, 0}, */
  244.                 {'f', STRING, &file_ask, &port_name, 1},
  245.                 {'n', STRING, &plotter_ask, &plotter_name, 1},
  246.                 {'v', REAL, &velocity_ask, &velocity, 1},
  247.                 {'\0'}};
  248.  
  249.     if(config_file == NULL) config_file = default_config_file;
  250.     config(config_file, NULL, parmv, buf, BUFSIZE);
  251.  
  252.     
  253.     if(version()>=0x200) 
  254.         {if(plotter_name == NULL)
  255.             {plotter_name = getenv("PLOTTER");
  256.             }
  257.         else plotter_ask = 0;
  258.         }
  259.  
  260.     while(1)
  261.         {if(plotter_ask)
  262.             {plotter_name = strcpy(buf,"DMP-29");
  263.             printf("Enter plotter name:  DMP-29 or DMP-7  (default %s): ",
  264.                 buf);
  265.             gets(inbuf);
  266.             if(inbuf[0]) strcpy(buf,inbuf);
  267.             strupr(plotter_name);
  268.             if(streq(plotter_name,"DMP-7") || streq(plotter_name, "7"))
  269.                 {plotter_type=7; break;
  270.                 }
  271.             if(streq(plotter_name,"DMP-29") || streq(plotter_name, "29"))
  272.                 {plotter_type=29; break;
  273.                 }
  274.             plotter_ask = 1;
  275.             }
  276.         }
  277.     if(plotter_type==7)
  278.         {prim_attr.hardware_linestyles=8;
  279.         prim_attr.charfont_count=1;
  280.         }
  281.  
  282.     if(port_name == NULL && version() >= 0x200)
  283.         port_name = getenv("PLOT_PORT");
  284.     if(port_name == NULL) 
  285.         {port_name = strncpy(buf, default_script_file, BUFSIZE-4);
  286.         s = strchr(port_name, '.');
  287.         if(s != NULL) *s = 0;
  288.         strcat(port_name, ".hi");
  289.         }
  290.  
  291.     if(file_ask)
  292.         {port_name = strncpy(buf, port_name, BUFSIZE);
  293.         printf("Enter output file                        (default %s): ",buf);
  294.         gets(inbuf);
  295.         if(inbuf[0]) strcpy(buf,inbuf);
  296.         }
  297.     else
  298.         printf("\noutput written to %s\n", port_name);
  299.  
  300.     unlink(port_name);                /* delete the file if it exists */
  301.     plot_file=fopen(port_name,"w");        /* this will open a file or device */
  302.     if(plot_file==NULL) {printf("can\'t open output file %s", port_name); exit();}
  303.     file_open = 1;
  304.  
  305.     setup_string = NULL;
  306.     if(version()>=0x200) setup_string = getenv("PLOT_SETUP");
  307.     if(setup_string == NULL) 
  308.         setup_string = strcpy(buf,"\n\n\n;: EC5 V8 A 0,40 O @");
  309.                              /*    Default setup string...
  310.                                  Carriage return (allows auto baud rate), 
  311.                                 plotter select, mode 1, .005" resolution,
  312.                                 8 in/sec,
  313.                                 absolute mode,
  314.                                 move .2 inches up and set origin,
  315.                                 deselect */
  316.     fixup_escapes(setup_string);
  317.  
  318.     fprintf(plot_file,"%s", setup_string);
  319.  
  320.     printf("Please...\n");
  321.     printf("    Position paper.\n");
  322.     printf("    Take tip protectors off the pens \
  323. to be used and turn them over.\n");
  324.     printf("To put origin at top left of plot surface:\n");
  325.     printf("    Press \"LOCAL\" on plotter.\n");
  326.     printf("    Press \"small chart\".\n");
  327.     printf("    Press \"REMOTE\".\n");
  328.     printf("(type <return> when finished.)\n");
  329.     getchar();
  330.  
  331.     vel=velocity;
  332.     if(velocity_ask)
  333.         {printf("\nEnter pen velocity     (power of 2, default %2d in/sec): ",
  334.                                                                         vel);
  335.         gets(buf);
  336.         if(buf[0]) sscanf(buf,"%d",&vel);
  337.         }
  338.     if(vel>0)
  339.         {for (i=16; i>vel ; i /= 2) {}
  340.         vel=i;
  341.         }
  342.     else vel=8;
  343.     fprintf(plot_file,";: V%d ",vel);
  344.                                      /* plotter select, mode 1,
  345.                                         set velocity */
  346.     xx=offset[0];
  347.     yy=offset[1];
  348.     while(1)
  349.         {if(offset_ask)
  350.             {printf(
  351.             "\nEnter x and y displacement of plot origin in inches\n"
  352.             "                               (default %4.2f and %4.2f): ",
  353.                                                             xx,yy);
  354.             }
  355.         gets(buf); if(buf[0]) sscanf(buf,"%lf %lf",&xx,&yy);
  356.         if(xx < -4. || 16. < xx)
  357.             printf("x displacement outside valid range -4...16\n");
  358.         else if(yy < -4. || 16. < yy)
  359.             printf("y displacement outside valid range -4...16\n");
  360.         else break;
  361.         offset_ask = 1;
  362.         xx = BMARGIN;
  363.         yy = 0.;
  364.         }
  365.     fprintf(plot_file, "%d,%d O ET%02x ", (int)(xx/.005), 
  366.                                                     (int)(yy/.005), EOT);
  367.                                      /* set origin,
  368.                                         end of text char */
  369.     w=size[0]; h=size[1];
  370.     while(1)
  371.         {if(size_ask)
  372.             {
  373.             printf("\nEnter width and height of plot area in inches \n");
  374.             printf("                             (default, %5.3f by %5.3f): ", w, h);
  375.             gets(buf); if(buf[0]) sscanf(buf,"%lf %lf",&w,&h);
  376.             }
  377.  
  378.         hmax = wmax = 17.;
  379.         h = floor(h*100. + .5)/100.;
  380.         w = floor(w*100. + .5)/100.;
  381.  
  382.         if(w < .1 || w > wmax)
  383.             printf("width outside valid range 0.1 to %2.3f\n", wmax);
  384.         else if(h < .1 || h > hmax)
  385.             printf("height outside valid range 0.1 to %2.3f\n", hmax);
  386.         else break;
  387.                             /* set defaults for next time */
  388.         h = 6.25;
  389.         w = 8.;
  390.         size_ask = 1;
  391.         }
  392. /*
  393.     printf("\nEnter width and height of plot area in inches \n");
  394.     printf("                                 (default %5.2f by %5.2f): ",w,h);
  395.     gets(buf); if(buf[0]) sscanf(buf,"%lf %lf",&w,&h);
  396.     if(w<.1) w=.1; else if(w>17.) w=17.;
  397.     if(h<.1) h=.1; else if(h>17.) h=17.;
  398. */
  399.     pixels_wide=w/.005;
  400.     pixels_high=h/.005;
  401.     if(pixels_wide>=pixels_high)         /* landscape style */
  402.         {best_width=1.;
  403.         best_height=(double)pixels_high/pixels_wide;
  404.         }
  405.     else                                 /* portrait style */
  406.         {best_height=1.;
  407.         best_width=(double)pixels_wide/pixels_high;
  408.         }
  409.     set_height(28,28);
  410. }
  411.  
  412. /* character sizes in units of .005 inch */
  413.      /* interpret escape sequences in setup string...
  414.                          "$e" -> escape char,
  415.                          "\n" -> line feed
  416.                          "\r" -> carriage return
  417.                          "\t" -> tab
  418.                          "\c" -> c (escape an otherwise special character) */
  419. fixup_escapes(s) char *s;
  420. {    char *t;
  421.     for (t=s; *s; s++)
  422.         {if(*s=='$' && s[1]=='e') {*t++=0x1b; s++;}
  423.         else if(*s=='\\' && s[1]=='n') {*t++='\n'; s++;}
  424.         else if(*s=='\\' && s[1]=='t') {*t++='\t'; s++;}
  425.         else if(*s=='\\' && s[1]=='r') {*t++='\r'; s++;}
  426.         else if(*s=='\\') {*t++=s[1]; s++;}
  427.         else *t++=*s;
  428.         }
  429.     *t=0;
  430. }
  431.  
  432. int size[9]={14, 21, 28, 42, 56, 84, 112, 168, 224};
  433. char *size_code[9]={"1 ","1+","2 ","2+","3 ","3+","4 ","4+","5 "};
  434. static text(s) char *s;
  435. {    char *t,c;
  436.     get_pen();
  437.     t=s;
  438.     while(*t)
  439.         {c= *t&127;
  440.         if(c<32 || c>126 || c==EOT) *t=' ';
  441.         t++;
  442.         }
  443.     fprintf(plot_file,"S1%s%s%c U ",size_code[font],s,EOT);
  444.     down=0;
  445. }
  446.  
  447. static character(c) char c;
  448. {    if(c<32 || c>126 || c==EOT) return;
  449.     get_pen();
  450.     fprintf(plot_file,"S1%s%c%c U ",size_code[font],c,EOT);
  451.     down=0; cx=cy=-2000;
  452. }
  453.  
  454. static set_height(width, height)
  455. int width, height;  /* height is in units of .005" */
  456. {    if(height<size[0]) height=size[0];
  457.     else if(height>size[8]) height=size[8];
  458.     font=0;
  459.     while(height > size[font+1]) font++;
  460.                     /* assert: size[font] < height <= size[font+1] */
  461.     if(height-size[font] > size[font+1]-height) font++;
  462.     char_width=char_height=size[font];
  463.     char_columns=pixels_wide/char_width;
  464.     char_rows=pixels_high/char_height;
  465.     x_offset=0; y_offset=char_height-1;
  466. }
  467.  
  468. version()    /* return MS-DOS version number. Version 2.01 returned as 0x201 */
  469. {    
  470. #ifdef __DESMET__
  471.     extern unsigned _rax;
  472.     _rax=0x3000;
  473.     _doint(0x21);
  474.     return ( (_rax&0xff)<<8 | (_rax&0xff00)>>8 );
  475. #else
  476. #include <dos.h>
  477.     return ( (_version&0xff)<<8 | (_version&0xff00)>>8 );
  478. #endif
  479. }
  480.  
  481. #ifdef __DESMET__
  482. /*    search environment for given string */
  483.  
  484. getenv(target) char *target;
  485. {    char buf[256],*s,t[25],*env, *malloc();
  486.     int nt,offset;
  487.  
  488.     s=t;
  489.     while(*target) *s++=toupper(*target++);
  490.     *s++= '='; *s=0;
  491.     nt = strlen(t);
  492.     offset=0;
  493.     _lmove(2,44,_showcs()-0x10,&env,_showds());
  494.     while(1)
  495.         {_lmove(256,offset,env,buf,_showds());
  496.         s=buf;
  497.         if(*s)
  498.             {/* printf("examining entry: %s \n",s); getchar(); */
  499.             if (strncmp(t,s,nt)==0) 
  500.                 {env = malloc(strlen(s+nt)+1);
  501.                 if(env == NULL) return NULL;
  502.                 return strcpy(env, s+nt);
  503.                 }
  504.             }
  505.         else return NULL;
  506.         offset+=strlen(buf)+1;
  507.         }
  508. }
  509. #endif /* DESMET */
  510.  
  511. /*        finish - close down the graphics system     */
  512.  
  513. finish_graphics()
  514. {    if(file_open)
  515.         {fprintf(plot_file,"P0@");
  516.         fclose(plot_file);
  517.         file_open = 0;
  518.         puts("Please put caps back on pens.");
  519.         }
  520. }
  521.  
  522. clear_graphics()
  523. {    fprintf(plot_file,"H"); down=0;
  524.     puts("please replace paper (press <return> when finished)");
  525.     getchar();
  526. }
  527.  
  528.  
  529. /*    pointers to optional functions (NULL if not implemented)    */
  530.  
  531. int    (*new_linestyle)()=set_style;    /* (*new_linestyle)(style) int style; */
  532. int    (*new_linewidth)()=0;            /* (*new_linewidth)(width) int width; */
  533. int    (*new_charsize)()=set_height;    /* (*new_charsize)(w,h) int w,h; */
  534. int    (*draw_marker)()=0;    /* (*draw_marker)(n) int n; */
  535.  
  536. #ifdef MAIN
  537.  
  538. main()
  539. {    char buf[100];
  540.     printf("Interface %s for the %s\n",interface_version,machine);
  541.     init_graphics();
  542.     printf("screen width %d pixels\nheight %d pixels\n",
  543.         pixels_wide,pixels_high);
  544.     printf("height:width ratio %f:%f\n",best_height,best_width);
  545.     printf("%d colors\n",max_color+1);
  546.     printf("primitive attributes...\n");
  547.     printf("color_count=               %d \n",prim_attr.color_count);
  548.     printf("intensity_count=           %d \n",prim_attr.intensity_count);
  549.     printf("intensities_in_hardware=   %d \n",prim_attr.intensities_in_hardware);
  550.     printf("hardware_linestyles=       %d \n",prim_attr.hardware_linestyles);
  551.     printf("software_linestyles=       %d \n",prim_attr.software_linestyles);
  552.     printf("linewidth_count=           %d \n",prim_attr.linewidth_count);
  553.     printf("linewidths_in_hardware=    %d \n",prim_attr.linewidths_in_hardware);
  554.     printf("linewidth_minimum=         %d \n",prim_attr.linewidth_minimum);
  555.     printf("linewidth_maximum=         %d \n",prim_attr.linewidth_maximum);
  556.     printf("hardware_pens=             %d \n",prim_attr.hardware_pens);
  557.     printf("software_pens=             %d \n",prim_attr.software_pens);
  558.     printf("charfont_count=            %d \n",prim_attr.charfont_count);
  559.     printf("charsize_count=            %d \n",prim_attr.charsize_count);
  560.     printf("charsize_in_hardware=      %d \n",prim_attr.charsize_in_hardware);
  561.     printf("charsize_minimum=          %d \n",prim_attr.charsize_minimum);
  562.     printf("charsize_maximum=          %d \n",prim_attr.charsize_maximum);
  563.     printf("hardware_markers=          %d \n",prim_attr.hardware_markers);
  564.     printf("software_markers=          %d \n",prim_attr.software_markers);
  565.     printf("pick_id_count=             %d \n",prim_attr.pick_id_count);
  566.     (*draw_line)(2,4,200,-400);
  567.     (*draw_line)(20,40,100,-200);
  568.     (*erase_line)(2,4,200,-400);
  569.     (*draw_line)(10,30,100,300);
  570.     (*draw_line)(10,40,500,890);
  571.     (*draw_line)(10,40,500,32);
  572.     (*draw_line)(10,1000,78,8900);
  573.     gotoxy(10,-20);
  574.     (*draw_text)("hello\nDolly");
  575.     (*draw_char)('A');
  576.     finish_graphics();
  577. }
  578.  
  579. #endif
  580.  
  581. maximum(a,b) int a,b;
  582. {    if (a>b) return a;
  583.     return b;
  584. }
  585.  
  586.