2 Copyright © 2004-2013, 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.
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.
14 #include <proto/exec.h>
15 #include <proto/dos.h>
27 #define TEMPLATE "NAME/M/A"
28 #define ERROR_HEADER "LoadResource"
30 BOOL
process(CONST_STRPTR name
);
31 BOOL
dev_process(CONST_STRPTR name
);
36 struct RDArgs
*rdargs
= NULL
;
37 IPTR args
[ARG_COUNT
] = { 0 };
39 if ((rdargs
= ReadArgs(TEMPLATE
, args
, NULL
)) != NULL
)
41 if (args
[ARG_NAME
] != 0)
43 CONST_STRPTR
*names
= (CONST_STRPTR
*) args
[ARG_NAME
],
46 while ((name
= *names
++) != NULL
)
49 int len
= strlen(name
);
51 if ((len
> 7) && (!strcmp(&name
[len
-7], ".device")))
52 res
= dev_process(name
);
64 // FIXME: List currently locked resources.
71 PrintFault(IoErr(), ERROR_HEADER
);
78 BOOL
process(CONST_STRPTR name
)
80 struct Library
*lb
= OpenLibrary(name
, 0L);
89 PutStr(ERROR_HEADER
": ");
90 Printf(_(MSG_ERROR_OPEN_LIBRARY
), name
);
96 BOOL
dev_process(CONST_STRPTR name
)
100 memset(&req
, 0, sizeof(req
));
101 req
.io_Message
.mn_Length
= sizeof(req
);
103 if (!OpenDevice(name
, 0, &req
, 0))
109 /* There can different errors, but if the device was loaded, it's OK */
110 if (FindName(&SysBase
->DeviceList
, name
))
113 PutStr(ERROR_HEADER
": ");
114 Printf(_(MSG_ERROR_OPEN_DEVICE
), name
);