home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0682.ZIP / CCE_0682.PD / DSPSHELL / C_SOURCE / DSPSHELL.C next >
C/C++ Source or Header  |  1993-09-27  |  25KB  |  883 lines

  1. /*********************************************
  2.  * DSPSHELL    Version 1.0                      *
  3.  * von      Mario Bahr                          *    
  4.  * 14532 Kleinmachnow                        *
  5.  * Karl-Marx-Straße 110                      * 
  6.  * unter Nutzung einer erweiterten POWERGEM- *
  7.  * BIBLIOTHEK von Boris Sander aus TOS 4/93  *
  8.  *********************************************/
  9.  
  10. #include <stdio.h>
  11. #include <aes.h>
  12. #include <vdi.h>
  13. #include <tos.h>
  14. #include <stdlib.h>
  15. #include <process.h>
  16. #include <string.h>
  17. #include <time.h >
  18. #include "D:\DSPSHELL\dspshell.h" 
  19. #include "scancode.h"
  20. #include "powergem.h"
  21. #include "powrtext.h"
  22. #include "easyfsel.h"
  23.  
  24.  
  25. #define NO_DATEI -33
  26. #define FILE_EXIST -34
  27. #define FILE_NOEXIST -35
  28. #define NO_PRG -36
  29. #define FALSE_EXTENSION -100
  30. #define TEXT_ERROR    -200
  31.  
  32. #define FEHLER -1
  33.  
  34. #define EDITOR 1
  35. #define EXECUTE 2
  36.  
  37. /* Globale Variablen ----------------------------------------------------- */
  38. typedef struct 
  39. {
  40. char edit[15];        /* aktuelle Datei            */
  41. char edit_path[256];/* Pfad für aktuelle Datei   */
  42. char editor[256];    /* Pfad für Editor           */
  43. char a56[256];        /* Pfad für A56              */
  44. char otl[256];        /* Pfad für out to lod       */
  45. char exe_path[256]; /* Pfad für anderes Programm */
  46. int main_x,main_y;    /* Koordinaten des SHELL-Fensters */ 
  47. }CONFIGURATION;
  48.  
  49. CONFIGURATION config,temp; 
  50. int prg_flag;
  51. char prg_pfad[256]; /* Pfad für dieses Programm */
  52.  
  53. TEXT *reportA56 = NULL;        /* Zeiger auf A56-Reporttext */
  54. TEXT *reportotl = NULL;        /* Zeiger auf OTL-Reporttext */
  55. char main_info[]=" DSP-SHELL V1.0 ";
  56. char reportA56_info[]=" Report of A56 ";
  57. char reportotl_info[]=" Report of OUT to LOD ";
  58.  
  59. int TEXT_ELEMENTS=NAME|CLOSER|MOVER|SIZER|FULLER|UPARROW|
  60.                  DNARROW|RTARROW|LFARROW|VSLIDE|HSLIDE;
  61.  
  62. /* Prototyp -------------------------------------------------------------- */
  63. int main(void);
  64. void exit_prg(void);
  65. void infobox(void);
  66. void open_anzeige(char *text,char *file);
  67. void close_anzeige(void);
  68. void init_all(void);
  69. void read_config(void);
  70. void save_config(void);
  71. void new_file(void);
  72. void open_file(void);
  73. void parameter(void);
  74. void start_editor(void);
  75. void start_exe(void);
  76. void execute_editor(void);
  77. void execute_exe(void);
  78. void execute_asm(void);
  79. void execute_otl(void);
  80. void make_all(void);
  81. int set_execute(char *dest,char *title);
  82. void show_report(TEXT **report,char *name,char *file,
  83.                         void (*draw)(struct WINDOW *win),int(*close)
  84.                         (struct WINDOW *win) );
  85. void draw_A56report(struct WINDOW *win);
  86. void draw_otlreport(struct WINDOW *win);
  87. int close_A56report(struct WINDOW *win);
  88. int close_otlreport(struct WINDOW *win);
  89. void text_down(void);
  90. void text_up(void);
  91. void text_right(void);
  92. void text_left(void);
  93. void texts_down(void);
  94. void texts_up(void);
  95. void text_a(void);
  96. void text_e(void);
  97.  
  98. int error(int fehler_e);
  99.  
  100. /* ---------------------------------------------------------------------- */
  101. /* Hauptinitialisierung                                                      */
  102. /* ---------------------------------------------------------------------- */
  103. int main(void)
  104. {
  105. char resourcen[256];
  106. get_akt_path(prg_pfad);
  107.  
  108. build_filname(resourcen,prg_pfad,"DSPSHELL.RSC");
  109.  
  110. do
  111.     {    
  112.     if (init_powergem(resourcen, MENUE))  /* PowerGEM initialisieren */
  113.         {
  114.         /* Funktionen des Menüs anmelden ------------------ */
  115.  
  116.         init_desktop(DESKTOP);        
  117.         key_action( CNTRL_W, untop_win);    /* Fensterwechsel mit ^W */ 
  118.         /* Cursortasten für Text */
  119.         key_action( CUR_DOWN, text_down);    /* Zeilen und Spaltenweise */
  120.         key_action( CUR_UP, text_up);
  121.         key_action( CUR_RIGHT, text_right);
  122.         key_action( CUR_LEFT, text_left);    
  123.  
  124.         key_action( SHFT_CD, texts_down);    /* Seitenweise            */    
  125.         key_action( SHFT_CU, texts_up);
  126.  
  127.         key_action( HOME, text_a);        /* an den Anfang         */
  128.         key_action( SHFT_HOME, text_e); /* ans Ende                */
  129.  
  130.         menu_action( MTINFO ,  M_INFO  , CNTRL_I, infobox       ); 
  131.         menu_action( MTDATEI , M_NEU   , CNTRL_N, new_file      );
  132.         menu_action( MTDATEI , M_OEFFNEN,CNTRL_O, open_file     );
  133.         menu_action( MTDATEI , M_ENDE   ,CNTRL_Q, exit_prg         );
  134.         menu_action( MTDATEI , MEXE      ,ALT_E  , execute_exe    );
  135.         menu_action( MTDO_IT , MEDITOR  ,CNTRL_E, execute_editor);
  136.         menu_action( MTDO_IT , MASSEMBLE,ALT_A,   execute_asm   );
  137.         menu_action( MTDO_IT , MOUTLOD  ,ALT_L,   execute_otl   );
  138.         menu_action( MTDO_IT , MMAKEALL ,ALT_X,   make_all        );
  139.         menu_action( MTOPTION, MPFAD   , ALT_C  , parameter        );
  140.         menu_action( MTOPTION, MSAVE   , ALT_S  , save_config   );
  141.         
  142.  
  143.         /* Zu überwachende Ereignisse festlegen -> multi */
  144.         watch_events(MU_MESAG|MU_BUTTON|MU_KEYBD, 2,1,1); 
  145.         graf_mouse(ARROW, NULL);
  146.         init_all();
  147.         multi(); 
  148.         }
  149.     if(prg_flag== EDITOR) /* Da sicherlich GEM-Programm 
  150.                                 -> eigene Applikation terminieren */
  151.         start_editor();
  152.  
  153.     if(prg_flag ==    EXECUTE)
  154.         start_exe();        /* andere Applikation starten */                
  155.  
  156.     }while(prg_flag);
  157. return 0;
  158. }
  159. /*************************************************
  160.  * Beendet Programm  und sichert Konfiguration   *
  161.  *************************************************/
  162. void exit_prg(void)
  163. {
  164. prg_flag=0;    
  165. save_config();
  166. exit_powergem();
  167.  
  168. /************************
  169.  * Infobox                 *
  170.  ************************/
  171. void infobox(void)
  172. {
  173. struct WINDOW *info;
  174.  
  175. info = create_dial(DINFO, 0, NAME|MOVER,UNMODAL,0, 0, 0,0,0);
  176.  
  177. if (info)
  178.     {
  179.     button_action(info, DINFOOK,break_dial, FALSE);
  180.     open_window(info, "DSP-SHELL", 0);
  181.     }
  182. }
  183. /************************
  184.  * Anzeige  an            *
  185.  ************************/
  186. void open_anzeige(char *text,char *file)
  187. {
  188. struct WINDOW *anzeige;
  189.  
  190. anzeige = create_dial(DANZEIGE, 0, NAME|MOVER,MODAL,0, 0, 0,0,0);
  191.  
  192. if (anzeige)
  193.     {
  194.     set_text(anzeige, ANZEIGE, text, (int)strlen(text),FALSE);
  195.     set_text(anzeige, DNAME, file, (int)strlen(file),FALSE);
  196.     open_window(anzeige, "DSP-SHELL ", 0);
  197.     }
  198. }
  199. /************************
  200.  * Anzeige  aus            *
  201.  ************************/
  202. void close_anzeige(void)
  203. {
  204. break_dial();
  205. }
  206.  
  207. /********************************************************************
  208.  * Initialisiert alles, und stellt kleines Fenster dar                 *
  209.  * Zugriff auf globale Struktur config                              *
  210.  ********************************************************************/
  211. void init_all(void)
  212. {
  213. struct WINDOW *init;
  214.  
  215. init = create_dial(MAIN, 0, NAME|MOVER,UNMODAL,0, 0, 0,0,0);
  216.  
  217. if (init)
  218.     {
  219.     read_config();
  220.     set_text(init, IN_DATEI, config.edit,
  221.                      (int)strlen(config.edit), FALSE);
  222.     button_action(init, IN_DATEI,open_file, FALSE);
  223.     button_action(init, DEDITOR,execute_editor,FALSE);
  224.     button_action(init, DASSEMBLE,execute_asm, FALSE);
  225.     button_action(init, DOUTTOLOD,execute_otl, FALSE);
  226.     button_action(init, DMAKEALL ,make_all, FALSE);
  227.     init->actual_position.g_x=config.main_x;
  228.     init->actual_position.g_y=config.main_y;
  229.     open_window(init, main_info, 0);
  230.     }
  231. else
  232.     exit_powergem();    
  233. }
  234. /********************************************************************
  235.  * Liest aktuelle Konfiguration ein                                  *
  236.  * Zugriff auf globale Struktur config und auf app_cntrl-Struktur    *
  237.  ********************************************************************/
  238. void read_config(void)
  239. {
  240. FILE *config_file;
  241. char configuration[256];
  242.  
  243. build_filname(configuration,prg_pfad,"DSPSHELL.SYS");
  244.  
  245. config_file=fopen(configuration,"r");        /* Daten einlesen */
  246. if(config_file != NULL)
  247.     {
  248.     fscanf(config_file,"%s\n%s\n%s\n%s\n%s\n%s\n",config.edit,
  249.     config.edit_path,config.editor,config.a56,config.otl,config.exe_path);
  250.     fscanf(config_file,"%i %i\n",&config.main_x,&config.main_y);
  251.     if(config.main_x+100  >= get_app_cntrl()->workarea.g_w ||     /* bei geringerer Auflösung */
  252.             config.main_y+100  >= get_app_cntrl()->workarea.g_h || 
  253.             config.main_x  <= get_app_cntrl()->workarea.g_x || 
  254.             config.main_y  <= get_app_cntrl()->workarea.g_y )
  255.         {
  256.         config.main_x=get_app_cntrl()->workarea.g_x+5;
  257.         config.main_y=get_app_cntrl()->workarea.g_y+10;
  258.         }         
  259.     fclose(config_file);
  260.     }
  261. else
  262.     {
  263.     sprintf(config.edit,"NEW.ASM");
  264.     get_akt_path(config.edit_path); /* aktuellen Pfad setzen */
  265.     sprintf(config.editor,"C:\\EDITOR\\EDITOR.PRG");
  266.     sprintf(config.a56,"C:\\DSP\\A56.TTP");
  267.     sprintf(config.otl,"C:\\DSP\\OUTTOLOD.TTP");
  268.     config.main_x=get_app_cntrl()->workarea.g_x+5;
  269.     config.main_y=get_app_cntrl()->workarea.g_y+10;
  270.     get_akt_path(config.exe_path);
  271.     }
  272. }
  273. /********************************************************************
  274.  * Sichert aktuelle Konfiguration                                       *
  275.  * Zugriff auf globale Struktur config                              *
  276.  ********************************************************************/
  277. void save_config(void)
  278. {
  279. FILE *config_file;
  280. char configuration[256];
  281. struct WINDOW *main;
  282. int dummy;
  283.  
  284. build_filname(configuration,prg_pfad,"DSPSHELL.SYS");
  285.  
  286. config_file=fopen(configuration,"w");
  287. if(config_file != NULL)
  288.     {
  289.     fprintf(config_file,"%s\n%s\n%s\n%s\n%s\n%s\n",config.edit,
  290.             config.edit_path,config.editor,config.a56,config.otl
  291.                 ,config.exe_path);
  292.     main=get_winfn(main_info);
  293.     if(main)    /* Koordinaten sichern */
  294.         {
  295.         wind_get(main->w_handle,WF_CURRXYWH,&config.main_x,
  296.             &config.main_y, &dummy, &dummy); 
  297.         }    
  298.     fprintf(config_file,"%i %i\n",config.main_x,config.main_y);
  299.     fclose(config_file);
  300.     }
  301. }
  302. /********************************************************************
  303.  * Legt eine neue Datei an                                               *
  304.  * Zugriff auf globale Struktur config                              *
  305.  ********************************************************************/
  306. void new_file(void)
  307. {
  308. char datei[15]="";
  309. char path[256];
  310. char dat_path[256];
  311. FILE *new;
  312. time_t date_clock;
  313.  
  314. strcpy(path,config.edit_path);
  315. if(easy_fsel(path,datei,"CREATE NEW FILE" ) && datei[0] != 0x0)
  316.     {
  317.     if(check_extension(datei,"ASM")==FALSE)
  318.         {
  319.         error(FALSE_EXTENSION);
  320.         return;
  321.         }
  322.     build_filname(dat_path,path,datei);
  323.     if(!exist_file(dat_path))
  324.         {
  325.         if( (new=fopen(dat_path,"w")) != NULL)
  326.             {
  327.             strcpy(config.edit,datei);    
  328.             strcpy(config.edit_path,path);    
  329.             date_clock=time(&date_clock);
  330.             fprintf(new,";DSP56-File: %s \n",ctime(&date_clock));  
  331.             fclose(new);
  332.             blank(0,0,0,0,0); /* REDRAW */
  333.             }
  334.         else
  335.             error(NO_DATEI);
  336.         }    
  337.     else
  338.         error(FILE_EXIST);
  339.     }        
  340. }
  341. /********************************************************************
  342.  * Öffnet eine Datei                                                  *
  343.  * Zugriff auf globale Struktur config                              *
  344.  ********************************************************************/
  345. void open_file(void)
  346. {
  347. char datei[15]="";
  348. char path[256];
  349. char dat_path[256];
  350. FILE *_datei;
  351.  
  352. strcpy(path,config.edit_path);
  353. if(easy_fsel(path,datei,"OPEN FILE" ) && datei[0] != 0x0)
  354.     {
  355.     if(check_extension(datei,"ASM")==FALSE)
  356.         {
  357.         error(FALSE_EXTENSION);
  358.         return;
  359.         }
  360.     build_filname(dat_path,path,datei);
  361.     if(exist_file(dat_path))
  362.         {
  363.         if((_datei=fopen(dat_path,"r")) != NULL)
  364.             {
  365.             strcpy(config.edit,datei);    
  366.             strcpy(config.edit_path,path);    
  367.             set_text(get_winfn(main_info),IN_DATEI,config.edit,
  368.                                  (int)strlen(config.edit),TRUE);
  369.             fclose(_datei);    /* Wir haben sie uns ja bereits gemerkt */  
  370.             }
  371.         else
  372.             error(NO_DATEI);
  373.         }    
  374.     else
  375.         error(FILE_NOEXIST);
  376.     }        
  377. }
  378.  
  379. void set_new(void);
  380. void select_editor(void);
  381. void select_asm(void);
  382. void select_otl(void);
  383.  
  384. /********************************************************************
  385.  * Parameter setzen                                                    *
  386.  * Zugriff auf globale Struktur config                              *
  387.  ********************************************************************/
  388. void parameter(void)
  389. {
  390. struct WINDOW *parameter;
  391.  
  392. parameter = create_dial(PARAMETER, 0, NAME|MOVER,MODAL,0, 0, 0,0,0);
  393.  
  394. if (parameter)
  395.     {
  396.     memcpy(&temp,&config,sizeof(config)); /* Werte kopieren */
  397.     
  398.     set_text(parameter, PSEDITOR, temp.editor,
  399.                      (int)strlen(temp.editor), FALSE);
  400.     set_text(parameter, PSASM, temp.a56,
  401.                      (int)strlen(temp.a56), FALSE);
  402.     set_text(parameter, PSOUTTOLOD, temp.otl,
  403.                      (int)strlen(temp.otl), FALSE);
  404.  
  405.     
  406.     button_action(parameter,PARACAN,break_dial, FALSE);
  407.     button_action(parameter,PARAOK,set_new, FALSE);
  408.     button_action(parameter,PSEDITOR,select_editor, FALSE);
  409.     button_action(parameter,PSASM,select_asm, FALSE);
  410.     button_action(parameter,PSOUTTOLOD,select_otl, FALSE);
  411.  
  412.     open_window(parameter, "DSP-SHELL", 0);
  413.     }
  414. else
  415.     exit_powergem();    
  416. }
  417. /***********************************************
  418.  * Setzt die Parameter                         *
  419.  ***********************************************/
  420. void set_new(void)
  421. {
  422. memcpy(&config,&temp,sizeof(CONFIGURATION)); /* Werte kopieren */
  423. break_dial();
  424. }
  425. /***********************************************
  426.  * Editor selektieren                          *
  427.  ***********************************************/
  428. void select_editor(void)
  429. {
  430. char dest[256]="";
  431. if(set_execute(dest,"SELECT EDITOR") != FEHLER)
  432.     {
  433.     strcpy(temp.editor,dest);
  434.     }
  435. }
  436. /***********************************************
  437.  * Assembler selektieren                       *
  438.  ***********************************************/
  439. void select_asm(void)
  440. {
  441. char dest[256]="";
  442. if(set_execute(dest,"SELECT ASM56") != FEHLER)
  443.     strcpy(temp.a56,dest);
  444. }
  445. /***********************************************
  446.  * OUT TO LOD  selektieren                     *
  447.  ***********************************************/
  448. void select_otl(void)
  449. {
  450. char dest[256]="";
  451. if(set_execute(dest,"SELECT OUTTOLOD") != FEHLER)
  452.     strcpy(temp.otl,dest);
  453. }
  454.  
  455. /***********************************************
  456.  * Programm selektieren                        *
  457.  * Input: dest Zeiger für Zielstring           * 
  458.  *          title Zeiger auf Titel               *    
  459.  * Output:evtl. Fehlercode                       *
  460.  ***********************************************/
  461. int set_execute(char *dest,char *title)
  462. {
  463. char datei[15]="";
  464. char path[256];
  465. char dat_path[256];
  466.  
  467. strcpy(path,config.edit_path);
  468. if(easy_fsel(path,datei,title ) && datei[0] != 0x0)
  469.     {
  470.     build_filname(dat_path,path,datei);
  471.     if(exist_file(dat_path))
  472.         {
  473.         strcpy(dest,dat_path);    
  474.         blank(0,0,0,0,0); /* REDRAW */
  475.         }
  476.     else
  477.         return(error(FILE_NOEXIST));
  478.     }        
  479. else
  480.     return FEHLER;
  481. return 0;
  482. }
  483. /***********************************************
  484.  * Setzt Flags um den Editor zu starten        *
  485.  ***********************************************/
  486. void execute_editor(void)
  487. {
  488. blank(0,0,0,0,0); /* REDRAW */
  489.  
  490. exit_powergem();
  491. prg_flag=EDITOR;
  492. }
  493. /**********************************************
  494.  * Startet anderes Programm                      *
  495.  **********************************************/
  496. void execute_exe(void)
  497. {
  498. char datei[15];
  499. char path[240];
  500.  
  501. extract_filename(path,datei,config.exe_path);
  502. strcat(path,"\\*.*");
  503. if(easy_fsel(path,datei,"EXECUTE PRG" ) && datei[0] != 0x0)
  504.     {
  505.     build_filname(config.exe_path,path,datei);
  506.     prg_flag=EXECUTE;
  507.     exit_powergem();
  508.     }
  509. }
  510. /***********************************************
  511.  * Startet den (GEM)-EDITOR                    *     
  512.  ***********************************************/
  513. void start_editor(void)
  514. {
  515. int ret_code;
  516. char dat_pfad1[256],datei[15],e_pfad[256],old_pfad[256];
  517. char dat_pfad2[256];
  518.  
  519. save_config();
  520. get_akt_path(old_pfad);
  521. extract_filename(e_pfad,datei,config.editor);
  522. build_filname(dat_pfad1,config.edit_path,config.edit);
  523. build_filname(dat_pfad2,config.edit_path,"REPORT.A56 ");
  524. strcat(dat_pfad2,dat_pfad1);
  525. set_new_path(e_pfad);
  526. if(exec( datei,dat_pfad2,old_pfad , &ret_code) <0)
  527.     error(NO_PRG);
  528. set_new_path(old_pfad);
  529. }
  530. /***********************************************
  531.  * Startet beliebiges Programm                    *     
  532.  ***********************************************/
  533. void start_exe(void)
  534. {
  535. char datei[15],parameter[2]="",e_pfad[256],old_pfad[256];
  536. int ret_code;
  537.  
  538. save_config();
  539. get_akt_path(old_pfad);
  540. extract_filename(e_pfad,datei,config.exe_path);
  541.  
  542. set_new_path(e_pfad);
  543. if(exec( datei,parameter,e_pfad , &ret_code) <0)
  544.     error(NO_PRG);
  545. set_new_path(old_pfad);
  546. }
  547. /***********************************************
  548.  * Ruft den Assembler auf und übergibt ihm     *
  549.  * die zu assemblierende Datei                   *
  550.  ***********************************************/
  551. void execute_asm(void)
  552. {
  553. int ret_code,f_handle,flag =FALSE;
  554. char dat_path[128];
  555. char buf[13]="report.a56";
  556. char parameter[256]="-o";
  557. time_t date_clock;
  558.  
  559. build_filname(dat_path,config.edit_path,buf);
  560. f_handle = (int)Fcreate(dat_path,0);
  561. if(f_handle > 0)
  562.     {
  563.     strcpy(buf,config.edit);
  564.     swap_extension(buf,"OUT");    /* OUT-Endung setzen          */
  565.     build_filname(dat_path,config.edit_path,buf);
  566.     
  567.     graf_mouse(HOURGLASS,0);
  568.     open_anzeige("   ASSEMBLE  TO ",dat_path);
  569.     
  570.     strcat(parameter,dat_path);        /* an Parameterliste anhängen */
  571.     build_filname(dat_path,config.edit_path,config.edit);
  572.     strcat(parameter," ");        /* Leerzeichen                   */
  573.     strcat(parameter,dat_path); /* ASM-File anhängen          */
  574.     
  575.     Fforce(1,f_handle);    /* Bildschirmausgabe in Datei umlenken */
  576.     date_clock=time(&date_clock);
  577.     printf("DSP56 - OUT - Report: %s \n",ctime(&date_clock));  
  578.     printf("A56 Assembler say: \n"); 
  579.     
  580.     if(exec( config.a56,parameter,get_akt_path(dat_path), &ret_code) <0 )
  581.         {
  582.         graf_mouse(ARROW,0);
  583.         error(NO_PRG);
  584.         flag =TRUE;        
  585.         }
  586.     Fforce(1,1);
  587.     Fclose(f_handle);                                                            
  588.     close_anzeige();
  589.     graf_mouse(ARROW,0);
  590.     if( ret_code != 0 && flag == FALSE )
  591.         show_report(&reportA56,reportA56_info,"REPORT.A56",
  592.                                     draw_A56report,close_A56report);
  593.  
  594.     }
  595. else
  596.     error(NO_DATEI);
  597. }
  598.  
  599. /***********************************************
  600.  * Wandelt OUT in LOD Format                   *
  601.  ***********************************************/
  602. void execute_otl(void)
  603. {
  604. int ret_code,f_handle;
  605. char dat_path[256],buf[256];
  606. char report[13]="report.otl";
  607. time_t date_clock;
  608.  
  609. build_filname(dat_path,config.edit_path,report);
  610.  
  611. f_handle = (int)Fcreate(dat_path,0);
  612. if(f_handle > 0)
  613.     {
  614.     Fforce(1,f_handle);    /* Bildschirmausgabe in Datei umlenken */
  615.     date_clock=time(&date_clock);
  616.     printf("DSP56 - LOD - Report %s \n",ctime(&date_clock));  
  617.     printf("OUT to LOD say: \n"); 
  618.     build_filname(dat_path,config.edit_path,config.edit);
  619.     graf_mouse(HOURGLASS,0);
  620.     strcpy(buf,dat_path);
  621.     open_anzeige("    OUT TO LOD ",    swap_extension(buf,"LOD"));
  622.     swap_extension(dat_path,"OUT");
  623.  
  624.     if(exec( config.otl,dat_path,get_akt_path(buf), &ret_code) < 0 )
  625.         {    
  626.         graf_mouse(ARROW,0);
  627.         error(NO_PRG);
  628.         }
  629.     Fforce(1,1);
  630.     Fclose(f_handle);
  631.     close_anzeige();
  632.     graf_mouse(ARROW,0);
  633.     if(ret_code != 0)
  634.         show_report(&reportotl,reportotl_info,"REPORT.OTL",
  635.                                     draw_otlreport,close_otlreport);
  636.     }
  637. else
  638.     error(NO_DATEI);
  639. }
  640. /*******************************************
  641.  * Assembliert und wandelt um in einem Zug *
  642.  *******************************************/
  643. void make_all(void)
  644. {
  645. execute_asm();
  646. execute_otl();
  647. }
  648. /************************************************
  649.  * Zeigt  Report                                *
  650.  * Input: report: Zeiger auf TEXT                *
  651.  *        name:   Name des Fensters                *
  652.  *        file:   einzulesende Datei(ohne Pfad!)*
  653.  *                   -> Pfad von Source             *
  654.  *        draw:   Zeiger auf Textredrawfunktion    *
  655.  *        close   Zeiger auf Closefunktion        *    
  656.  ************************************************/
  657. void show_report(TEXT **report,char *name,char *file,
  658.     void (*draw)(struct WINDOW *win),int (*close)(struct WINDOW *win))
  659. {
  660. struct WINDOW *win;
  661. GRECT winpos,*desk; 
  662. char dat_path[256];
  663.  
  664. break_win( (win=get_winfn(name)) );    /* Falls das Fenster schon offen
  665.                                         -> schließen */        
  666.  
  667. build_filname(dat_path,config.edit_path,file);
  668. *report = text_read(dat_path,4);
  669. if(*report == NULL)
  670.     {error(TEXT_ERROR);return;}            /*     Fehler beim einlesen */            
  671.  
  672.  
  673. desk=&get_app_cntrl()->workarea;
  674.  
  675. winpos.g_x =desk->g_x + ((rand())&0x1F)+10;
  676. winpos.g_y =desk->g_y + ((rand())&0x1F)+10;
  677. winpos.g_w =desk->g_w-winpos.g_x; 
  678. winpos.g_h =desk->g_h-winpos.g_y; 
  679.  
  680. win = create_window(desk, &winpos, 150, 150, TEXT_ELEMENTS,                
  681.             DATA_WINDOW,draw, 0, 0, 0 ,0 ,close);
  682. if (win)
  683.     {
  684.     /* Slider initialisieren -------------------------- */
  685.     init_slider(win, (*report)->max_spalten ,(*report)->zeilen,
  686.     get_app_cntrl()->gl_wchar ,get_app_cntrl()->gl_hchar);
  687.     open_window(win, name,"");
  688.     }
  689.  
  690. }
  691.  
  692. /************************************
  693.  * Zeichnet den A56-Text             *
  694.  ************************************/
  695. void draw_A56report(struct WINDOW *win)
  696. {
  697. text_draw(win,reportA56);
  698. }
  699. /************************************
  700.  * Zeichnet den OTL-Text             *
  701.  ************************************/
  702. void draw_otlreport(struct WINDOW *win)
  703. {
  704. text_draw(win,reportotl);
  705. }
  706. /************************************
  707.  * Schließt A56 Text                 *
  708.  ************************************/
  709. int close_A56report(struct WINDOW *win)
  710. {
  711. if(win)
  712.     text_free(reportA56);
  713. return 0;
  714. }
  715. /************************************
  716.  * Schließt OTL Text                 *
  717.  ************************************/
  718. int close_otlreport(struct WINDOW *win)
  719. {
  720. if(win)
  721.     text_free(reportotl);
  722. return 0;
  723. }
  724. /****************************************
  725.  * Text eine Position nach unten        *
  726.  *                                        *
  727.  ****************************************/
  728. void text_down(void)
  729. {
  730. struct WINDOW *win;
  731. int wh;
  732.  
  733. wind_get(0, WF_TOP, &wh, 0,0,0);     /* Oberstes Fenster ermitteln  */  
  734. win=get_winfh(wh);
  735. set_y_slider(win, get_y_slider(win)+1);
  736. }
  737.  
  738. /****************************************
  739.  * Text eine Position nach oben            *
  740.  *                                        *
  741.  ****************************************/
  742. void text_up(void)
  743. {
  744. struct WINDOW *win;
  745. int wh;
  746.  
  747. wind_get(0, WF_TOP, &wh, 0,0,0);     /* Oberstes Fenster ermitteln  */  
  748. win=get_winfh(wh);
  749. set_y_slider(win, get_y_slider(win)-1);
  750. }
  751.  
  752. /****************************************
  753.  * Text eine Position nach rechts        *
  754.  *                                        *
  755.  ****************************************/
  756. void text_right(void)
  757. {
  758. struct WINDOW *win;
  759. int wh;
  760.  
  761. wind_get(0, WF_TOP, &wh, 0,0,0);     /* Oberstes Fenster ermitteln  */  
  762. win=get_winfh(wh);
  763. set_x_slider(win, get_x_slider(win)+1);
  764. }
  765.  
  766. /****************************************
  767.  * Text eine Position nach links        *
  768.  *                                        *
  769.  ****************************************/
  770. void text_left(void)
  771. {
  772. struct WINDOW *win;
  773. int wh;
  774.  
  775. wind_get(0, WF_TOP, &wh, 0,0,0);     /* Oberstes Fenster ermitteln  */  
  776. win=get_winfh(wh);
  777. set_x_slider(win, get_x_slider(win)-1);
  778. }
  779. /****************************************
  780.  * Text eine Seite nach unten            *
  781.  *                                        *
  782.  ****************************************/
  783. void texts_down(void)
  784. {
  785. struct WINDOW *win;
  786. int w_z;            /* Anzahl der mögliche Spalten */
  787. int wh;
  788.  
  789. wind_get(0, WF_TOP, &wh, 0,0,0);     /* Oberstes Fenster ermitteln  */  
  790. win=get_winfh(wh);
  791. if(win)                /* Wir haben ja nur Textfenster mit Slider */
  792.     {                /*   -> keine weitere Abfrage nötig         */     
  793.     w_z=abs(win->workarea.g_h/get_app_cntrl()->gl_hchar-2);
  794.     set_y_slider(win, get_y_slider(win)+ w_z);
  795.     }
  796. }
  797. /****************************************
  798.  * Text eine Seite nach oben            *
  799.  *                                        *
  800.  ****************************************/
  801. void texts_up(void)
  802. {
  803. struct WINDOW *win;
  804. int w_z;            /* Anzahl der mögliche Spalten */
  805. int wh;
  806.  
  807. wind_get(0, WF_TOP, &wh, 0,0,0);     /* Oberstes Fenster ermitteln  */  
  808. win=get_winfh(wh);
  809. if(win)                /* Wir haben ja nur Textfenster mit Slider */
  810.     {                /*   -> keine weitere Abfrage nötig         */     
  811.     w_z=abs(win->workarea.g_h/get_app_cntrl()->gl_hchar-2);
  812.     set_y_slider(win, get_y_slider(win)- w_z);
  813.     }
  814. }
  815. /****************************************
  816.  * Text an den Anfang                    *
  817.  *                                        *
  818.  ****************************************/
  819. void text_a(void)
  820. {
  821. struct WINDOW *win;
  822. int wh;
  823.  
  824. wind_get(0, WF_TOP, &wh, 0,0,0);     /* Oberstes Fenster ermitteln  */  
  825. win=get_winfh(wh);
  826. set_y_slider(win,0);
  827. }
  828. /****************************************
  829.  * Textende                                *
  830.  *                                        *
  831.  ****************************************/
  832. void text_e(void)
  833. {
  834. struct WINDOW *win;
  835. int wh;
  836.  
  837. wind_get(0, WF_TOP, &wh, 0,0,0);     /* Oberstes Fenster ermitteln  */  
  838. win=get_winfh(wh);
  839. set_y_slider(win,LAST_ZEILE);/* Auch wenn es diese Zeile nicht gibt */ 
  840. }
  841.  
  842. /************************************************
  843.  * Fehlermeldungen                                *
  844.  ************************************************/
  845. int error(int fehler_e)
  846. {
  847. char meldung[80];
  848. char tfehler[80];
  849. char *fehl_p;
  850. fehl_p=tfehler;
  851. if(fehler_e<0)
  852.     {
  853.     switch(fehler_e)
  854.         {
  855.         case NO_DATEI:
  856.             fehl_p=" File Error ! ";
  857.             break;
  858.         case FILE_EXIST:
  859.             fehl_p=" File exist ! ";
  860.             break;
  861.         case FILE_NOEXIST:
  862.             fehl_p=" File does'nt exist ! ";
  863.             break;
  864.         case FALSE_EXTENSION:
  865.             fehl_p=" Use only Files with '.asm' ! ";
  866.             break;
  867.         case NO_PRG:
  868.             fehl_p=" Cannot start Program ! ";
  869.             break;
  870.         case TEXT_ERROR:
  871.             fehl_p=" Cannot read text ! ";
  872.         default:
  873.             fehl_p="Not described Error !   ";
  874.         }    
  875.     sprintf(meldung,"[3][ | %s ][ OK ]",fehl_p);
  876.     form_alert(1,meldung);                /* Fehlermeldung zeigen    */
  877.     return FEHLER;
  878.     } 
  879. return 0;
  880. }
  881.  
  882. /* EOF */