-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWBStartup.c
206 lines (176 loc) · 5.54 KB
/
WBStartup.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
/* 3dPlot - 29-1-94 SSi - WorkbenchStartup - Auswertung der Tooltypes */
/* erkannte Tooltypes:
*
* DIR=<Pfad> ; Pfad für Laden/Speichern setzen
* INTERLACE=<ON/OFF> ; Interlace-Schalter (zur Kompatibilität)
* HELP=<Filename> ; Help-Textfile (ASCII)
* LANGUAGE=<Filename> ; zu verwendender Sprachfile (s.Languages/(...).lng)
* SETOPT=<Option(s)> ; setzt Optionen
* CLROPT=<OPtion(s)> ; löscht Optionen
* RESETFNCT=<Filename> ; setzt Filenamen der Resetfnct (Default:"Reset.fnct")
* PREFS=<Filename> ;Filenamen des .3dp Files
* ICONS=<Pfad> ; Pfad für Icons (Default: ProgHomeDir)
*/
char *TOOLTYPES="\
DIR=<Path> sets up path for load/save operations\n\
INTERLACE=<ON/OFF> chooses screen mode (obsolete - don't use!)\n\
HELP=<Filename> redefines help file\n\
LANGUAGE=<Filename> defines language infofile\n\
BACKUP=<Filename> defines backup file\n\
SETOPT=<Option(s)> activates one or more options(see below)\n\
CLROPT=<Option(s)> deactivates one or more options(see below)\n\
RESETFNCT=<Filename> redefines reset function file\n\
PREFS=<Filename> defines custom prefs file\n\
ICONS=<Path> redefines directory to take icons from\n\
\n\
Options for SETOPT/CLROPT: ACR, TIME, LOWPRI, APS, AWH, BAK, WB, RG3D\n";
#include "Plot.h"
#include <workbench/startup.h>
#include <proto/dos.h>
#include <proto/icon.h>
#include <string.h>
/* Globale Parameter -------------------------------------------------------- */
extern char *_Filename; /* Filename für Disk.c */
extern char *HelpFile;
extern char *Language; /* bevorz. Languagefilename */
extern short Options;
struct WBStartup *argmsg;
struct WBArg *wbarg;
extern char BackupFileName[];
char Reset_fnct_Name[80]="Reset.fnct";
char Prefs_1st_Name[80]="";
extern BPTR HomeDir_Lock; /* Homedir Lock des Programms (needs not to be UnLock()-ed */
BPTR DefaultDir_Lock=0; /* needs not to be UnLock()-ed */
char *Default_fnct_Name=0; /* needs not to be free()-ed */
BPTR FnctDir_Lock=0; /* gets UnLock()-ed in CloseAll() */
char Icons_Dir[520];
/* -------------------------------------------------------------------------- */
void ComputeWBMsg(int argc, char **argv) /* wertet die Übergabeparam. aus */
{ /* und benutzt gegf. die Tooltypes */
BPTR OldCD;
struct DiskObject *dobj=0;
char **toolarray=0;
char *s;
if (!argc)
{
if (!(argmsg=(struct WBStartup *)argv)) return;
}
if (argmsg)
{
if (!(wbarg=argmsg->sm_ArgList)) return;
OldCD=CurrentDir(wbarg->wa_Lock);
if (dobj=GetDiskObject(wbarg->wa_Name)) /* .info laden */
{
toolarray=(char **)dobj->do_ToolTypes;
}
}
else
{
if (argc==1)
{
if (dobj=GetDiskObject(argv[0])) /* .info laden */
{
toolarray=(char **)dobj->do_ToolTypes;
}
}
else toolarray=&argv[1];
}
if (toolarray) /* Tooltypes auswerten - - - - - - - - - - - - - - - - */
{
if (s=(char *)FindToolType(toolarray,"DIR"))
{
FnctDir_Lock=Lock(s,ACCESS_READ);
}
if (s=(char *)FindToolType(toolarray,"LANGUAGE"))
{
Language=getstr(s);
}
else Language=0;
if (s=(char *)FindToolType(toolarray,"HELP"))
{
HelpFile=getstr(s);
}
else HelpFile=0;
if (s=(char *)FindToolType(toolarray,"INTERLACE"))
{
Options=(Options&~OPT_INTERLACE)|(!stricmp(s,"ON")?OPT_INTERLACE:0);
}
if (s=(char *)FindToolType(toolarray,"BACKUP"))
{
strncpy(BackupFileName,s,559);
}
else
{
if (FnctDir_Lock) NameFromLock(FnctDir_Lock,BackupFileName,559);
strmfp(BackupFileName,BackupFileName,".bak");
}
if (s=(char *)FindToolType(toolarray,"CLROPT"))
{
if (MatchToolValue(s,"ACR")) Options&=~OPT_ACR;
if (MatchToolValue(s,"TIME")) Options&=~OPT_Time;
if (MatchToolValue(s,"LOWPRI")) Options&=~OPT_LowPri;
if (MatchToolValue(s,"APS")) Options&=~OPT_APS;
if (MatchToolValue(s,"AWH")) Options&=~OPT_AWH;
if (MatchToolValue(s,"BAK")) Options&=~OPT_Backup;
if (MatchToolValue(s,"WB")) Options&=~OPT_WorkBench;
if (MatchToolValue(s,"RG3D")) Options&=~OPT_RG3d;
}
if (s=(char *)FindToolType(toolarray,"SETOPT"))
{
if (MatchToolValue(s,"ACR")) Options|=OPT_ACR;
if (MatchToolValue(s,"TIME")) Options|=OPT_Time;
if (MatchToolValue(s,"LOWPRI")) Options|=OPT_LowPri;
if (MatchToolValue(s,"APS")) Options|=OPT_APS;
if (MatchToolValue(s,"AWH")) Options|=OPT_AWH;
if (MatchToolValue(s,"BAK")) Options|=OPT_Backup;
if (MatchToolValue(s,"WB")) Options|=OPT_WorkBench;
if (MatchToolValue(s,"RG3D")) Options|=OPT_RG3d;
}
if (s=(char *)FindToolType(toolarray,"RESETFNCT"))
{
strncpy(Reset_fnct_Name,s,79);
}
if (s=(char *)FindToolType(toolarray,"PREFS"))
{
strncpy(Prefs_1st_Name,s,79);
}
if (s=(char *)FindToolType(toolarray,"ICONS"))
{
strncpy(Icons_Dir,s,519);
}
else Icons_Dir[0]=0;
}
if (argmsg) /* Anfangsfunktion ggf. setzen */
{
if (argmsg->sm_NumArgs>=2)
{
if (wbarg[1].wa_Name)
{
DefaultDir_Lock=wbarg[1].wa_Lock;
_Filename=Default_fnct_Name=wbarg[1].wa_Name;
}
}
}
if (dobj) FreeDiskObject(dobj);
if (argmsg) CurrentDir(OldCD);
LoadLanguage();
if (!HelpFile) HelpFile=l[87];
}
/* -------------------------------------------------------------------------- */
/* CreateIcon() produziert für einen File dann ein Icon,
* wenn im Programhomedir ein Icon mit dem Namen "<Ext>.info" existiert,
* wobei <Ext> die Extension des Filenamens ist.
*/
void CreateIcon(char *Name) /* s.o. (CD=Programhomedir) */
{
struct DiskObject *dobj;
char ext[10];
static char buf[530];
stcgfe(ext,Name);
strmfp(buf,Icons_Dir,ext);
if (dobj=GetDiskObject(buf))
{
PutDiskObject(Name,dobj);
FreeDiskObject(dobj);
}
}