home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / beehive / utilitys / xwp11src.arc / XWPUSER.C < prev   
Text File  |  1990-07-21  |  2KB  |  100 lines

  1. /*    XWPUSER.C
  2. **
  3. **    User-defined menu for XWP
  4. */
  5.  
  6. #include "a:stdio.h"
  7. #include "b:oxege.h"
  8.  
  9. char FLuser, *GLuser;
  10. int GLusnums;
  11. extern char FLerror;
  12.  
  13. /*    USER -- User-defined menu
  14. **    
  15. **    FLuser = status of user menu initialization:
  16. **        0   = not initialized
  17. **        1   = initialized and ok
  18. **        127 = attempt to initialize failed
  19. **
  20. **    GLuser  data structure:
  21. **        10 possible fields of:
  22. **            10 bytes    identifier string
  23. **            15 bytes    command string
  24. **    GLusnums = number of program options found by userinit()
  25. */
  26. user()
  27.     {
  28.     int counter, choice;
  29.     char *pointer;
  30.     /* First check FLuser status and initialize if necessary */
  31.     if( FLuser == NULL )
  32.         {
  33.         userinit();
  34.         }
  35.     if( FLuser == 127 )
  36.         {
  37.         error( "XWP.USR NOT FOUND" );
  38.         FLerror = 0;
  39.         return;
  40.         }
  41.     /* Now set up menu areas */
  42.     pointer = GLuser;
  43.     counter = 0;
  44.     while( counter < GLusnums )
  45.         {
  46.         strcpy( scratch, " " );
  47.         strcat( scratch, pointer );
  48.         setmenu( counter+1, 12, scratch );
  49.         pointer += 25;
  50.         ++counter;
  51.         }
  52.     setmenu( counter+1, 12, " RETURN " );
  53.     /* Save the environment */
  54.     savewindow( 1, 50, 4+GLusnums, 62, 0, 1 );    
  55.     /* get menu choice */
  56.     choice = menu( 1, 50, 1, GLusnums+1, 12, 1 );
  57.     /* restore environment  */
  58.     savewindow( 1, 50, 4+GLusnums, 62, 1, 1);
  59.     /* execute the choice */
  60.     if( choice <= GLusnums )
  61.         {
  62.         pointer = GLuser-15+( choice * 25 );
  63.         check( pointer );
  64.         if ( !FLerror )
  65.             {
  66.             strcpy( scratch, pointer );
  67.             strcat( scratch, "!xwp"  );
  68.             execl( scratch );
  69.             }
  70.         }
  71.     FLerror = 0;
  72.     }
  73.  
  74. userinit()
  75.     {
  76.     int udatfile, counter;
  77.     char *pointer;
  78.     if( ( udatfile = fopen( "XWP.USR", "r" ) ) == NULL )
  79.         {
  80.         FLuser = 127;
  81.         return;
  82.         }
  83.     FLuser = 1;
  84.     pointer = GLuser = malloc( 500 );
  85.     counter = 0;
  86.     while( !feof( udatfile ) )
  87.         {
  88.         fgets( pointer,    11, udatfile );
  89.         fgets( pointer+10, 16, udatfile );
  90.         xcr( pointer );
  91.         xcr( pointer+10 );
  92.         pointer += 25;
  93.         ++counter;
  94.         }
  95.     GLusnums = counter-1;    /* subtract the last (null) line */
  96.     }
  97.  
  98. 
  99.         xcr( pointer+10 );
  100.         pointer +