home *** CD-ROM | disk | FTP | other *** search
-
-
- /*
- *FUNC= GetRes A0
- *FUNC= FreeRes A0
- *FUNC= FreeAllRes A0
- *FUNC= ChownRes D0/D1/A0
- *FUNC= UnLinkAllRes A0
- *FUNC= ReLinkAllRes A0
- *FUNC= SetResFlags D0/D1/A0
- *FUNC= AddRes D0/D1/D2/A0
- *FUNC= RemRes A0
- *FUNC= GetResInfo D0/D1/A0
- *FUNC= GetResList D0/D1/D2/A0
- *FUNC= GetFileList D0/D1/D2/A0
- *FUNC= AddPrivResFile D0/D1
- *FUNC= RemPrivResFiles A0
- *FUNC= AddGlobResFile D0/D1
- *FUNC= RemGlobResFiles A0
- *FUNC= AddResSwapDir D0/D1/A0
- *FUNC= RemResSwapDirs A0
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *FUNC= NULL -
- *
- */
-
- #include <local/typedefs.h>
- #include <local/res.h>
- #include "file.h"
-
- /*
- * resptr = GetRes(resnametype) char *resnametype;
- *
- * (1) The resource is SHARED, is tagged with its name, then
- * (a) if swapped, swap in
- * (b) incr. ref. count.
- * (2) The resource is not shared, re-load from disk
- *
- */
-
- GetRes(rnt)
- register char *rnt;
- {
- RMSG RMsg;
- register char *str;
-
- for (str = rnt + strlen(rnt); str >= rnt && *str != '.'; --str);
- RMsg.Arg1 = (long)rnt;
- RMsg.Arg2 = (long)str + 1;
- if ((RMsg.Arg3 = str - rnt) < 0)
- RMsg.Arg3 = 0;
- RMsg.Arg4 = strlen(str + 1);
- DoSyncMsg(&ResPort, &RMsg);
- return(RMsg.Res1);
- }
-
- resptr= GetRes(resnametype) char *resnametype;
-
- This function retrieves the requested resource, doing any
- translations required to get the resource into the requested
- type. NULL is returned if the resource could not be found
- or could not be translated to the requested type.
-
- In-Memory private resources are searched first, then the private
- resource files for the task, then In-Memory system resources, then
- the global resource files for the system. Openning an already-open
- resource causes one of two actions depending on whether the resource
- is shared or not. If shared, the reference count is simply
- incremented, otherwise a private copy of the resource is made.
-
- Example: Win = GetRes("Charlie.Window");
-
- error = FreeRes(resptr)
-
- Free a resource that you retrieved via GetRes(). Only the task
- that owns the resource may free it (though several tasks may own
- a resource through duplication and ownership changes). 1 is
- returned on success, 0 on error.
-
- numres= FreeAllRes(task)
-
- Free all resources associated with the specified task (NULL for
- self).
-
- error = ChownRes(resptr, fromtask, totask)
-
- Change ownership of a resource from the source task to the
- destination task. The resource must be owned by the source
- task or an error will occur (0 return value). 1 is returned
- on success. NULL may be specified for either or both tasks
- meaning the calling task.
-
- handle= UnLinkAllRes(task)
-
- Unlink all resources associated with the specified task (NULL
- for self) and return a handle representing those resources.
-
- This is useful for shells and such to keep their resources from
- getting removed by commands they run. Combined with the NUNLINK
- flag one can pass resources to a Command and keep the rest out of
- reach.
-
- (void) ReLinkAllRes(handle, task)
-
- Link all the resources represented by the handle to the specified
- task (NULL for self).
-
- oldfl = SetResFlags(resptr, newflags, flagsmask)
-
- Modify the flags associated with a resource. NOTE: If multiple
- references to a shared resource exist, all are modified. Some
- modifications may be disallowed by the system. This call is
- normally used to modify the LOCKED and SWAPABLE flags (note that
- the SWAPABLE flag can be changed back and forth only for resource
- which support it).
-
- error = AddRes(resnametype, flags, ptr, ctlcode);
- char *resnametype;
- long flags;
- APTR ptr;
- long (*ctlcode)();
-
- Add a resource to the system. The resource is placed either in
- the task's privately accessable in-memory resource list or
- in the system global accessable in-memory resource list depending
- on the specified flags. One may now GetRes() the resource.
-
- ONLY VIRTUAL RESOURCES MAY BE ADDED IN THIS WAY. The VIRTUAL
- and LOCKED flags are automatically set.
-
- If flags specifies a VIRTUAL resource
-
- error = RemRes(resname)
-
- Remove the specified resource. An error will occur and the resource
- will not be removed (1) if it does not exist in memory, or (2) it
- is currently being referenced. (Note: the resource is removed even
- if it is swapped or locked).
-
- error = GetResInfo(resname, &flags, &bytes)
-
- Get information on a resource. Information may not exist for a
- resource if it is not currently in memory and would have to be
- translated to get to the right type.
-
- error = GetResList(wildcard, from, &av, &ac);
-
- from: mask, bit 0 search private list
- 1 search system list
- 2 <not used>
- 3 search in-memory private list
- 4 search in-memory global list
-
- Return an ARGC/ARGV list of resource names. Note that some names
- might be duplicated if searching multiple lists. Restricting the
- search to in-memory lists give resources which are already in
- memory (but might be swapped out or removed at any time for those
- with no references)
-
- RESOURCE FILES
-
- error = GetFileList(wildcard, from, &av, &ac);
-
- from: mask, bit 0 search private list
- 1 search system list
- 2 search swap list
-
- Return an ARGC/ARGV list of the files which match the specified
- wildcard from the private list, system list, or system swap dir
- list (in which case you get directory names). This list has been
- allocated, and can be freed as follows:
-
- Loop through all entries for (i = 0; i < ac; ++i)
- FreeMem(av[i], strlen(av[i])+1);
- Free the array itself: FreeMem(av, sizeof(char *) * (ac+1));
-
- num = AddPrivResFile(filename, pri)
-
- Add a file name to the list of resource files for this task. These
- are scanned before global files when a resource is requested. All
- files in the list are write protected (i.e. a shared lock is kept
- for each file). Thus, such files cannot be updated until removed
- from the list.
-
- Can also be used to modify the priority of an existing file
-
- num = RemPrivResFiles(wildcard)
-
- Remove zero or more file names from the list of resource files for
- this task. A wildcard pattern (* and ?) is accepted.
-
- Note for command processors: commands you run might execute
- this command for *.
-
- num = AddGlobResFile(filename, pri)
-
- Same as AddPrivResFile() but applies to the system list, which is
- searched last and by any requesting task. Wildcard file names are
- NOT accepted. The file need not exist at this time, and references
- to unmounted volumes are allowed.
-
- Can also be used to modify the priority of an existing entry
-
- num = RemGlobResFiles(wildcard)
-
- Remove zero or more resource files from the global list. Again,
- a wildcard filename is accepted.
-
- num = AddResSwapDir(dirname, pri, maxkbytes) char *dirname;
- char pri;
- long maxkbytes
-
- Add a directory to the list of directories the resource system
- can swap to. The maximum number of KBytes of material allowed
- in the directory should be specified. You can also use this
- call to modify the priority and maxkbytes for an entry.
-
- The highest priority directories are used before lower priority
- directories. Not all directories need be mounted, but if a swapin
- occurs from an unmounted directory a requester will appear.
-
- A lock is kept on each specified directory.
-
- num = RemResSwapDirs(wildcard)
-
- Remove directories associated with the resource swap areas.
-
-
-