home *** CD-ROM | disk | FTP | other *** search
- %!
- %%VMusage: 5132 5132
- %%VMlocation: global
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% %%
- %% This file implements the Generic category resource. %%
- %% %%
- %% The Generic implementation stores instances of the resource in %%
- %% local VM in a dictionary with the category name in Resources in %%
- %% userdict. Global instances are held in Instances in the %%
- %% category implementation dictionary. It looks for disc files in %%
- %% %resources%category. %%
- %% %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- <<
- /Category /Generic
-
- %%
- %% ResourceFileName builds a filename of the form %resource%category/instance
- %%
- /ResourceFileName {
- dup 0 (%resource%) putinterval
- dup 10 1 index length 10 sub getinterval
- Category exch cvs
- length 10 add
- 2 copy 16#2f put 1 add
- 2 copy 1 index length 1 index sub getinterval
- 3 index exch cvs length add 0 exch getinterval exch pop
- } bind
-
- /FindResource {
- currentglobal not {
- LocalInstances 1 index known {
- LocalInstances exch get false
- } {
- true
- } ifelse
- } {
- true
- } ifelse
- {
- Instances 1 index known not {
- dup 256 string ResourceFileName
- dup status {
- pop pop pop pop
- currentglobal exch true setglobal
- mark exch 20 dict begin {run} stopped end cleartomark
- setglobal
- } {
- pop
- } ifelse
- } if
- Instances 1 index known {
- Instances exch get
- } {
- LocalInstances 1 index known {
- LocalInstances exch get
- } {
- /findresource
- errordict /undefinedresource get exec
- } ifelse
- } ifelse
- } if
- } bind
-
- /DefineResource {
- currentglobal {
- LocalInstances 2 index known {
- LocalInstances 2 index undef
- } if
- Instances 3 -1 roll 2 index put
- } {
- LocalInstances 3 -1 roll 2 index put
- } ifelse
- } bind
-
- /UndefineResource {
- currentglobal {
- LocalInstances 1 index known {
- LocalInstances 1 index undef
- } if
- Instances 1 index known {
- Instances 1 index undef
- } if
- pop
- } {
- LocalInstances 1 index known {
- LocalInstances 1 index undef
- } if
- pop
- } ifelse
- } bind
-
- /ResourceStatus {
- currentglobal {
- false
- } {
- LocalInstances 1 index known
- } ifelse
- Instances 2 index known or {
- pop 0 -1 true
- } {
- 256 string ResourceFileName
- dup status {
- pop pop pop pop
- (r) file 256 string readstring pop %% Is this good enough?
- (%%VMusage:) search {
- pop pop 2 exch
- token pop exch token pop exch pop
- 2 copy lt {exch} if pop
- true
- } {
- pop 2 -1 true
- } ifelse
- } {
- pop false
- } ifelse
- } ifelse
- } bind
-
- /ResourceForAll {
- currentdict end
- 10 dict begin
- /cat exch def
- userdict /##_RFA_TEMP_## currentdict put
- /scratch exch def
- /proc exch def
- /template exch def
- /done false def
- currentglobal not {
- cat begin LocalInstances end {
- pop scratch cvs dup template stringmatch {
- /proc load
- end stopped
- ##_RFA_TEMP_## begin
- {
- $error /errorname get dup /invalidexit eq {
- pop /done true def exit
- } {
- $error /command get exch
- errordict exch get exec
- } ifelse
- } if
- } {
- pop
- } ifelse
- } forall
- } if
- done not {
- cat /Instances get {
- pop
- cat begin LocalInstances end 1 index known not
- exch scratch cvs dup template stringmatch 3 -1 roll and {
- /proc load
- end stopped
- ##_RFA_TEMP_## begin
- {
- $error /errorname get dup /invalidexit eq {
- pop /done true def exit
- } {
- $error /command get exch
- errordict exch get exec
- } ifelse
- } if
- } {
- pop
- } ifelse
- } forall
- } if
- done not {
- (*) 256 string cat begin ResourceFileName end {
- (/) search {
- pop pop dup template stringmatch {
- dup cvn
- cat begin LocalInstances end 1 index known
- cat /Instances get 3 -1 roll known or not {
- scratch cvs
- /proc load
- end stopped
- ##_RFA_TEMP_## begin
- {
- $error /errorname get dup /invalidexit eq {
- pop /done true def exit
- } {
- $error /command get exch
- errordict exch get exec
- } ifelse
- } if
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } 256 string filenameforall
- } if
- end
- ##_RFA_TEMP_## /cat get begin
- userdict /##_RFA_TEMP_## undef
- } bind
-
- /LocalInstances {
- userdict /Resources known not {
- userdict /Resources
- currentglobal false setglobal 1 dict exch setglobal
- put
- } if
- userdict /Resources get dup Category known not {
- dup Category 1 dict put
- } if
- Category get
- } bind
-
- >>
-
- dup /Category get exch /Category defineresource pop
-
-