home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / editors / tde150.arj / CFGMACRO.C < prev    next >
C/C++ Source or Header  |  1992-04-01  |  2KB  |  88 lines

  1. /*
  2.  * This module contains all the routines needed to save an existing macro
  3.  * definition file in tde.exe
  4.  *
  5.  * Program Name:  tdecfg
  6.  * Author:        Frank Davis
  7.  * Date:          October 5, 1991
  8.  */
  9.  
  10. #include <io.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14.  
  15. #include "tdecfg.h"
  16. #include "cfgmacro.h"
  17.  
  18. extern struct vcfg cfg;
  19. extern FILE *tde_exe;                  /* FILE pointer to tde.exe */
  20.  
  21. static WINDOW *w_ptr;
  22.  
  23. MACRO macros;
  24.  
  25. /********    EXTREMELY IMPORTANT   ************/
  26. /*
  27.  * If you modify tde, it is your responsibility to find the offset of
  28.  * the macro buffer in your new executable, tde.exe.
  29.  *
  30.  */
  31.  
  32. #define MACRO_OFFSET     68190l
  33.  
  34.  
  35. /*
  36.  * Name:    tdehelp
  37.  * Date:    October 1, 1991
  38.  * Notes:   Set up most of the window global variables.
  39.  */
  40. void tdemacro( void )
  41. {
  42. int c;
  43. int i;
  44. char line[200];
  45. char out_line[82];
  46. char fname[82];
  47. char *rc;
  48. FILE *macro_file;                  /* FILE pointer to macro */
  49. long offset;
  50.  
  51.  
  52.    cls( );
  53.    show_box( 0, 0, macro_screen, NORMAL );
  54.    xygoto( 42, 14 );
  55.    c = getkey( );
  56.    while (c != '1' && c != '2')
  57.       c = getkey( );
  58.    if (c == '1') {
  59.       puts( "" );
  60.       puts( "" );
  61.       puts( "" );
  62.       puts( "Enter file name that contains the macro definitions :" );
  63.       gets( fname );
  64.       if ((c = access( fname, EXIST )) != 0) {
  65.          puts( "\nFile not found.  Press any key to continue." );
  66.          c = getkey( );
  67.          cls( );
  68.          return;
  69.       } else if ((macro_file = fopen( fname, "rb" )) == NULL ) {
  70.          puts( "\nCannot open macro file.  Press any key to contine." );
  71.          c = getkey( );
  72.          cls( );
  73.          return;
  74.       }
  75.  
  76.       fread( (void *)¯os, sizeof(MACRO), 1, macro_file );
  77.       fseek( tde_exe, MACRO_OFFSET, SEEK_SET );
  78.       fwrite( (void *)¯os, sizeof(MACRO), 1, tde_exe );
  79.       fclose( macro_file );
  80.       puts( "" );
  81.       puts( "" );
  82.       puts( "" );
  83.       puts( "New macros successfully installed.  Press any key to continue." );
  84.       c = getkey( );
  85.    }
  86.    cls( );
  87. }
  88.