-
Notifications
You must be signed in to change notification settings - Fork 0
/
Preferences.c
executable file
·243 lines (228 loc) · 7.68 KB
/
Preferences.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/*
* Preferences.c - Contains all Preferences-related Routines
*/
#include <Fame/fameDoorProto.h>
#include <proto/utility.h>
#include <utility/utility.h>
#include "global_defines.h"
#include "struct_ex.h"
#include "proto.h"
void ReadSettings(void);
static long CheckTheLine(char *); // Checks for required keywords in the current line
static void ReadAllOther(void); // Reads out the FAME Settings
static char *checkarray[MAX_CHECK]={"ARJ_PATH","DMS_PATH","EXE_PATH","LHA_PATH",
"LZX_PATH","ZIP_PATH","GUIDE_PATH","SHRINK_PATH",
"WARP_PATH","ZOOM_PATH","ZOO_PATH","DMS_FILEID_PATH",
"EXE_FILEID_PATH","HTML_PATH","RAR_PATH","TGZ_PATH",
"TEMP_PATH","ALLOW_ARCHIVES","WRITE_CALLERSLOG",
"DOWNLOAD_LEVEL","ONLY_CHECK","SYSOP_VIEWLEVEL",
"USE_ASL_REQUESTER"};
/*
* ReadSettings() - Get's all informations out of mega-view.cfg. The cfg-file
* doesn't have to be in a special format, this routine gets
* all infos via ReadArgs() and is in this case very flexible.
*/
void ReadSettings(void)
{
BPTR prefspointer=NULL;
char mybuf[256],dummy[200];
long retvar=NULL,myarray[1]={0L},mydummy=NULL;
struct RDArgs *myargs=NULL;
struct CSource mysource;
*mybuf='\0';*dummy='\0';
if(!(prefspointer=Open("FAME:ExternEnv/Doors/mEGA-vIEW.cfg",MODE_OLDFILE))) wb("\n\r[37mUnable to open preferences (FAME:ExternEnv/Doors/mEGA-vIEW.cfg) !");
if(!(myargs=AllocDosObject(DOS_RDARGS, NULL)))
{
Close(prefspointer); prefspointer=NULL;
wb(NO_MEM);
}
*mybuf='\0';
while(FGets(prefspointer,mybuf,255))
{
retvar=CheckTheLine(mybuf);
if(retvar<0)
{
*mybuf='\0';*mytemp1='\0';
continue;
}
mysource.CS_Buffer=mybuf;
mysource.CS_Length=strlen(mybuf);
mysource.CS_CurChr=0;
myargs->RDA_Source=mysource;
myargs->RDA_Flags=RDAF_NOPROMPT;
*mytemp1='\0';
strcpy(mytemp1,checkarray[retvar]);
switch(retvar)
{
case PREFS_DL_LEVEL:
case PREFS_ONLY_CHECK:
case PREFS_SYSVIEW_LEVEL: strcat(mytemp1,"/N");
break;
}
if(!(myargs=ReadArgs(mytemp1,myarray,myargs)))
{
Close(prefspointer);prefspointer=NULL;
FreeDosObject(DOS_RDARGS,myargs);
PutStringFormat("\n\r[37mCONFIG-ERROR: Entry [35m%s[37m has a wrong value !!!\n\n\rDOS-Error: [32m%ld [37m - ",checkarray[retvar],IoErr());
Fault(IoErr(),NULL,mytemp1,MAX_BUF-1);
wb(mytemp1);
}
switch(retvar)
{
case PREFS_WRITE_CLOG:
case PREFS_ALLOWARCHIVES:
case PREFS_USE_ASL: SPrintf(dummy,"%s",myarray[0]);
if(!Stricmp(dummy,"Yes"))
{
switch(retvar)
{
case PREFS_ALLOWARCHIVES: MyPrefs->MV_Switches |= BITDEF_ALLOWARCHIVES;
break;
case PREFS_WRITE_CLOG: MyPrefs->MV_Switches |= BITDEF_WRITE_CLOG;
break;
case PREFS_USE_ASL: GetCommand("",0,0,0,SR_LogonType);
if((MyFAMEDoorMsg->fdom_Data2!=3) && (ASLBase)) MyPrefs->MV_Switches |= BITDEF_USE_ASL;
break;
}
}
FreeArgs(myargs);
break;
case PREFS_DL_LEVEL:
case PREFS_ONLY_CHECK:
case PREFS_SYSVIEW_LEVEL: mydummy=*(LONG *)myarray[0];
if(mydummy<1)
{
Close(prefspointer);prefspointer=NULL;
FreeDosObject(DOS_RDARGS,myargs);
PutStringFormat("\n\r[37mCONFIG-ERROR: [35m%s[37m must be set to a value greater than Zero !!",checkarray[retvar]);
wb("");
}
switch(retvar)
{
case PREFS_DL_LEVEL: MyPrefs->MV_DL_Level=mydummy;
break;
case PREFS_ONLY_CHECK: MyPrefs->MV_Check=mydummy;
break;
case PREFS_SYSVIEW_LEVEL: MyPrefs->MV_Sysop=mydummy;
break;
}
FreeArgs(myargs);
break;
default: if(retvar<MAX_ARRAY) SPrintf(MyPrefs->MV_Pathes[retvar],"%s",myarray[0]);
FreeArgs(myargs);
break;
}
}
Close(prefspointer);prefspointer=NULL;
FreeDosObject(DOS_RDARGS,myargs);
ReadAllOther(); // Configure meGA-vIEW now...
FAMEStrCopy(MyPrefs->MV_Pathes[PREFS_TEMPDIR],ActTempDir,255);
*mybuf='\0';
SPrintf(mybuf,"MV.%ld",node);
AddPart(ActTempDir,mybuf,255); // Built Temp Dir for general usage
*tempfile='\0';
SPrintf(tempfile,"MV_TEMP.%ld",node);
}
/*
* Checks *testline for a known keyword, returns offset for checkarray or
* -1 to indicate that the current line is no config line !
*/
static long CheckTheLine(char *testline)
{
register long lv=NULL;
for(lv=0;lv<MAX_CHECK;lv++)
{
if(!(Strnicmp(testline,checkarray[lv],strlen(checkarray[lv]))))
{
return(lv);
}
}
return(-1);
}
/*
* Reads the rest of the configuration parameters out of FAME structs. If global
* Viewing is enabled for the current user, mEGA-vIEW will load in ALL dl-pathes
* of ALL conferences to search in all pathes. If this flag is disabled, only all
* pathes of the current conference will be scanned.
*/
static void ReadAllOther(void)
{
BPTR dlptr=NULL;
long totalconfs=NULL,lv=NULL;
char buffer[256],extbuf[12];
GetCommand("",0,0,0,NR_AccessLevel);
if(MyFAMEDoorMsg->fdom_Data2>=MyPrefs->MV_Sysop) pathlen=LEN_SYSOP; // SysOpAccess
else pathlen=LEN_NORMAL;
if(MyFAMEDoorMsg->fdom_Data2>=MyPrefs->MV_Check)
{
strcpy(viewtest,"view");
MyPrefs->MV_Switches |= BITDEF_ALLOW_VIEW; // Viewing is allowed
}
else
{
strcpy(viewtest,"test"); // Only test arcs
}
GetCommand("",0,0,0,NR_NumLines);
maxlines=MyFAMEDoorMsg->fdom_Data2-1; // Max Lines to view
GetCommand("",0,0,0,NR_ViewFlag);
if(MyFAMEDoorMsg->fdom_Data2)
{
MV_FLAGS |= BITDEF_GLOBVIEW;
GetCommand("",0,0,0,SR_NumberOfConfs);
totalconfs=MyFAMEDoorMsg->fdom_Data2;
}
else
{
MV_FLAGS &= ~BITDEF_GLOBVIEW;
totalconfs=1;
}
*mytemp1='\0';
GetCommand(mytemp1,0,0,0,AR_DownloadPathI); // Get 1. DL Path
if(!*mytemp1) wb("[37mNo Download-Path defined, please report to SysOp !!!\n\r[m");
if(AddDlPath(mytemp1)==FALSE) wb(NO_MEM);
*mytemp1='\0';
GetCommand(mytemp1,0,0,0,AR_AdditioDlPaths);
if(*mytemp1)
{
if(dlptr=Open(mytemp1,MODE_OLDFILE))
{
*mytemp1='\0';
while(FGets(dlptr,mytemp1,MAX_BUF-1))
{
mytemp1[strlen(mytemp1)-1]='\0';
if(AddDlPath(mytemp1)==FALSE)
{
Close(dlptr);dlptr=NULL;
wb(NO_MEM);
}
}
Close(dlptr);dlptr=NULL;
}
}
et1=NULL; et2=NULL;
if(!(dlptr=Open("FAME:ExternEnv/Doors/mEGA-vIEW_EXT.CFG",MODE_OLDFILE))) return;
*mytemp1='\0';
while(FGets(dlptr,mytemp1,255))
{
lv=NULL;
mytemp1[strlen(mytemp1)-1]='\0';
while(mytemp1[lv]!=' ')
{
extbuf[lv]=mytemp1[lv];
lv++;
}
extbuf[lv]='\0';
while(mytemp1[lv]==' ') lv++;
FAMEStrMid(mytemp1,buffer,lv+1,-1);
if(AddFileType(extbuf,buffer)==FALSE)
{
Close(dlptr);dlptr=NULL;
wb(NO_MEM);
}
}
Close(dlptr);dlptr=NULL;
}
/*
* Global Viewing Support - This function loads in ALL available conferences for the current user and puts all
* download pathes into a global structure ready to use.
*/