home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1987 / 09 / enviro / mc.c < prev    next >
Encoding:
Text File  |  1980-01-12  |  25.0 KB  |  832 lines

  1. /****************************************************************************/
  2. /**                    C System Environment                                **/
  3. /**           Turbo-Pascal aehnliche Benutzeroberflaeche                   **/
  4. /**        (C) 1987 Martin Schloeter & PASCAL International                **/
  5. /****************************************************************************/
  6.  
  7. int _okbigbuf = 0; /* Platz fuer Tochterprozess freihalten !!! */
  8.  
  9. #include <stdio.h>
  10. #include <ctype.h> /* Beinhaltet die Typpruefungsfunktionen (z.B. isascii) */
  11. #include <my-h.h>
  12. #define ZORLAND 1  /* I/O soll ueber Zorland-eigene Routinen laufen        */
  13. #include <MC.H>    /* Vereinbarung der systemabhaengigen I/O-Routinen      */
  14.  
  15. #define MAXL1 24              /* Anzahl Bildschirmzeilen minus 1            */
  16. #define MAXOPTIONS  13        /* Anzahl Optionen                            */
  17. #define OPTIONL 3             /* Laenge der Optionsstring                   */
  18. #define MEMMODNR 10           /* Anzahl Speichermodelle                     */
  19. #define MEMMODL 4             /* Laenge der Speichermodell-Optionsstrings   */
  20. #define MAXINCLUDEPATH 10     /* Anzahl der bei Aufruf angebbaren Suchpfade */
  21. #define MAXARGUMENTE (MAXOPTIONS+MAXINCLUDEPATH+10)
  22.         /* ...+5 wuerde auch reichen, so hat man aber fuer andere Compiler, */
  23.         /* die vielleicht mehr Standardoptionen haben, Spielraum.           */
  24.  
  25. /* Defaulteinstellungen fuer Filenamen und PATHes. */
  26. /* Werden in init() ggf geaendert.                  */
  27. char editorname[81] = "B:MY-ED";
  28. char compiler_name[81] = "A:ZC";
  29. string logged_drive = "B:";
  30. char path[41] = "\\";
  31. char workfile[81] = "";
  32. char mainfile[81] = "";
  33. char out_file[81] = "";
  34. int mem_mod_nr = 0;        /* Nummer des zu verwendenden Memory-Modells. */
  35. int int_only = FALSE;
  36. int lst_exist = FALSE;     /* Soll Listfile erzeugt worden ?             */
  37. int run_possible  = FALSE; /* Schon compiliert ?                         */
  38. int com = FALSE;           /* COM- oder EXE-File erzeugen ?              */
  39. char macro[127] = "";      /* Bei Compileraufruf zu uebergebendes Macro. */
  40.  
  41. /* Felder werden in init() initialisiert */
  42. int option_flag[MAXOPTIONS];            /* Option n verwenden ?        */
  43. char option_str[MAXOPTIONS][OPTIONL+1]; /* String zu Option n.         */
  44. char mem_mod_str[MEMMODNR][MEMMODL+1];  /* Strings zu Memory-Modellen. */
  45. int include_path_flag[MAXINCLUDEPATH];  /* Existiert Includepath n ?   */
  46. char include_path[MAXINCLUDEPATH][127]; /* Tabelle der Include-Pathes  */
  47.                                         /* fuer Compileraufruf.        */
  48.  
  49. /***** FUNCTION-PROTOTYPING der benutzerdefinierten Funktionen von MC.C *****/
  50. void get_mainfile(void), get_path(string), show_copyright(void);
  51. void get_workfile(void), get_drive(void), edit(void), get_off(void);
  52. void compile(void), ed_lst(void), run(void), file_manager(void);
  53. void init(void), options(void), get_mask(string), exit(int);
  54. void my_getstr(int,string), fit_files(void), missing_file(string);
  55. void dir(void), erase(void), copy(void), my_rename(void);
  56. int mark_print(string,int), ja_nein(string);
  57. char hauptmenu(void), *strupr(string), *index(string,char);
  58.  
  59. main()
  60.  
  61. begin
  62.   char wahl;
  63.  
  64.     init_device();
  65.     init();
  66.  
  67.     repeat 
  68.       wahl = hauptmenu();
  69.       switch (wahl) begin
  70.         case 'l':
  71.         case 'L': get_drive();
  72.                   break;
  73.         case 'a': 
  74.         case 'A': get_path(path);
  75.                   break; 
  76.         case 'w':
  77.         case 'W': get_workfile();
  78.                   break;
  79.         case 'm':
  80.         case 'M': get_mainfile();
  81.                   break;
  82.         case 'e':
  83.         case 'E': edit();
  84.                   break;
  85.         case 's':
  86.         case 'S': ed_lst();
  87.                   break;
  88.         case 'c':
  89.         case 'C': compile();
  90.                   break;
  91.         case 'r':
  92.         case 'R': run();
  93.                   break;  
  94.         case 'f':
  95.         case 'F': file_manager();
  96.                   break; 
  97.         case 'o':
  98.         case 'O': options();
  99.                   break;
  100.         case 'q':
  101.         case 'Q': get_off(); 
  102.                   break;
  103.       end
  104.     until (FALSE); /* Endlosschleife, Ausgang in get_off */ 
  105. end
  106.  
  107.  
  108. /* Hier werden die Initialisierungen der Felder der Compileroptionen        */
  109. /* vorgenommen, und ggf. Defaultwerte fuer Filenamen PATHes und Laufwerke   */
  110. /* neu eingelesen und geaendert.                                            */
  111. void init(void)
  112.  
  113. begin
  114.   FILE *f;
  115.   int i;
  116.  
  117.   /* Einlesen der Dateien mit den Optionen */
  118.   f = fopen("defaults.dfl","r");
  119.   if (f != NULL) begin
  120.     fscanf(f,"%80s",editorname);
  121.     fscanf(f,"%80s",compiler_name);
  122.     fscanf(f,"%2s",logged_drive);
  123.     fscanf(f,"%40s",path)
  124.   end
  125.   else
  126.     missing_file("DEFAULTS.DFL");
  127.   fclose(f);
  128.  
  129.   /* Compiler-Optionen einlesen */
  130.   f = fopen("coptions.opt","r");
  131.   if (f != NULL) begin
  132.     int i;
  133.  
  134.     for (i = 0; i < MAXOPTIONS; i++)
  135.       fscanf(f,"%s",option_str[i]);
  136.   end
  137.   else
  138.     missing_file("COPTIONS.OPT");
  139.   fclose(f);
  140.  
  141.   /* Speichermodelle einlesen */
  142.   f = fopen("memmods.mmd","r");
  143.   if (f != NULL) begin
  144.     int i;
  145.  
  146.     for (i = 0; i < MEMMODNR; i++)
  147.       fscanf(f,"%s",mem_mod_str[i]);
  148.   end
  149.   else
  150.     missing_file("MEMMODS.MMD");
  151.   fclose(f);
  152.  
  153.   /* Initialisierung der Felder */
  154.   for(i = 0; i < MAXOPTIONS; i++)
  155.     option_flag[i] = FALSE;
  156.   for(i = 0; i < MAXINCLUDEPATH; i++) begin
  157.     strcpy(include_path[i],"");
  158.     include_path_flag[i] = FALSE
  159.   end
  160. end
  161.  
  162.  
  163. void show_copyright(void)
  164.  
  165. begin
  166.  
  167.     inverse();
  168.     setyx(0,0);
  169.     printf(  "============================================================");
  170.     printf("\n*                C - System - Environment                  *");
  171.     printf("\n*   (C) 1987 by Martin Schloeter & PASCAL International    *");
  172.     printf("\n============================================================");
  173.     normal()
  174. end
  175.  
  176.  
  177. char hauptmenu(void)
  178.  
  179. begin
  180.   string valid_keys = "lLaAmMwWeEsScCrRdFfQqoO";
  181.   char wahl;
  182.  
  183.   cls();
  184.   show_copyright();
  185.   setyx(6,4); mark_print("Logged drive: ",1); printf("%s",logged_drive);
  186.   setyx(7,4); mark_print("Active directory: ",1); printf("%s",path);
  187.   setyx(9,4); mark_print("Workfile: ",1); printf("%s",workfile);
  188.   setyx(10,4);  mark_print("Mainfile: ",1); printf("%s",mainfile);
  189.   setyx(15,4); mark_print("Edit",1);
  190.   setyx(15,14); mark_print("LST-file",2);
  191.   setyx(15,24); mark_print("Compile",1);
  192.   setyx(15,34); mark_print("Run",1);
  193.   setyx(17,4); mark_print("Files",1);
  194.   setyx(17,14); mark_print("Quit",1);
  195.   setyx(17,24); mark_print("compiler Options",10);
  196.   setyx(18,1); update(); /* Falls Systemmeldungen durchkommen, */
  197.                          /* scrollen verhindern !              */
  198.   repeat
  199.     wahl = getch(); /* Keyboard ohne Echo lesen */
  200.   until(member(wahl,valid_keys));
  201.   return(wahl)
  202. end;
  203.  
  204.  
  205. void get_drive(void)
  206.  
  207. begin
  208.   char wahl;
  209.  
  210.   setyx(MAXL1,0);
  211.   inverse(); printf("Drive:"); setyx(MAXL1,7); update(); wahl = getch();
  212.   if (member(wahl,"aAbBcCdD")) /* Wer mehr Laufwerke hat --> anpassen !!! */
  213.     logged_drive[0] = (char)toupper(wahl);
  214.   normal();
  215. end;
  216.  
  217.  
  218. void get_workfile(void)
  219.  
  220. begin
  221.   string trim_filestr(string);
  222.   char filename[15];
  223.  
  224.   setyx(MAXL1-1,0); inverse();
  225.   printf("WORKFILE:"); setyx(MAXL1-1,10); normal(); update();
  226.   filename[0] = '\0'; my_getstr(14,filename);
  227.   strcpy(workfile,trim_filestr(filename));
  228. end;
  229.  
  230.  
  231. void get_mainfile(void)
  232.  
  233. begin
  234.   string trim_filestr(string);
  235.   char filename[15];
  236.  
  237.   setyx(MAXL1-1,0); inverse();
  238.   printf("MAINFILE:"); setyx(MAXL1-1,10); normal(); update();
  239.   filename[0] = '\0'; my_getstr(14,filename);
  240.   strcpy(mainfile,trim_filestr(filename));
  241. end;
  242.  
  243.  
  244. void get_path(Str)
  245. string Str;
  246.  
  247. begin
  248.   char inp[66];
  249.  
  250.   setyx(MAXL1-1,0); inverse();
  251.   printf("PATH:"); setyx(MAXL1-1,6); normal(); update();
  252.   my_getstr(65,inp);
  253.   strcpy(Str,strupr(inp));
  254. end;
  255.  
  256.  
  257. void compile(void)
  258.  
  259. begin
  260.   char *argumente[MAXARGUMENTE];
  261.   int i, j, res;
  262.  
  263.   fit_files();
  264.   cls();
  265.   if (not((*mainfile == '\0') || (*mainfile == ' '))) begin
  266.      /* nicht leerer String */
  267.      for(i = 0; i < MAXARGUMENTE; i++)
  268.        argumente[i] = NULL;
  269.      argumente[0] = "dummy";
  270.      argumente[1] = mainfile;
  271.      for (i = 0, j = 2; i < MAXOPTIONS; i++) begin
  272.        switch (i) begin
  273.          case 2: if (option_flag[2]) /* Macro anhaengen */
  274.                    argumente[j++] = macro;
  275.                  break;
  276.          case 7: if (option_flag[8]) /* Outputname angeben */
  277.                    argumente[j++] = out_file;
  278.                  break;
  279.          default: if (option_flag[i])
  280.                     argumente[j++] = option_str[i];
  281.                   break;
  282.        end;
  283.      end;
  284.      run_possible = (not(option_flag[1]));
  285.      lst_exist = (option_flag[6]);
  286.      argumente[j++] = mem_mod_str[mem_mod_nr];
  287.      for(i = 0; i < MAXINCLUDEPATH; i++)
  288.        if (include_path_flag[i])
  289.          argumente[j++] = include_path[i];
  290.      argumente[j] = NULL;
  291.      res = subprozess(1,compiler_name,argumente);
  292.   end;
  293.   if (res) begin /* Fehler beim Compilieren */
  294.     run_possible = FALSE;
  295.     setyx(MAXL1,0);
  296.     if (ja_nein("\n\n Fehler beim Compilieren. Listing erzeugen ? (j/n)"))
  297.       begin
  298.         normal(); update(); printf("\n");
  299.         argumente[j++] = "-l";
  300.         argumente[j] = NULL;
  301.  
  302.         subprozess(1,compiler_name,argumente);
  303.         lst_exist = TRUE
  304.       end
  305.   end;
  306.   normal(); update();
  307. end
  308.  
  309.  
  310. void run(void)
  311.  
  312. begin
  313.   char *argumente[2];
  314.  
  315.   if (not(run_possible))
  316.     compile();
  317.  
  318.   if (run_possible) begin
  319.     char runname[81], *zeiger;
  320.  
  321.     strcpy(runname,mainfile);
  322.     zeiger = index(runname,'.');
  323.     if (com)
  324.       strcpy(zeiger,".COM");
  325.     else
  326.       strcpy(zeiger,".EXE");
  327.     argumente[0] = "dummy";
  328.     argumente[1] = NULL;
  329.     subprozess(1,runname,argumente);
  330.   end
  331. end
  332.  
  333.  
  334. void edit(void)
  335.  
  336. begin
  337.   char *argumente[3];
  338.  
  339.   fit_files();
  340.   argumente[0] = "dummy";
  341.   argumente[1] = workfile;
  342.   argumente[2] = NULL;
  343.   ende_device(); /* Auf normalen Bildschirm I/O umschalten */
  344.   subprozess(1,editorname,argumente);
  345.   init_device();/* Wieder spezieller Bildschirm I/O */
  346. end;
  347.  
  348.  
  349. void ed_lst(void)
  350.  
  351. begin
  352.   char *argumente[3];
  353.  
  354.   if (lst_exist) begin
  355.     char *zeiger, errorname[81];
  356.     strcpy(errorname,mainfile);
  357.     zeiger = index(errorname,'.');
  358.     strcpy(zeiger,".LST");
  359.     argumente[0] = "dummy";
  360.     argumente[1] = errorname;
  361.     argumente[2] = NULL;
  362.     ende_device(); /* Auf normalen Bildschirm I/O umschalten */
  363.     subprozess(1,editorname,argumente);
  364.     init_device();/* Wieder spezieller Bildschirm I/O */
  365.   end
  366. end;
  367.  
  368.  
  369. void options(void)
  370.  
  371. begin
  372.   char wahl, wahl2, ein[127];
  373.   char *valid_keys = "aAcCdDeEgGiIlLmMoOrRsSuUwWxXqQ";
  374.  
  375.   repeat
  376.     cls();
  377.     inverse();
  378.     printf(  "********************************");
  379.     printf("\n*                              *");
  380.     printf("\n*       Compiler Options       *");
  381.     printf("\n*                              *");
  382.     printf("\n********************************");
  383.     normal();
  384.     setyx(6,0); mark_print("Alignment of structure-elements",1);
  385.     setyx(8,0); mark_print("Compile only",1);
  386.     setyx(8,20); mark_print("Define macro",1);
  387.     setyx(8,40); mark_print("PrEprocessor results",3);
  388.     setyx(10,0); mark_print("Generate debugging informations",1);
  389.     setyx(12,0); mark_print("Include path",1);
  390.     setyx(12,20); mark_print("List file",1);
  391.     setyx(12,40); mark_print("Memory model",1);
  392.     setyx(14,0); mark_print("Output file",1);
  393.     setyx(14,20); mark_print("ROMable code",1);
  394.     setyx(14,40); mark_print("Stack checking",1);
  395.     setyx(16,0); mark_print("sUpress predef. macros",2);
  396.     setyx(18,0); mark_print("no Warnings",4);
  397.     setyx(18,20); mark_print("no error maXimum",12);
  398.     setyx(18,40); mark_print("Quit",1);
  399.     setyx(MAXL1,79); update();  /* Cursor aus dem Weg raeumen */
  400.     repeat
  401.       wahl = getch();
  402.     until(member(wahl,valid_keys));
  403.     switch (wahl) begin
  404.       case 'a':
  405.       case 'A': setyx(MAXL1-1,0); inverse(); printf("Byte/Word (b/w) ?");
  406.                 normal();
  407.                 setyx(MAXL1-1,18); update();
  408.                 repeat
  409.                   wahl2 = getch();
  410.                 until(member(wahl2,"bBwW"));
  411.                 option_flag[0] = (member(wahl2,"bB"));
  412.                 break;
  413.       case 'c':
  414.       case 'C': setyx(MAXL1-1,0);
  415.                 option_flag[1] = ja_nein("Nur Compilieren (j/n) ?");
  416.                 break;
  417.       case 'd':
  418.       case 'D': setyx(MAXL1-1,0); inverse(); printf("Macro:");
  419.                 normal(); setyx(MAXL1-1,7); update(); my_getstr(126,ein);
  420.                 strcpy(macro,option_str[2]); strcat(macro,ein);
  421.                 option_flag[2] = (strlen(ein) != 0);
  422.                 break;
  423.       case 'e':
  424.       case 'E': setyx(MAXL1-1,0);
  425.                 option_flag[3] =
  426.                   ja_nein("Preprozessorresultate im LST-File zeigen ? (j/n)");
  427.                 break;
  428.       case 'g':
  429.       case 'G': setyx(MAXL1-1,0);
  430.                 option_flag[4] =
  431.                   ja_nein("Debugging-Informationen erzeugen (j/n) ?");
  432.                 break;
  433.       case 'i':
  434.       case 'I': setyx(MAXL1-2,0); inverse();
  435.                 printf("Include-Path Nr. (0..9) ?");
  436.                 normal(); setyx(MAXL1-2,26); update();
  437.                 repeat
  438.                   wahl2 = getch();
  439.                 until(member(wahl2,"0123456789"));
  440.                 setyx(MAXL1-1,0); inverse(); printf("PATH:"); normal();
  441.                 setyx(MAXL1-1,6); update(); my_getstr(126,ein);
  442.                 if (strlen(ein) > 0) begin
  443.                   include_path_flag[wahl2-'0'] = TRUE;
  444.                   strcpy(include_path[wahl2-'0'],option_str[5]);
  445.                   strcat(include_path[wahl2-'0'],ein)
  446.                 end;
  447.                 break;
  448.       case 'l':
  449.       case 'L': setyx(MAXL1-1,0);
  450.                 option_flag[6] = ja_nein("List-File erzeugen (j/n) ?");
  451.                 break;
  452.       case 'm':
  453.       case 'M': begin
  454.                   char wahl3;
  455.  
  456.                   repeat
  457.                     setyx(6,0); etoeos();
  458.                     setyx(8,0); mark_print("Small code & small data",1);
  459.                     setyx(8,40); mark_print("small code & large Data",20);
  460.                     setyx(10,0);
  461.                     mark_print("large Programcode & small Data",7);
  462.                     setyx(10,40); mark_print("Large code & large data",1);
  463.                     setyx(12,20); mark_print("COM-File",1);
  464.                     setyx(16,20); mark_print("only Integer-Arithmetik",6);
  465.                     setyx(20,0); mark_print("Quit",1);
  466.                     setyx(MAXL1,79); update();
  467.                     repeat
  468.                       wahl3 = getch();
  469.                     until(member(wahl3,"sSdDpPlLcCiIqQ"));
  470.                     if (not(member(wahl3,"qQ")))
  471.                       run_possible = FALSE;
  472.                     begin
  473.                       char *lvalid_key = "sdplc";
  474.                       char *uvalid_key = "SDPLC";
  475.                       if (member(wahl3,lvalid_key))
  476.                         mem_mod_nr =
  477.                           (int)(index(lvalid_key,wahl3)-lvalid_key);
  478.                       if (member(wahl3,uvalid_key))
  479.                         mem_mod_nr =
  480.                           (int)(index(uvalid_key,wahl3)-uvalid_key);
  481.                     end;
  482.                     if (member(wahl3,"cC"))
  483.                       com = TRUE;
  484.                     if ((not(member(wahl3,"cCiIqQ"))) && com)
  485.                       com = FALSE;
  486.                     if (member(wahl3,"iI")) begin
  487.                       setyx(MAXL1,0);
  488.                       int_only = ja_nein("Nur Integerarithmetik (j/n) ?");
  489.                     end;
  490.                     if ((int_only) && (mem_mod_nr < MEMMODNR / 2))
  491.                       mem_mod_nr += MEMMODNR / 2;
  492.                     if ((not(int_only)) && (mem_mod_nr >= MEMMODNR / 2))
  493.                       mem_mod_nr -= MEMMODNR / 2;
  494.                   until(member(wahl3,"qQ"));
  495.                   break;
  496.                 end;
  497.                 break;
  498.       case 'o':
  499.       case 'O': setyx(MAXL1-1,0); inverse(); printf("Output-File:");
  500.                 normal(); setyx(MAXL1-1,13); update(); my_getstr(65,ein);
  501.                 strcpy(out_file,option_str[7]); strcat(out_file,ein);
  502.                 option_flag[7] = (strlen(ein) != 0);
  503.                 break;
  504.       case 'r':
  505.       case 'R': setyx(MAXL1-1,0);
  506.                 option_flag[8] = ja_nein("ROM-faehigen Code (j/n) ?");
  507.                 break;
  508.       case 's':
  509.       case 'S': setyx(MAXL1-1,0);
  510.                 option_flag[9] = ja_nein("Stack Ueberpruefung (j/n) ?");
  511.                 break;
  512.       case 'u':
  513.       case 'U': setyx(MAXL1-1,0);
  514.                 option_flag[10] =
  515.                   ja_nein("Vordefinierte Macros unterdruecken (j/n) ?");
  516.                 break;
  517.       case 'w':
  518.       case 'W': setyx(MAXL1-1,0);
  519.                 option_flag[11] = ja_nein("Keine Warnings (j/n) ?");
  520.                 break;
  521.       case 'x':
  522.       case 'X': setyx(MAXL1-1,0);
  523.                 option_flag[12] = ja_nein("Kein Fehlermaximum (j/n) ?");
  524.                 break;
  525.  
  526.     end
  527.   until(member(wahl,"qQ"))
  528. end
  529.  
  530.  
  531. void file_manager(void)
  532.  
  533. begin
  534.   char wahl;
  535.   string valid_keys = "dDeEcCrRqQ";
  536.  
  537.   repeat
  538.     cls(); inverse(); update();
  539.     printf(  "*****************************************");
  540.     printf("\n*                                       *");
  541.     printf("\n*                  FILE                 *");
  542.     printf("\n*                                       *");
  543.     printf("\n*                 MANAGER               *");
  544.     printf("\n*                                       *");
  545.     printf("\n*****************************************");
  546.     normal();
  547.     setyx(10,4);  mark_print("Dir",1);
  548.     setyx(10,14); mark_print("Erase",1);
  549.     setyx(10,24); mark_print("Copy",1);
  550.     setyx(10,34); mark_print("Rename",1);
  551.     setyx(12,4); mark_print("Quit",1);
  552.     setyx(MAXL1,0); update();
  553.  
  554.     repeat
  555.       wahl = getch(); /* Keyboard ohne Echo lesen */
  556.     until(member(wahl,valid_keys));
  557.  
  558.     switch (wahl) begin
  559.       case 'd':
  560.       case 'D': dir();
  561.                 break;
  562.       case 'e':
  563.       case 'E': erase();
  564.                 break;
  565.       case 'c':
  566.       case 'C': copy();
  567.                 break;
  568.       case 'r':
  569.       case 'R': my_rename();
  570.                 break;
  571.     end
  572.   until(member(wahl,"qQ"))
  573. end;
  574.  
  575.  
  576. void dir(void)
  577.  
  578. begin
  579.   char mask[61], sysline[80];
  580.  
  581.   strcpy(sysline,"DIR ");
  582.   get_mask(mask); strcat(sysline,mask);
  583.   cls(); setyx(0,0); call_system(sysline);
  584.   setyx(MAXL1-1,0); wait_key()
  585. end;
  586.  
  587.  
  588. void erase(void)
  589.  
  590. begin
  591.   char mask[61], sysline[80];
  592.  
  593.   strcpy(sysline,"ERASE ");
  594.   get_mask(mask);
  595.   if (strlen(mask) != 0) begin
  596.     strcat(sysline,mask);
  597.     setyx(15,0);
  598.     call_system(sysline);
  599.     setyx(MAXL1-1,0); wait_key();
  600.   end
  601. end;
  602.  
  603.  
  604. void copy(void)
  605.  
  606. begin
  607.   char sysline[127], sourcepath[61], destinationpath[61];
  608.  
  609.   strcpy(sysline,"COPY ");
  610.   setyx(MAXL1-2,5); inverse();
  611.   printf("Sourcepath:"); normal();
  612.   setyx(MAXL1-2,17); update(); my_getstr(60,sourcepath);
  613.   if (strlen(sourcepath) > 0) begin
  614.     setyx(MAXL1-1,0); inverse();
  615.     printf("Destinationpath:"); normal();
  616.     setyx(MAXL1-1,17); update(); my_getstr(60,destinationpath);
  617.     if (strlen(destinationpath) > 0) begin
  618.       strcat(sysline,sourcepath); strcat(sysline," ");
  619.       strcat(sysline,destinationpath);
  620.       setyx(MAXL1-2,0); etoeos();
  621.       setyx(15,0); update();
  622.       system(sysline); wait_key();
  623.     end
  624.   end
  625. end
  626.  
  627.  
  628. void my_rename(void)
  629.  
  630. begin
  631.   char sysline[127], sourcepath[61], destinationpath[61];
  632.  
  633.   strcpy(sysline,"RENAME ");
  634.   setyx(MAXL1-2,5); inverse();
  635.   printf("Sourcepath:"); normal();
  636.   setyx(MAXL1-2,17); update(); my_getstr(60,sourcepath);
  637.   if (strlen(sourcepath) > 0) begin
  638.     setyx(MAXL1-1,0); inverse();
  639.     printf("Destinationpath:"); normal();
  640.     setyx(MAXL1-1,17); update(); my_getstr(60,destinationpath);
  641.     if (strlen(destinationpath) > 0) begin
  642.       strcat(sysline,sourcepath); strcat(sysline," ");
  643.       strcat(sysline,destinationpath);
  644.       setyx(MAXL1-2,0); etoeos();
  645.       setyx(15,0); update();
  646.       system(sysline); wait_key();
  647.     end
  648.   end
  649. end
  650.  
  651.  
  652. void get_mask(mask)
  653.   string mask;
  654.  
  655. begin
  656.  
  657.   setyx(MAXL1-1,0); inverse();
  658.   printf("MASK:"); normal(); setyx(MAXL1-1,6); update();
  659.   *mask = '\0'; my_getstr(60,mask);
  660.   setyx(MAXL1-1,0); etoeoln(); /* Unterste Zeilen loeschen */
  661. end;
  662.  
  663.  
  664. void get_off(void)
  665.  
  666. begin
  667.  
  668.   setyx(MAXL1,0);
  669.   if (ja_nein("Sie wollen das System verlassen ? (j/n):")) begin
  670.     cls();
  671.     ende_device();
  672.     exit(0)   /* Ende und aus ! */
  673.   end
  674. end
  675.  
  676.  
  677. int mark_print(strp,pos) /* Gibt String mit einem inversen Buchstabe an der */
  678.      string strp;        /* Stelle pos aus                                  */
  679.      int pos;
  680.  
  681. begin
  682.   char front[81],sign[2];
  683.  
  684.   if (pos > strlen(strp)) return(-1); /* Bockmist */
  685.  
  686.   strncpy(front,strp,(pos-1));
  687.   front[pos-1] = '\0'; /* String abschliessen */
  688.   printf(front);
  689.  
  690.   strp += (pos-1); /* Zeiger auf das markierte Zeichen ruecken */
  691.   strncpy(sign,strp,1);
  692.   sign[1] = '\0'; /* String abschliessen */
  693.   inverse(); printf(sign); normal(); /* Zeichen invers drucken */
  694.  
  695.   strp++; /* Nun zeigt strp auf den Rest nach dem markierten Zeichen */
  696.   printf(strp);
  697.   return(0) /* Alles OK */
  698. end
  699.  
  700.  
  701. void fit_files(void)   /* Faengt leeres Work- oder Mainfile ab */
  702.  
  703. begin
  704.   if ((*mainfile == '\0') || (*mainfile == ' ')) /* leerer String */
  705.     strcpy(mainfile,workfile);
  706.   if ((*workfile == '\0') || (*workfile == ' ')) /* leerer String */
  707.     strcpy(workfile,mainfile);
  708.   if ((*workfile == '\0') || (*workfile == ' ')) /* immer noch Leerstring */
  709.     strcpy(workfile,"WORK.C");
  710.   if ((*mainfile == '\0') || (*mainfile == ' ')) /* immer noch Leerstring */
  711.   strcpy(mainfile,"WORK.C");
  712. end
  713.  
  714.  
  715. int ja_nein(Str)
  716.     string Str;
  717.  
  718. begin
  719.   char wahl;
  720.   string valid_keys = "jJnN";
  721.  
  722.   inverse(); printf(Str); normal(); printf(" "); update();
  723.   repeat
  724.     wahl = getch()
  725.   until(member(wahl,valid_keys));
  726.   return(member(wahl,"jJ"));
  727. end
  728.  
  729.  
  730. string trim_filestr(filename)  /* Macht einen Filenamen verarbeitungsfertig */
  731.        string filename;
  732.  
  733. begin
  734.    char res[14], drive[3], name[9], ext[4];
  735.  
  736.   *res = '\0'; /* Resultat ist leer */
  737.   /* path fertigmachen */
  738.   *index(path,' ') = '\0'; /* Falls Leerzeichen in path, Rest raus */
  739.   /* Laufwerk extrahieren */
  740.   if (member(':',filename)) begin
  741.     char *zeiger;
  742.     zeiger =  index(filename,':');
  743.     strncpy(drive,--zeiger,1); /* Hoechstens 1 Characters kopieren */
  744.     drive[1] = ':';
  745.     drive[2] = '\0';
  746.     filename = zeiger + 2; /* Jetzt zeigt filename auf den Dateinamen */
  747.   end
  748.   else
  749.     strcpy(drive,logged_drive);
  750.   /* Extension extrahieren */
  751.   if (member('.',filename)) begin /* Wenn Extension vorhanden */
  752.     char *zeiger;
  753.     int i;
  754.  
  755.     zeiger =  index(filename,'.');
  756.     zeiger++;
  757.     strncpy(ext,zeiger,3); /* Hoechstens 3 Characters kopieren */
  758.     if (strlen(ext) < 3 ) /* Extension ggf. mit Blanks auffuellen */
  759.       for(i = strlen(ext); i < 3; ext[i++] = ' ');
  760.     ext[3] = '\0'; /* Sauber abschliessen */
  761.     zeiger--;
  762.     *zeiger = '\0'; /* Originalextension von Eingang-String abhaengen */
  763.   end
  764.   else /* Sonst C anhaengen */
  765.     strcpy(ext,"C  ");
  766.   /* Nun den Dateiname fertigmachen */
  767.   strncpy(name,filename,8); /* Maximal 8 Charakters kopieren */;
  768.   name[8] = '\0';
  769.   if ((strlen(name) == 0) || (name[0]  == ' '))
  770.     strcpy(name,"WORK");
  771.   /* Rueckgabestring zusammenpuzzlen */
  772.   strcat(res,drive);
  773.   strcat(res,path);
  774.   strcat(res,name);
  775.   strcat(res,".");
  776.   strcat(res,ext);
  777.   /* String bis Ende auffuellen */
  778.   if (strlen(res) < 14) begin
  779.     int i, len;
  780.     len = strlen(res);
  781.     for(i = len; i < 14; res[i++] = ' ');
  782.     res[14] = '\0'
  783.   end;
  784.   return(strupr(res));
  785.  
  786. end;
  787.  
  788.  
  789. /* Diese String-Eingabefunktion akzeptiert keine Leerzeichen und          */
  790. /* ermoeglicht mit <RETURN> eine "leere" Eingabe. Editiermoeglickkeit mit */
  791. /* <BACKSPACE>.                                                           */
  792. void my_getstr(nr,Str)
  793.   int nr;
  794.   char *Str;
  795. begin
  796.   int zeichen;
  797.   char *base;
  798.  
  799.   base = Str;
  800.   repeat
  801.     zeichen = getch();
  802.     *Str++ = zeichen;
  803.     if (zeichen != ' ') /* Echo produzieren */
  804.       putchar(zeichen);
  805.     if ((zeichen == BACKSPACE) && ((Str - base) > 1)) begin
  806.       Str -= 2;
  807.       putchar(' ');    /* Letztes Zeichen ueberschreiben und */
  808.       putchar(zeichen) /* wieder auf Position zurueck        */
  809.     end;
  810.     if (zeichen == ' ')
  811.       Str--;
  812.   until ((zeichen == LF) || (zeichen == CR) || ((Str - base) == nr));
  813.   if ((zeichen == LF) || (zeichen == CR)) begin
  814.     Str--;
  815.   end;
  816.   *Str = '\0';
  817. end
  818.  
  819.  
  820. void missing_file(Str)
  821.   string Str;
  822.  
  823. begin
  824.   printf("\n+++++++++++++++++++++++++++++++++++++++++++++");
  825.   printf("\n+  FEHLER:                                  +");
  826.   printf("\n+  Datei %12s fehlt !!!         +",Str);
  827.   printf("\n+ Vergewissern Sie sich, dass sich die      +");
  828.   printf("\n+ Datei im Default-Directory befindet.      +");
  829.   printf("\n+++++++++++++++++++++++++++++++++++++++++++++\n\n");
  830.   wait_key()
  831. end
  832.