home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
276.lha
/
Pref
/
pref.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-07
|
2KB
|
100 lines
/****************************************************************************
pref.c
activer des preferences différentes
auteur: Louis Salvador
janvier 88
création
3 mars 88
remplacement de wb_parse() pour reduire dimension executable
17 avril 89
modification de _main() et _exit pour reduire d'avantage la taille
de l'executable
26 juin 89
fonctionne maintenant en WB
*****************************************************************************/
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#define MAX_BUFF 256L
#define INFORM TRUE
struct IntuitionBase *IntuitionBase;
extern struct WBStartup *WBenchMsg;
char *last_saved = "devs:system-configuration";
main(argc,argv)
int argc;
char *argv[];
{
struct FileHandle *InFile;
char PrefBuff[MAX_BUFF];
LONG ReadLen;
char *arg;
struct WBArg *wba;
#ifdef VERBOSE
struct FileHandle *STD;
STD = Output(); if (STD == NULL) STD = Open("NIL:",MODE_NEWFILE);
#endif
if (!(IntuitionBase=(struct IntuitionBase*) OpenLibrary("intuition.library",0L))){
exit(20L);
}
if (argc == 0 && WBenchMsg->sm_NumArgs >1L) {
wba = WBenchMsg->sm_ArgList;
wba++;
arg = wba->wa_Name;
CurrentDir(wba->wa_Lock);
}
else if(argc == 2)
arg = argv[1];
else {
#ifdef VERBOSE
Write(STD,"usage: pref preference_file\n pref *\n",42L);
#else
DisplayBeep(0L);
#endif
exit(20);
}
if ((strcmp(arg,"standard") == 0) || (strcmp(arg,"*") == 0)) {
arg = last_saved;
#ifdef VERBOSE
Write(STD,"preferences reset to last saved\n",32L);
#endif
}
if ((InFile = Open(arg, MODE_OLDFILE)) == NULL){
#ifdef VERBOSE
Write(STD,"Cannot open input file\n",23L);
#else
DisplayBeep(0L);
#endif
exit(20);
}
ReadLen = Read(InFile,PrefBuff,MAX_BUFF);
Close(InFile);
if (ReadLen == 232)
SetPrefs((struct Preferences *)PrefBuff,ReadLen,INFORM);
else {
#ifdef VERBOSE
Write(STD,"Not a preferences file\n",23L);
#else
DisplayBeep(0L);
#endif
}
CloseLibrary(IntuitionBase);
}