prism2.device: Compiler delint
[AROS.git] / workbench / c / LoadResource / main.c
blob49f7a4c446410f172e0d44d824677d467e0f2667
1 /*
2 Copyright © 2004, The AROS Development Team. All rights reserved.
3 This file is part of the LoadResource program, which is distributed under
4 the terms of version 2 of the GNU General Public License.
6 FIXME:
7 + Implement LOCK and UNLOCK options. Argument template should then be
8 changed to "NAME/M,LOCK/S,UNLOCK/S"; if the user doesn't provide NAME,
9 then all currently locked resources shall be listed.
10 + Implement support for loading devices, fonts and catalogs.
13 #include <proto/exec.h>
14 #include <proto/dos.h>
15 #include "locale.h"
17 enum
19 ARG_NAME,
20 ARG_COUNT
23 #define TEMPLATE "NAME/M/A"
24 #define ERROR_HEADER "LoadResource"
26 BOOL process(CONST_STRPTR name);
28 int main(void)
30 int rc = RETURN_OK;
31 struct RDArgs *rdargs = NULL;
32 IPTR args[ARG_COUNT] = { 0 };
34 if ((rdargs = ReadArgs(TEMPLATE, args, NULL)) != NULL)
36 if (args[ARG_NAME] != 0)
38 CONST_STRPTR *names = (CONST_STRPTR *) args[ARG_NAME],
39 name = NULL;
41 while ((name = *names++) != NULL)
43 if (!process(name))
45 rc = RETURN_WARN;
49 else
51 // FIXME: List currently locked resources.
54 FreeArgs(rdargs);
56 else
58 PrintFault(IoErr(), ERROR_HEADER);
59 rc = RETURN_FAIL;
62 return rc;
65 BOOL process(CONST_STRPTR name)
67 struct Library *lb = OpenLibrary(name, 0L);
69 if (lb != NULL)
71 CloseLibrary(lb);
72 return TRUE;
74 else
76 PutStr(ERROR_HEADER": ");
77 Printf(_(MSG_ERROR_OPEN_LIBRARY), name);
78 PutStr("\n");
79 return FALSE;