home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / gle.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  6KB  |  233 lines

  1. #include "all.h"
  2. #include <math.h>
  3. #ifdef __TURBOC__
  4. #include "conio.h"
  5. #include "bios.h"
  6. #endif
  7.  
  8. int gle_debug;
  9. int dev_eps=0;
  10. int control_d = !0;
  11. int MAX_VECTOR=500;
  12. int dev_fill,dev_font; /* do real filling for d_dvi.c, and use texcmr font */
  13. extern int trace_on;
  14. int init_memory(void);
  15. int text_expand(int n);
  16. int g_get_type(char *s);
  17. int gle_redraw(void);
  18. int scr_init(void);
  19. int scr_end(void);
  20. #define true (!false)
  21. #define false 0
  22. int noscreenio=true;
  23. int BLACKANDWHITE=(false);
  24. #define dbg if (gle_debug>0)
  25. #ifdef __TURBOC__
  26.     extern unsigned _stklen=45000;
  27. #endif
  28.  
  29. typedef char (*TEXT)[];
  30. int int_edt(char *fname);
  31. int scrinsert(int y);
  32. int scrdeleteline(int y);
  33. int text_eol(void);
  34. int text_delete(void);
  35. int text_undelete(void);
  36. int text_deleteline(void);
  37. int text_left(void);
  38. int text_right(void);
  39. int text_up(void);
  40. int text_down(void);
  41. int text_return(void);
  42. int text_refresh();
  43. int text_putstr(char *s);
  44. int text_setwindow();
  45. int text_move(int x,int y);
  46. int scr_tab(char *s, int x);
  47. int scr_negtab(char *s, int x, int *fpos, int *scrx);
  48. int fner(char *s);
  49. int fner_clear(void);
  50. int text_setwindow(void);
  51. int text_refresh(void);
  52. int text_main(void);
  53. int text_inkey(void);
  54. int text_scroll(void);
  55. int text_scroll_up(void);
  56. int text_scroll_down(void);
  57. int text_select(void);
  58. int text_cut(void);
  59. int text_paste(void);
  60. int restofline(int y,int x);
  61. int normal_key(int c);
  62. int setoutfile(char *s);
  63. int lineset(int i,char *ss);
  64. int lineinsert(int y, char *ss);
  65. int textinsert(int y);
  66. char *sline(int i);
  67. int text_load(char *f);
  68. int print_out(void);
  69. char *line(int i);
  70. int ncpy(char *d, char *s, int n);
  71. /*------------ GLOBAL VARIABLES --------------*/
  72. char input_file[50];
  73. char *(*gtxt)[];   /* gtxt is a pointer to an array of poiter to char */
  74. int ngtxt=0;
  75. char gleroot[60];
  76. char glearg0[66];
  77. int gotfile;
  78. int hpgl_size;
  79. /*---------------------------------------------------------------------------*/
  80. #ifdef unix
  81. #include "glepath.h"
  82. #endif
  83. main(int argc, char **argv)
  84. {
  85. char dtype[60];
  86. char fname[60],*ss;
  87. static int i,ask_debug,spawn_print,call_menu,drawit;
  88.     strcpy(fname,"test.gle");
  89.     strcpy(glearg0,argv[0]);
  90.     strcpy(gleroot,argv[0]);
  91.     init_memory(); /* saves some memory for emergencies */
  92. #ifdef VMS
  93.     if (strcmp(strupr(getsymbol("GLE_NOCONTROLD")),"TRUE")==0) {
  94.         control_d = false;
  95.     }
  96. #endif
  97. #ifdef unix
  98.     dtype[0] = 0;
  99.     ss = getenv("GLE_TOP");
  100.     if (ss==NULL) ss = GLEPATH;
  101.     strcpy(gleroot,ss);
  102.     control_d = false;
  103. #endif
  104. #ifdef __TURBOC__
  105.     ss = strchr(gleroot,'\\');
  106.     if (ss==NULL) gle_abort("Unable to locate files AGRV[0] wrong");
  107.     for (;strchr(ss+1,'\\')!=NULL;) ss = strchr(ss+1,'\\');
  108.     *(ss+1) = 0;
  109.     if (getenv("GLE_NOCONTROLD")!=NULL) control_d = false;
  110. #endif
  111. #ifdef VAXC
  112.     if (strcmp(getsymbol("GLE_NOCONTROLD"),"TRUE")==0) control_d = false;
  113. #endif
  114.     hpgl_size = 3;
  115.     for (i=1;i<argc;i++) {
  116.         strcpy(dtype,argv[i]);
  117.         strupr( argv[i] );
  118.         if (strcmp( argv[i] , "/TRACE")==0) trace_on = true;
  119.         else if (strcmp( argv[i] , "/DEBUG")==0) ask_debug = true;
  120.         else if (strcmp( argv[i] , "/PRINT")==0) spawn_print = true;
  121.         else if (strncmp( argv[i] , "/DEV", 4)==0) spawn_print = false;
  122.         else if (strcmp( argv[i] , "/NOD")==0) control_d = false;
  123.         else if (strcmp( argv[i] , "/ADDD")==0) control_d = true;
  124.         else if (strcmp( argv[i] , "/A0")==0) hpgl_size = 0;
  125.         else if (strcmp( argv[i] , "/A1")==0) hpgl_size = 1;
  126.         else if (strcmp( argv[i] , "/A2")==0) hpgl_size = 2;
  127.         else if (strcmp( argv[i] , "/A3")==0) hpgl_size = 3;
  128.         else if (strcmp( argv[i] , "/A4")==0) hpgl_size = 4;
  129.         else if (strcmp( argv[i] , "/MENU")==0) call_menu = true;
  130.         else if (strcmp( argv[i] , "/EPS")==0) dev_eps = true;
  131.         else if (strcmp( argv[i] , "/FILL")==0) dev_fill = true;
  132.         else if (strcmp( argv[i] , "/FONT")==0) dev_font = true;
  133.         else if (strcmp( argv[i] , "/NOMAXPATH")==0) MAX_VECTOR = 999999;
  134.         else if (strcmp( argv[i] , "/COLOR")==0) BLACKANDWHITE = false;
  135.         else if (strcmp( argv[i] , "/NOCOLOR")==0) BLACKANDWHITE = false;
  136.         else if (strncmp( argv[i] , "/OUT", 4)==0) setoutfile(argv[i]);
  137.         else if (strncmp( argv[i] , "/DRA", 4)==0) drawit = true;
  138.         else if (!gotfile && (isalnum(*argv[i]) || (*argv[i] == '['))) {strcpy(fname, dtype); gotfile=true;}
  139.         else printf("Unrecognised qualifier {%s} \n",argv[i]);
  140.     }
  141. /*    if (argc>1) strcpy(fname,*(++argv)); else strcpy(fname,"test.gle");*/
  142.     g_get_type(dtype);
  143. /* works here */
  144.     if (strstr(dtype,"HARDCOPY")!=NULL  && !call_menu) {
  145.         if (!gotfile) {
  146. try_again:        gprint("Enter name of GLE file ? ");
  147.             gets(fname);
  148.             ss = strchr(fname,'\n');
  149.             if (ss!=NULL) *ss = 0;
  150.             if (strcmp(fname,"")==0) goto try_again;
  151.         }
  152.     }
  153.  
  154.     if (strchr(fname,'.')==NULL) strcat(fname,".gle");
  155. /* works*/
  156.     if (strstr(dtype,"HARDCOPY")==NULL  || call_menu) {
  157.         noscreenio = false;
  158.         scr_init();
  159.     }
  160.     strcpy(input_file,fname);
  161.     text_expand(500); /* Initially allocate 500 lines of text */
  162.  
  163.     if (strstr(dtype,"HARDCOPY")!=NULL  && !call_menu) {
  164.         text_load(fname);
  165.         if (ask_debug) {
  166.         printf("Debug options 16=do_pcode, 8=pass 4=polish, 2=eval ");
  167.         printf("Debug ");scanf("%d",&gle_debug);
  168.         printf("Trace "); scanf("%d",&trace_on);
  169.         }
  170.         gle_redraw();
  171.     } else {
  172.         noscreenio = false;
  173.         if (coreleft()<120000L) {
  174.  printf("\n\nThere is not enough memory for GLE to run properly, follow these guidelines\n");
  175.  printf("to free up more memory.\n");
  176.  printf("    1) Don't run GLE from inside editors/file utilities.\n");
  177.  printf("    2) Don't run GLE at the same time as disk servers like:\n");
  178.  printf("        NOVELL, PCSA, VDISK, RAF etc...\n");
  179.  printf("    3) Remove any extra's from CONFIG.SYS and AUTOEXEC.BAT\n");
  180.  printf("        (after taking copies of them)\n\n");
  181.  printf("    (GLE will attempt to continue by not using any complex fonts)\n");
  182.  printf("Press any key to continue");
  183.             font_simple();
  184.             if (!drawit) text_inkey();
  185.         }
  186.         if (gotfile) text_load(fname);
  187.         if (drawit) gle_redraw();
  188.         else int_edt(fname);
  189.     }
  190.     if (!noscreenio) scr_end();
  191. /*     if (spawn_print) {
  192.         print_out();
  193.     } */
  194. #ifdef VMS
  195.     return 1;
  196. #else
  197.     return 0;
  198. #endif
  199. }
  200. #ifdef unix
  201. print_out(){}
  202. #endif
  203. #ifdef __TURBOC__
  204. print_out()
  205. {}
  206. #else
  207. #ifdef VMS
  208. #include <descrip.h>
  209. /* #include <lib$routines.h> */
  210. print_out()
  211. {
  212.     static $DESCRIPTOR(cmd_desc
  213.       ,"print out.ps /que=laser/notify/noburst/noflag");
  214.  
  215.     printf("$ %s \n",cmd_desc.dsc$a_pointer);
  216.     LIB$DO_COMMAND(&cmd_desc);
  217. }
  218. #endif
  219. #endif
  220. char output_file[80];
  221. setoutfile(char *q)
  222. {
  223.     char *s;
  224.     s = strchr(q,'=');
  225.     if (s==NULL) return;
  226.     strcpy(output_file,s+1);
  227.     strlwr(output_file);
  228. }
  229.  
  230.  
  231.  
  232.  
  233.