2 Copyright © 2006-2008, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
10 #include <proto/exec.h>
11 #include <proto/icon.h>
12 #include <proto/intuition.h>
13 #include <proto/graphics.h>
15 #include <dos/filesystem.h>
23 #define MAX_LOCK_LEN 100 /* Max. length of a lock string */
24 #define MAX_STR_LEN 200 /* Max. string length for misc stuff */
26 #define MAX(x,y) ((x) > (y) ? (x) : (y))
27 #define MIN(x,y) ((x) < (y) ? (x) : (y))
30 #define LVO_CreateDir ( -20 * LIB_VECTSIZE)
31 #define LVO_CurrentDir ( -21 * LIB_VECTSIZE)
32 #define LVO_DeleteFile ( -12 * LIB_VECTSIZE)
33 #define LVO_DeleteVar ( -152 * LIB_VECTSIZE)
34 #define LVO_Execute ( -37 * LIB_VECTSIZE)
35 #define LVO_FindVar ( -153 * LIB_VECTSIZE)
36 #define LVO_GetVar ( -151 * LIB_VECTSIZE)
37 #define LVO_LoadSeg ( -25 * LIB_VECTSIZE)
38 #define LVO_Lock ( -14 * LIB_VECTSIZE)
39 #define LVO_MakeLink ( -74 * LIB_VECTSIZE)
40 #define LVO_NewLoadSeg ( -128 * LIB_VECTSIZE)
41 #define LVO_Open ( -5 * LIB_VECTSIZE)
42 #define LVO_Rename ( -13 * LIB_VECTSIZE)
43 #define LVO_RunCommand ( -84 * LIB_VECTSIZE)
44 #define LVO_SetVar ( -150 * LIB_VECTSIZE)
45 #define LVO_SystemTagList ( -101 * LIB_VECTSIZE)
48 #define LVO_FindPort ( -65 * LIB_VECTSIZE)
49 #define LVO_FindResident ( -16 * LIB_VECTSIZE)
50 #define LVO_FindSemaphore ( -99 * LIB_VECTSIZE)
51 #define LVO_FindTask ( -49 * LIB_VECTSIZE)
52 #define LVO_OpenDevice ( -74 * LIB_VECTSIZE)
53 #define LVO_OpenLibrary ( -92 * LIB_VECTSIZE)
54 #define LVO_OpenResource ( -83 * LIB_VECTSIZE)
57 #define LVO_LockPubScreen ( -85 * LIB_VECTSIZE)
60 #define LVO_OpenFont ( -12 * LIB_VECTSIZE)
63 #define LVO_FindToolType ( -16 * LIB_VECTSIZE)
64 #define LVO_MatchToolValue ( -17 * LIB_VECTSIZE)
66 struct Library
*libbases
[LIB_last
];
78 } patches
[PATCH_last
] =
80 // must be in same order as in enum in patches.h
81 {NULL
, NULL
, LIB_Dos
, 0, LVO_CreateDir
, FALSE
},
82 {NULL
, NULL
, LIB_Dos
, 0, LVO_CurrentDir
, FALSE
},
83 {NULL
, NULL
, LIB_Dos
, 0, LVO_DeleteFile
, FALSE
},
84 {NULL
, NULL
, LIB_Dos
, 0, LVO_DeleteVar
, FALSE
},
85 {NULL
, NULL
, LIB_Dos
, 0, LVO_Execute
, FALSE
},
86 {NULL
, NULL
, LIB_Dos
, 0, LVO_FindVar
, FALSE
},
87 {NULL
, NULL
, LIB_Dos
, 0, LVO_GetVar
, FALSE
},
88 {NULL
, NULL
, LIB_Dos
, 0, LVO_LoadSeg
, FALSE
},
89 {NULL
, NULL
, LIB_Dos
, 0, LVO_Lock
, FALSE
},
90 {NULL
, NULL
, LIB_Dos
, 0, LVO_MakeLink
, FALSE
},
91 {NULL
, NULL
, LIB_Dos
, 0, LVO_NewLoadSeg
, FALSE
},
92 {NULL
, NULL
, LIB_Dos
, 0, LVO_Open
, FALSE
},
93 {NULL
, NULL
, LIB_Dos
, 0, LVO_Rename
, FALSE
},
94 {NULL
, NULL
, LIB_Dos
, 0, LVO_RunCommand
, FALSE
},
95 {NULL
, NULL
, LIB_Dos
, 0, LVO_SetVar
, FALSE
},
96 {NULL
, NULL
, LIB_Dos
, 0, LVO_SystemTagList
, FALSE
},
97 {NULL
, NULL
, LIB_Exec
, 0, LVO_FindPort
, FALSE
},
98 {NULL
, NULL
, LIB_Exec
, 0, LVO_FindResident
, FALSE
},
99 {NULL
, NULL
, LIB_Exec
, 0, LVO_FindSemaphore
, FALSE
},
100 {NULL
, NULL
, LIB_Exec
, 0, LVO_FindTask
, FALSE
},
101 {NULL
, NULL
, LIB_Exec
, 0, LVO_OpenDevice
, FALSE
},
102 {NULL
, NULL
, LIB_Exec
, 0, LVO_OpenLibrary
, FALSE
},
103 {NULL
, NULL
, LIB_Exec
, 0, LVO_OpenResource
, FALSE
},
104 {NULL
, NULL
, LIB_Intuition
, 0, LVO_LockPubScreen
, FALSE
},
105 {NULL
, NULL
, LIB_Graphics
, 0, LVO_OpenFont
, FALSE
},
106 {NULL
, NULL
, LIB_Icon
, 0, LVO_FindToolType
, FALSE
},
107 {NULL
, NULL
, LIB_Icon
, 0, LVO_MatchToolValue
, FALSE
},
110 //static char *MyNameFromLock(BPTR lock, char *filename, char *buf, int maxlen);
111 //static void GetVolName(BPTR lock, char *buf, int maxlen);
113 // ----------------------------------------------------------------------------------
115 AROS_UFH2(BPTR
, New_CreateDir
,
116 AROS_UFHA(CONST_STRPTR
, name
, D1
),
117 AROS_UFHA(APTR
, libbase
, A6
)
122 // result is exclusive lock or NULL
123 BPTR result
= AROS_UFC2(BPTR
, patches
[PATCH_CreateDir
].oldfunc
,
124 AROS_UFCA(CONST_STRPTR
, name
, D1
),
125 AROS_UFCA(APTR
, libbase
, A6
));
127 if (patches
[PATCH_CreateDir
].enabled
)
129 main_output("CreateDir", name
, 0, (LONG
)result
, TRUE
);
137 // ----------------------------------------------------------------------------------
139 AROS_UFH2(BPTR
, New_CurrentDir
,
140 AROS_UFHA(BPTR
, lock
, D1
),
141 AROS_UFHA(APTR
, libbase
, A6
))
144 //char lockbuf[MAX_LOCK_LEN+1];
145 char *lockpath
= "?";
147 // returns lock to old directory, 0 means boot filesystem
148 BPTR result
= AROS_UFC2(BPTR
, patches
[PATCH_CurrentDir
].oldfunc
,
149 AROS_UFCA(BPTR
, lock
, D1
),
150 AROS_UFCA(APTR
, libbase
, A6
));
152 if (patches
[PATCH_CurrentDir
].enabled
)
155 struct FileInfoBlock
*fib
= NULL
;
158 fib
= AllocDosObject(DOS_FIB
, NULL
);
161 if (Examine(lock
, fib
))
163 lockpath
= fib
->fib_FileName
;
167 main_output("CurrentDir", lockpath
, 0, TRUE
, TRUE
);
169 if (fib
) FreeDosObject(DOS_FIB
, fib
);
178 // ----------------------------------------------------------------------------------
180 AROS_UFH2(BOOL
, New_DeleteFile
,
181 AROS_UFHA(CONST_STRPTR
, name
, D1
),
182 AROS_UFHA(APTR
, libbase
, A6
))
186 // true means deleting was OK
187 BOOL result
= AROS_UFC2(BOOL
, patches
[PATCH_DeleteFile
].oldfunc
,
188 AROS_UFCA(CONST_STRPTR
, name
, D1
),
189 AROS_UFCA(APTR
, libbase
, A6
));
191 if (patches
[PATCH_DeleteFile
].enabled
)
193 main_output("Delete", name
, 0, result
, TRUE
);
201 // ----------------------------------------------------------------------------------
203 AROS_UFH3(LONG
, New_DeleteVar
,
204 AROS_UFHA(CONST_STRPTR
, name
, D1
),
205 AROS_UFHA(ULONG
, flags
, D2
),
206 AROS_UFHA(APTR
, libbase
, A6
))
210 // true means variable was deleted
211 LONG result
= AROS_UFC3(LONG
, patches
[PATCH_DeleteVar
].oldfunc
,
212 AROS_UFCA(CONST_STRPTR
, name
, D1
),
213 AROS_UFCA(ULONG
, flags
, D2
),
214 AROS_UFCA(APTR
, libbase
, A6
));
216 if (patches
[PATCH_DeleteVar
].enabled
)
219 if (flags
& GVF_GLOBAL_ONLY
) opt
= MSG(MSG_GLOBAL
);
220 else if ((flags
& 7) == LV_VAR
) opt
= MSG(MSG_LOCAL
);
221 else if ((flags
& 7) == LV_ALIAS
) opt
= MSG(MSG_ALIAS
);
222 else opt
= MSG(MSG_UNKNOWN
);
224 main_output("DeleteVar", name
, opt
, result
, TRUE
);
232 // ----------------------------------------------------------------------------------
234 AROS_UFH4(LONG
, New_Execute
,
235 AROS_UFHA(STRPTR
, string
, D1
),
236 AROS_UFHA(BPTR
, input
, D2
),
237 AROS_UFHA(BPTR
, output
, D3
),
238 AROS_UFHA(APTR
, libbase
, A6
))
242 // true means command could be started
243 LONG result
= AROS_UFC4(LONG
, patches
[PATCH_Execute
].oldfunc
,
244 AROS_UFCA(STRPTR
, string
, D1
),
245 AROS_UFCA(BPTR
, input
, D2
),
246 AROS_UFCA(BPTR
, output
, D3
),
247 AROS_UFCA(APTR
, libbase
, A6
));
249 if (patches
[PATCH_Execute
].enabled
)
251 main_output("Execute", string
,0 , result
, TRUE
);
259 // ----------------------------------------------------------------------------------
261 AROS_UFH3(struct LocalVar
*, New_FindVar
,
262 AROS_UFHA(CONST_STRPTR
, name
, D1
),
263 AROS_UFHA(ULONG
, type
, D2
),
264 AROS_UFHA(APTR
, libbase
, A6
))
268 // NULL means variable not found
269 struct LocalVar
*result
= AROS_UFC3(struct LocalVar
*, patches
[PATCH_FindVar
].oldfunc
,
270 AROS_UFCA(CONST_STRPTR
, name
, D1
),
271 AROS_UFCA(ULONG
, type
, D2
),
272 AROS_UFCA(APTR
, libbase
, A6
));
274 if (patches
[PATCH_FindVar
].enabled
)
277 if ((type
& 7) == LV_VAR
) opt
= MSG(MSG_LOCAL
);
278 else if ((type
& 7) == LV_ALIAS
) opt
= MSG(MSG_ALIAS
);
279 else opt
= MSG(MSG_UNKNOWN
);
281 main_output("FindVar", name
, opt
, (LONG
)result
, TRUE
);
289 // ----------------------------------------------------------------------------------
291 AROS_UFH5(LONG
, New_GetVar
,
292 AROS_UFHA(CONST_STRPTR
, name
, D1
),
293 AROS_UFHA(STRPTR
, buffer
, D2
),
294 AROS_UFHA(LONG
, size
, D3
),
295 AROS_UFHA(LONG
, flags
, D4
),
296 AROS_UFHA(APTR
, libbase
, A6
))
300 // -1 means variable not defined
301 LONG result
= AROS_UFC5(LONG
, patches
[PATCH_GetVar
].oldfunc
,
302 AROS_UFCA(CONST_STRPTR
, name
, D1
),
303 AROS_UFCA(STRPTR
, buffer
, D2
),
304 AROS_UFCA(LONG
, size
, D3
),
305 AROS_UFCA(LONG
, flags
, D4
),
306 AROS_UFCA(APTR
, libbase
, A6
));
308 if (patches
[PATCH_GetVar
].enabled
)
311 if (flags
& GVF_GLOBAL_ONLY
) opt
= MSG(MSG_GLOBAL
);
312 else if ((flags
& 7) == LV_ALIAS
) opt
= MSG(MSG_ALIAS
);
313 else if (flags
& GVF_LOCAL_ONLY
) opt
= MSG(MSG_LOCAL
);
314 else opt
= MSG(MSG_ANY
);
316 main_output("GetVar", name
, opt
, result
!= -1, TRUE
);
324 // ----------------------------------------------------------------------------------
326 AROS_UFH2(BPTR
, New_LoadSeg
,
327 AROS_UFHA(CONST_STRPTR
, name
, D1
),
328 AROS_UFHA(APTR
, libbase
, A6
))
332 // 0 means load failed
333 BPTR result
= AROS_UFC2(BPTR
, patches
[PATCH_LoadSeg
].oldfunc
,
334 AROS_UFCA(CONST_STRPTR
, name
, D1
),
335 AROS_UFCA(APTR
, libbase
, A6
));
337 if (patches
[PATCH_LoadSeg
].enabled
)
339 main_output("LoadSeg", name
, 0, (LONG
)result
, TRUE
);
347 // ----------------------------------------------------------------------------------
349 AROS_UFH3(BPTR
, New_Lock
,
350 AROS_UFHA(CONST_STRPTR
, name
, D1
),
351 AROS_UFHA(LONG
, accessMode
, D2
),
352 AROS_UFHA(APTR
, libbase
, A6
))
357 BPTR result
= AROS_UFC3(BPTR
, patches
[PATCH_Lock
].oldfunc
,
358 AROS_UFCA(CONST_STRPTR
, name
, D1
),
359 AROS_UFCA(LONG
, accessMode
, D2
),
360 AROS_UFCA(APTR
, libbase
, A6
));
362 if (patches
[PATCH_Lock
].enabled
)
365 if (accessMode
== ACCESS_READ
) opt
= MSG(MSG_READ
);
366 else if (accessMode
== ACCESS_WRITE
) opt
= MSG(MSG_WRITE
);
367 else opt
= MSG(MSG_READ_ASK
);
369 CONST_STRPTR curname
= name
;
374 else if ( ! setup
.showPaths
&& *curname
== '\0')
379 main_output("Lock", curname
, opt
, (LONG
)result
, TRUE
);
387 // ----------------------------------------------------------------------------------
389 AROS_UFH4(LONG
, New_MakeLink
,
390 AROS_UFHA(STRPTR
, name
, D1
),
391 AROS_UFHA(APTR
, dest
, D2
),
392 AROS_UFHA(LONG
, soft
, D3
),
393 AROS_UFHA(APTR
, libbase
, A6
))
398 LONG result
= AROS_UFC4(LONG
, patches
[PATCH_MakeLink
].oldfunc
,
399 AROS_UFCA(STRPTR
, name
, D1
),
400 AROS_UFCA(APTR
, dest
, D2
),
401 AROS_UFCA(LONG
, soft
, D3
),
402 AROS_UFCA(APTR
, libbase
, A6
));
404 if (patches
[PATCH_MakeLink
].enabled
)
406 //struct Process *myproc = (struct Process *)SysBase->ThisTask;
409 if (soft
) opt
= "Softlink";
410 else opt
= "Hardlink";
412 //FIXME: MyNameFromLock crashes
415 int len
= strlen(name
);
416 char namestr
[MAX_STR_LEN
+ 1];
417 if (len
>= MAX_STR_LEN
) {
418 strncpy(namestr
, name
, MAX_STR_LEN
);
419 namestr
[MAX_STR_LEN
] = 0;
421 if (setup
.showPaths
) {
422 strcpy(namestr
, MyNameFromLock(myproc
->pr_CurrentDir
,
423 name
, namestr
, MAX_STR_LEN
-2));
424 len
= strlen(namestr
);
426 strcpy(namestr
, name
);
428 strcat(namestr
, " --> ");
430 strncat(namestr
, (char *)dest
, MAX_STR_LEN
- len
- 1);
431 namestr
[MAX_STR_LEN
] = 0;
433 strcat(namestr
, MyNameFromLock((BPTR
)dest
, NULL
, namestr
+len
+1,
438 main_output("MakeLink", name
/*namestr */, opt
, result
, TRUE
);
446 // ----------------------------------------------------------------------------------
448 AROS_UFH3(BPTR
, New_NewLoadSeg
,
449 AROS_UFHA(STRPTR
, file
, D1
),
450 AROS_UFHA(struct TagItem
*, tags
, D2
),
451 AROS_UFHA(APTR
, libbase
, A6
))
455 // 0 means load failed
456 BPTR result
= AROS_UFC3(BPTR
, patches
[PATCH_NewLoadSeg
].oldfunc
,
457 AROS_UFCA(STRPTR
, file
, D1
),
458 AROS_UFCA(struct TagItem
*, tags
, D2
),
459 AROS_UFCA(APTR
, libbase
, A6
));
461 if (patches
[PATCH_NewLoadSeg
].enabled
)
463 main_output("NewLoadSeg", file
, 0, (LONG
)result
, TRUE
);
471 // ----------------------------------------------------------------------------------
473 AROS_UFH3 (BPTR
, New_Open
,
474 AROS_UFHA (CONST_STRPTR
, name
, D1
),
475 AROS_UFHA (LONG
, accessMode
, D2
),
476 AROS_UFHA (APTR
, libbase
, A6
))
482 BPTR result
= AROS_UFC3(BPTR
, patches
[PATCH_Open
].oldfunc
,
483 AROS_UFCA (CONST_STRPTR
, name
, D1
),
484 AROS_UFCA (LONG
, accessMode
, D2
),
485 AROS_UFCA (APTR
, libbase
, A6
));
487 if (patches
[PATCH_Open
].enabled
)
489 CONST_STRPTR opt
= NULL
;
491 if (accessMode
== MODE_OLDFILE
) opt
= MSG(MSG_READ
);
492 else if (accessMode
== MODE_NEWFILE
) opt
= MSG(MSG_WRITE
);
493 else if (accessMode
== MODE_READWRITE
) opt
= MSG(MSG_MODIFY
);
494 else if (accessMode
& (FMF_READ
|FMF_WRITE
|FMF_APPEND
|FMF_CREATE
))
496 sprintf(optstr
, "FMF %c%c%c%c",
497 (accessMode
& FMF_READ
) ? 'R' : '_',
498 (accessMode
& FMF_WRITE
) ? 'W' : '_',
499 (accessMode
& FMF_APPEND
) ? 'A' : '_',
500 (accessMode
& FMF_CREATE
) ? 'C' : '_');
502 else opt
= MSG(MSG_UNKNOWN
);
504 main_output("Open", name
, opt
? opt
: (STRPTR
)optstr
, (LONG
)result
, TRUE
);
512 // ----------------------------------------------------------------------------------
514 AROS_UFH3(LONG
, New_Rename
,
515 AROS_UFHA(CONST_STRPTR
, oldName
, D1
),
516 AROS_UFHA(CONST_STRPTR
, newName
, D2
),
517 AROS_UFHA(APTR
, libbase
, A6
))
522 LONG result
= AROS_UFC3(LONG
, patches
[PATCH_Rename
].oldfunc
,
523 AROS_UFCA(CONST_STRPTR
, oldName
, D1
),
524 AROS_UFCA(CONST_STRPTR
, newName
, D2
),
525 AROS_UFCA(APTR
, libbase
, A6
));
527 if (patches
[PATCH_Rename
].enabled
)
529 main_output("Rename", oldName
, 0, result
, FALSE
);
530 main_output("to -->", newName
, 0, result
, TRUE
);
538 // ----------------------------------------------------------------------------------
540 AROS_UFH5(LONG
, New_RunCommand
,
541 AROS_UFHA(BPTR
, segList
, D1
),
542 AROS_UFHA(ULONG
, stacksize
, D2
),
543 AROS_UFHA(STRPTR
, argptr
, D3
),
544 AROS_UFHA(ULONG
, argsize
, D4
),
545 AROS_UFHA(APTR
, libbase
, A6
))
550 LONG result
= AROS_UFC5(LONG
, patches
[PATCH_RunCommand
].oldfunc
,
551 AROS_UFCA(BPTR
, segList
, D1
),
552 AROS_UFCA(ULONG
, stacksize
, D2
),
553 AROS_UFCA(STRPTR
, argptr
, D3
),
554 AROS_UFCA(ULONG
, argsize
, D4
),
555 AROS_UFCA(APTR
, libbase
, A6
));
557 if (patches
[PATCH_RunCommand
].enabled
)
559 char argstr
[MAX_STR_LEN
+ 1];
561 for (pos
= 0; pos
< MAX_STR_LEN
&& argptr
[pos
] != 0 ; pos
++)
563 if (argptr
[pos
] == '\n')
566 argstr
[pos
] = argptr
[pos
];
570 main_output("RunCommand", argstr
, 0, result
!= -1, TRUE
);
578 // ----------------------------------------------------------------------------------
580 AROS_UFH5(BOOL
, New_SetVar
,
581 AROS_UFHA(CONST_STRPTR
, name
, D1
),
582 AROS_UFHA(CONST_STRPTR
, buffer
, D2
),
583 AROS_UFHA(LONG
, size
, D3
),
584 AROS_UFHA(LONG
, flags
, D4
),
585 AROS_UFHA(void*, libbase
, A6
))
589 BOOL result
= AROS_UFC5(BOOL
, patches
[PATCH_SetVar
].oldfunc
,
590 AROS_UFCA(CONST_STRPTR
, name
, D1
),
591 AROS_UFCA(CONST_STRPTR
, buffer
, D2
),
592 AROS_UFCA(LONG
, size
, D3
),
593 AROS_UFCA(LONG
, flags
, D4
),
594 AROS_UFCA(void*, libbase
, A6
));
596 if (patches
[PATCH_SetVar
].enabled
)
599 char varstr
[MAX_STR_LEN
+ 1];
602 if (flags
& GVF_GLOBAL_ONLY
) opt
= MSG(MSG_GLOBAL
);
603 else if ((flags
& 7) == LV_VAR
) opt
= MSG(MSG_LOCAL
);
604 else if ((flags
& 7) == LV_ALIAS
) opt
= MSG(MSG_ALIAS
);
605 else opt
= MSG(MSG_UNKNOWN
);
608 * Now create a string that looks like "Variable=Value"
610 * We go to some pains to ensure we don't overwrite our
614 if (vlen
> (MAX_STR_LEN
-1)) {
615 strncpy(varstr
, name
, MAX_STR_LEN
);
616 varstr
[MAX_STR_LEN
] = 0;
618 strcpy(varstr
, name
);
622 vlen
= MIN(vlen
, size
);
624 strncat(varstr
, buffer
, vlen
);
625 varstr
[MAX_STR_LEN
] = 0;
627 main_output("SetVar", varstr
, opt
, result
, TRUE
);
635 // ----------------------------------------------------------------------------------
637 AROS_UFH3(LONG
, New_SystemTagList
,
638 AROS_UFHA(CONST_STRPTR
, command
, D1
),
639 AROS_UFHA(struct TagItem
*, tags
, D2
),
640 AROS_UFHA(APTR
, libbase
, A6
))
645 LONG result
= AROS_UFC3(LONG
, patches
[PATCH_SystemTagList
].oldfunc
,
646 AROS_UFCA(CONST_STRPTR
, command
, D1
),
647 AROS_UFCA(struct TagItem
*, tags
, D2
),
648 AROS_UFCA(APTR
, libbase
, A6
));
650 if (patches
[PATCH_SystemTagList
].enabled
)
653 sprintf(optstr
, "%d", result
);
654 main_output("SystemTagList", command
, optstr
, result
!= -1, TRUE
);
662 // ----------------------------------------------------------------------------------
664 AROS_UFH2(struct MsgPort
*, New_FindPort
,
665 AROS_UFHA(STRPTR
, name
, A1
),
666 AROS_UFHA(APTR
, libbase
, A6
))
671 struct MsgPort
*result
= AROS_UFC2(struct MsgPort
*, patches
[PATCH_FindPort
].oldfunc
,
672 AROS_UFCA(STRPTR
, name
, A1
),
673 AROS_UFCA(APTR
, libbase
, A6
));
675 if (patches
[PATCH_FindPort
].enabled
)
677 main_output("FindPort", name
, 0, (LONG
)result
, TRUE
);
685 // ----------------------------------------------------------------------------------
687 AROS_UFH2(struct Resident
*, New_FindResident
,
688 AROS_UFHA(const UBYTE
*, name
, A1
),
689 AROS_UFHA(APTR
, libbase
, A6
))
694 struct Resident
*result
= AROS_UFC2(struct Resident
*, patches
[PATCH_FindResident
].oldfunc
,
695 AROS_UFCA(const UBYTE
*, name
, A1
),
696 AROS_UFCA(APTR
, libbase
, A6
));
698 if (patches
[PATCH_FindResident
].enabled
)
700 main_output("FindResident", name
, 0, (LONG
)result
, TRUE
);
708 // ----------------------------------------------------------------------------------
710 AROS_UFH2(struct SignalSemaphore
*, New_FindSemaphore
,
711 AROS_UFHA(STRPTR
, name
, A1
),
712 AROS_UFHA(APTR
, libbase
, A6
))
717 struct SignalSemaphore
*result
= AROS_UFC2(struct SignalSemaphore
*, patches
[PATCH_FindSemaphore
].oldfunc
,
718 AROS_UFCA(STRPTR
, name
, A1
),
719 AROS_UFCA(APTR
, libbase
, A6
));
721 if (patches
[PATCH_FindSemaphore
].enabled
)
723 main_output("FindSemaphore", name
, 0, (LONG
)result
, TRUE
);
731 // ----------------------------------------------------------------------------------
733 AROS_UFH2(struct Task
*, New_FindTask
,
734 AROS_UFHA(STRPTR
, name
, A1
),
735 AROS_UFHA(APTR
, libbase
, A6
))
740 struct Task
*result
= AROS_UFC2(struct Task
*, patches
[PATCH_FindTask
].oldfunc
,
741 AROS_UFCA(STRPTR
, name
, A1
),
742 AROS_UFCA(APTR
, libbase
, A6
));
744 if (patches
[PATCH_FindTask
].enabled
)
746 main_output("FindTask", name
, 0, (LONG
)result
, TRUE
);
754 // ----------------------------------------------------------------------------------
756 AROS_UFH5(BYTE
, New_OpenDevice
,
757 AROS_UFHA(CONST_STRPTR
, devName
, A0
),
758 AROS_UFHA(ULONG
, unitNumber
, D0
),
759 AROS_UFHA(struct IORequest
*, iORequest
, A1
),
760 AROS_UFHA(ULONG
, flags
, D1
),
761 AROS_UFHA(APTR
, libbase
, A6
))
766 BYTE result
= AROS_UFC5(BYTE
, patches
[PATCH_OpenDevice
].oldfunc
,
767 AROS_UFCA(CONST_STRPTR
, devName
, A0
),
768 AROS_UFCA(ULONG
, unitNumber
, D0
),
769 AROS_UFCA(struct IORequest
*, iORequest
, A1
),
770 AROS_UFCA(ULONG
, flags
, D1
),
771 AROS_UFCA(APTR
, libbase
, A6
));
773 if (patches
[PATCH_OpenDevice
].enabled
)
776 sprintf(unitstr
, "Unit %d", unitNumber
);
777 main_output("OpenDevice", devName
, unitstr
, !result
, TRUE
);
785 // ----------------------------------------------------------------------------------
787 AROS_UFH3(struct Library
*, New_OpenLibrary
,
788 AROS_UFHA(CONST_STRPTR
, libName
, A1
),
789 AROS_UFHA(ULONG
, version
, D0
),
790 AROS_UFHA(APTR
, libbase
, A6
))
795 struct Library
*result
= AROS_UFC3(struct Library
*, patches
[PATCH_OpenLibrary
].oldfunc
,
796 AROS_UFCA(CONST_STRPTR
, libName
, A1
),
797 AROS_UFCA(ULONG
, version
, D0
),
798 AROS_UFCA(APTR
, libbase
, A6
));
800 if (patches
[PATCH_OpenLibrary
].enabled
)
803 sprintf(verstr
, MSG(MSG_VERSION
), version
);
804 main_output("OpenLibrary", libName
, verstr
, (LONG
)result
, TRUE
);
812 // ----------------------------------------------------------------------------------
814 AROS_UFH2(APTR
, New_OpenResource
,
815 AROS_UFHA(CONST_STRPTR
, resName
, A1
),
816 AROS_UFHA(APTR
, libbase
, A6
))
821 APTR result
= AROS_UFC2(APTR
, patches
[PATCH_OpenResource
].oldfunc
,
822 AROS_UFCA(CONST_STRPTR
, resName
, A1
),
823 AROS_UFCA(APTR
, libbase
, A6
));
825 if (patches
[PATCH_OpenResource
].enabled
)
827 main_output("OpenLibrary", resName
, 0, (LONG
)result
, TRUE
);
835 // ----------------------------------------------------------------------------------
837 AROS_UFH2(struct Screen
*, New_LockPubScreen
,
838 AROS_UFHA(CONST_STRPTR
, name
, A0
),
839 AROS_UFHA(APTR
, libbase
, A6
))
844 struct Screen
*result
= AROS_UFC2(struct Screen
*, patches
[PATCH_LockPubScreen
].oldfunc
,
845 AROS_UFCA(CONST_STRPTR
, name
, A0
),
846 AROS_UFCA(APTR
, libbase
, A6
));
848 if (patches
[PATCH_LockPubScreen
].enabled
)
850 main_output("LockPubScreen", name
, 0, (LONG
)result
, TRUE
);
858 // ----------------------------------------------------------------------------------
860 AROS_UFH2(struct TextFont
*, New_OpenFont
,
861 AROS_UFHA(struct TextAttr
*, textAttr
, A0
),
862 AROS_UFHA(APTR
, libbase
, A6
))
867 struct TextFont
*result
= AROS_UFC2(struct TextFont
*, patches
[PATCH_OpenFont
].oldfunc
,
868 AROS_UFCA(struct TextAttr
*, textAttr
, A0
),
869 AROS_UFCA(APTR
, libbase
, A6
));
871 if (patches
[PATCH_OpenFont
].enabled
)
877 sprintf(sizestr
, MSG(MSG_SIZE
), textAttr
->ta_YSize
);
878 name
= textAttr
->ta_Name
;
883 main_output("OpenFont", name
, sizestr
, (LONG
)result
, TRUE
);
891 // ----------------------------------------------------------------------------------
893 AROS_UFH3(UBYTE
*, New_FindToolType
,
894 AROS_UFHA(CONST STRPTR
*, toolTypeArray
, A0
),
895 AROS_UFHA(CONST STRPTR
, typeName
, A1
),
896 AROS_UFHA(APTR
, libbase
, A6
))
901 UBYTE
*result
= AROS_UFC3(UBYTE
*, patches
[PATCH_FindToolType
].oldfunc
,
902 AROS_UFCA(CONST STRPTR
*, toolTypeArray
, A0
),
903 AROS_UFCA(CONST STRPTR
, typeName
, A1
),
904 AROS_UFCA(APTR
, libbase
, A6
));
906 if (patches
[PATCH_FindToolType
].enabled
)
908 main_output("FindToolType", typeName
, 0, (LONG
)result
, TRUE
);
916 // ----------------------------------------------------------------------------------
918 AROS_UFH3(BOOL
, New_MatchToolValue
,
919 AROS_UFHA(UBYTE
*, typeString
, A0
),
920 AROS_UFHA(UBYTE
*, value
, A1
),
921 AROS_UFHA(APTR
, libbase
, A6
))
925 BOOL result
= AROS_UFC3(BOOL
, patches
[PATCH_MatchToolValue
].oldfunc
,
926 AROS_UFCA(UBYTE
*, typeString
, A0
),
927 AROS_UFCA(UBYTE
*, value
, A1
),
928 AROS_UFCA(APTR
, libbase
, A6
));
930 if (patches
[PATCH_MatchToolValue
].enabled
)
932 main_output("MatchToolValue", typeString
, value
, result
, TRUE
);
940 // ----------------------------------------------------------------------------------
942 void patches_init(void)
944 libbases
[LIB_Exec
] = (struct Library
*)SysBase
;
945 libbases
[LIB_Dos
] = (struct Library
*)DOSBase
;
946 libbases
[LIB_Icon
] = IconBase
;
947 libbases
[LIB_Intuition
] = (struct Library
*)IntuitionBase
;
948 libbases
[LIB_Graphics
] = (struct Library
*)GfxBase
;
950 patches
[PATCH_CreateDir
].newfunc
= (FP
)&New_CreateDir
;
951 patches
[PATCH_CurrentDir
].newfunc
= (FP
)&New_CurrentDir
;
952 patches
[PATCH_DeleteFile
].newfunc
= (FP
)&New_DeleteFile
;
953 patches
[PATCH_DeleteVar
].newfunc
= (FP
)&New_DeleteVar
;
954 patches
[PATCH_Execute
].newfunc
= (FP
)&New_Execute
;
955 patches
[PATCH_FindVar
].newfunc
= (FP
)&New_FindVar
;
956 patches
[PATCH_GetVar
].newfunc
= (FP
)&New_GetVar
;
957 patches
[PATCH_LoadSeg
].newfunc
= (FP
)&New_LoadSeg
;
958 patches
[PATCH_Lock
].newfunc
= (FP
)&New_Lock
;
959 patches
[PATCH_MakeLink
].newfunc
= (FP
)&New_MakeLink
;
960 patches
[PATCH_NewLoadSeg
].newfunc
= (FP
)&New_NewLoadSeg
;
961 patches
[PATCH_Open
].newfunc
= (FP
)&New_Open
;
962 patches
[PATCH_Rename
].newfunc
= (FP
)&New_Rename
;
963 patches
[PATCH_RunCommand
].newfunc
= (FP
)&New_RunCommand
;
964 patches
[PATCH_SetVar
].newfunc
= (FP
)&New_SetVar
;
965 patches
[PATCH_SystemTagList
].newfunc
= (FP
)&New_SystemTagList
;
966 patches
[PATCH_FindPort
].newfunc
= (FP
)&New_FindPort
;
967 patches
[PATCH_FindResident
].newfunc
= (FP
)&New_FindResident
;
968 patches
[PATCH_FindSemaphore
].newfunc
= (FP
)&New_FindSemaphore
;
969 patches
[PATCH_FindTask
].newfunc
= (FP
)&New_FindTask
;
970 patches
[PATCH_OpenDevice
].newfunc
= (FP
)&New_OpenDevice
;
971 patches
[PATCH_OpenLibrary
].newfunc
= (FP
)&New_OpenLibrary
;
972 patches
[PATCH_OpenResource
].newfunc
= (FP
)&New_OpenResource
;
973 patches
[PATCH_LockPubScreen
].newfunc
= (FP
)&New_LockPubScreen
;
974 patches
[PATCH_OpenFont
].newfunc
= (FP
)&New_OpenFont
;
975 patches
[PATCH_FindToolType
].newfunc
= (FP
)&New_FindToolType
;
976 patches
[PATCH_MatchToolValue
].newfunc
= (FP
)&New_MatchToolValue
;
981 for (i
=0; i
<PATCH_last
; i
++)
983 if (patches
[i
].newfunc
);
986 patches
[i
].oldfunc
= SetFunction(libbases
[patches
[i
].libidx
], patches
[i
].lvo
, patches
[i
].newfunc
);
992 // ----------------------------------------------------------------------------------
994 void patches_set(void)
996 patches
[PATCH_CreateDir
].enabled
= setup
.enableMakeDir
;
997 patches
[PATCH_CurrentDir
].enabled
= setup
.enableChangeDir
;
998 patches
[PATCH_DeleteFile
].enabled
= setup
.enableDelete
;
999 patches
[PATCH_DeleteVar
].enabled
= setup
.enableSetVar
;
1000 patches
[PATCH_Execute
].enabled
= setup
.enableExecute
;
1001 patches
[PATCH_FindVar
].enabled
= setup
.enableGetVar
;
1002 patches
[PATCH_GetVar
].enabled
= setup
.enableGetVar
;
1003 patches
[PATCH_LoadSeg
].enabled
= setup
.enableLoadSeg
;
1004 patches
[PATCH_Lock
].enabled
= setup
.enableLock
;
1005 patches
[PATCH_MakeLink
].enabled
= setup
.enableMakeLink
;
1006 patches
[PATCH_NewLoadSeg
].enabled
= setup
.enableLoadSeg
;
1007 patches
[PATCH_Open
].enabled
= setup
.enableOpen
;
1008 patches
[PATCH_Rename
].enabled
= setup
.enableRename
;
1009 patches
[PATCH_RunCommand
].enabled
= setup
.enableRunCommand
;
1010 patches
[PATCH_SetVar
].enabled
= setup
.enableSetVar
;
1011 patches
[PATCH_SystemTagList
].enabled
= setup
.enableSystem
;
1012 patches
[PATCH_FindPort
].enabled
= setup
.enableFindPort
;
1013 patches
[PATCH_FindResident
].enabled
= setup
.enableFindResident
;
1014 patches
[PATCH_FindSemaphore
].enabled
= setup
.enableFindSemaphore
;
1015 patches
[PATCH_FindTask
].enabled
= setup
.enableFindTask
;
1016 patches
[PATCH_OpenDevice
].enabled
= setup
.enableOpenDevice
;
1017 patches
[PATCH_OpenLibrary
].enabled
= setup
.enableOpenLibrary
;
1018 patches
[PATCH_OpenResource
].enabled
= setup
.enableOpenResource
;
1019 patches
[PATCH_LockPubScreen
].enabled
= setup
.enableLockScreen
;
1020 patches
[PATCH_OpenFont
].enabled
= setup
.enableOpenFont
;
1021 patches
[PATCH_FindToolType
].enabled
= setup
.enableReadToolTypes
;
1022 patches
[PATCH_MatchToolValue
].enabled
= setup
.enableReadToolTypes
;
1026 // ----------------------------------------------------------------------------------
1028 void patches_reset(void)
1032 for (i
=0; i
<PATCH_last
; i
++)
1034 patches
[i
].enabled
= FALSE
;
1037 for (i
=0; i
<PATCH_last
; i
++)
1039 if (patches
[i
].oldfunc
)
1042 SetFunction(libbases
[patches
[i
].libidx
], patches
[i
].lvo
, patches
[i
].oldfunc
);
1044 patches
[i
].oldfunc
= NULL
;