home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 276.lha / Pref / pref.c < prev    next >
C/C++ Source or Header  |  1989-08-07  |  2KB  |  100 lines

  1. /****************************************************************************
  2.     pref.c
  3.  
  4.     activer des preferences différentes
  5.  
  6.     auteur: Louis Salvador
  7.  
  8.     janvier 88
  9.     création
  10.  
  11.     3 mars 88
  12.     remplacement de wb_parse() pour reduire dimension executable
  13.  
  14.     17 avril 89
  15.     modification de _main() et _exit pour reduire d'avantage la taille
  16.     de l'executable
  17.  
  18.     26 juin 89
  19.     fonctionne maintenant en WB
  20.  
  21. *****************************************************************************/
  22.  
  23. #include <libraries/dos.h>
  24. #include <libraries/dosextens.h>
  25. #include <intuition/intuition.h>
  26.  
  27. #define MAX_BUFF 256L
  28. #define INFORM    TRUE
  29.  
  30. struct IntuitionBase *IntuitionBase;
  31. extern struct WBStartup *WBenchMsg;
  32.  
  33. char *last_saved = "devs:system-configuration";
  34.  
  35. main(argc,argv)
  36. int  argc;
  37. char *argv[];
  38. {
  39.     struct FileHandle *InFile;
  40.     char    PrefBuff[MAX_BUFF];
  41.     LONG    ReadLen;
  42.     char    *arg;
  43.     struct WBArg *wba;
  44. #ifdef VERBOSE
  45.     struct FileHandle *STD;
  46.  
  47.     STD = Output(); if (STD == NULL) STD = Open("NIL:",MODE_NEWFILE);
  48. #endif
  49.  
  50.     if (!(IntuitionBase=(struct IntuitionBase*) OpenLibrary("intuition.library",0L))){
  51.     exit(20L);
  52.     }
  53.  
  54.     if (argc == 0 && WBenchMsg->sm_NumArgs >1L) {
  55.     wba = WBenchMsg->sm_ArgList;
  56.     wba++;
  57.     arg = wba->wa_Name;
  58.     CurrentDir(wba->wa_Lock);
  59.     }
  60.     else if(argc == 2)
  61.     arg = argv[1];
  62.     else {
  63. #ifdef VERBOSE
  64.     Write(STD,"usage: pref preference_file\n       pref *\n",42L);
  65. #else
  66.     DisplayBeep(0L);
  67. #endif
  68.     exit(20);
  69.     }
  70.  
  71.     if ((strcmp(arg,"standard") == 0) || (strcmp(arg,"*") == 0)) {
  72.     arg = last_saved;
  73. #ifdef VERBOSE
  74.     Write(STD,"preferences reset to last saved\n",32L);
  75. #endif
  76.     }
  77.     if ((InFile = Open(arg, MODE_OLDFILE)) == NULL){
  78. #ifdef VERBOSE
  79.     Write(STD,"Cannot open input file\n",23L);
  80. #else
  81.     DisplayBeep(0L);
  82. #endif
  83.     exit(20);
  84.     }
  85.     ReadLen = Read(InFile,PrefBuff,MAX_BUFF);
  86.     Close(InFile);
  87.  
  88.     if (ReadLen == 232)
  89.     SetPrefs((struct Preferences *)PrefBuff,ReadLen,INFORM);
  90.     else {
  91. #ifdef VERBOSE
  92.     Write(STD,"Not a preferences file\n",23L);
  93. #else
  94.     DisplayBeep(0L);
  95. #endif
  96.     }
  97.     CloseLibrary(IntuitionBase);
  98. }
  99.  
  100.