Debian Codegraph @

wdoc/dbpath.html

raw
1 <HTML>
2
3 <HEAD>
4
5 <TITLE> ACEDB source code documentation: the dbpath utilities</TITLE>
6
7 <LINK rel=stylesheet type="text/css"
8 href="./wdoc.css"
9 title="Style sheet for wdoc developer documents">
10
11 </HEAD>
12
13 <BODY>
14
15 <DIV ALIGN=CENTER>
16
17 <H1 align=center>Application programmers' guide to the dbpath utilities</H1>
18
19
20 <ADDRESS>Originally written by<BR>
21 Simon Kelley &lt;[email protected]&gt, December 1999</ADDRESS>
22
23 </DIV>
24
25 <PRE>
26 I've made changes throughout the code, affecting every call to filName()
27 and sessionFilname(), and many calls to callScript*().
28
29 The motivation for these changes are twofold.
30
31 1) These functions used to return a pointer to a statically allocated
32 string. This is evil: it's fundamentally thread-unsafe, and exposes any
33 later code change to the risk of creating mysterious bugs because a
34 second call to a function is made which overwrites the static buffer
35 before a previous call has finished with it. (This is not a theoretical
36 risk - I fixed bugs caused this way). Sadly, this technique has been
37 used extensively in acedb (The glaring example is messprintf) I've now
38 removed some of the problem, we need to work on the rest.
39
40 2) A long time ago, the facility to make $ACEDB a colon separated search
41 path was introduced, using code in the filsubs library (ie filName).
42 This has never really been used, and indeed was disabled for many
43 lookups in sessionFilname. I wanted to achieve something similar, but
44 slightly different. I want exactly two directories; one is the standard
45 directory containing wspec and database and optionally other stuff where
46 a database resides, the other an installation-wide directory where
47 default copies of help files and config files and scripts can exist.
48 These are used when the files cannot be found in the default directory.
49
50 The database directory is found as before from the command line, or the
51 value of $ACEDB
52 The common directory is found from the value of $ACEDB_COMMON, or
53 /usr/share/acedb, or /usr/local/acedb (in that order) on unix, or from a
54 registry entry set up by the installation program on windows.
55
56 The following resources will be searched for in the COMMON dir if not
57 found in the database.
58
59 wspec/wingtkrc
60 wspec/gtkrc
61 wspec/winfonts.wrm
62 wspec/xfonts.wrm
63 wspec/psfonts.wrm
64 wspec/acedbrc
65 wspec/table.menu
66 wspec/sysclass.wrm
67 wspec/displays.wrm
68 wspec/table.menu
69 wscripts/*
70 whelp/
71 - note that the system will use only the contents of $ACEDB/whelp or
72 $ACEDB_COMMON/whelp
73 it won't mix files from both.
74
75 The following are searched for only in the database dir.
76 database/*
77 rawdata/*
78 wquery/*
79 rawdata/*
80 wgf/*
81 wspec/layout.wrm
82 wspec/models.wrm
83 wspec/server.wrm
84 wspec/constraints.wrm
85 wspec/subclasses.wrm
86 wspec/lock.wrm
87 wspec/serverconfig.wrm
88 wspec/server.wrm
89 wspec/datainfo.wrm
90 wspec/options.wrm
91 wspec/passwd.wrm
92 wspec/database.wrm
93
94 The API
95
96 Functions deleted - sessionFilname()
97 Functions deprecated - filName()
98 NOTE: This REALLY is deprecated, it's there for image and contigc which
99 have not been updated, I've removed every call in Acedb, and none should
100 be re-introduced.
101 Functions added - dbPathFilName(), dbPathStrictFilName(),
102 dbPathMakeFilName(),
103 filGetName(), filCheckName().
104 Semantics altered - callScript*()
105
106 The new functions.
107
108 char *filGetName(char *filename, char *ending, char *spec, STORE_HANDLE
109 handle)
110
111 expands filename to an absolute path if needed, on windows translates
112 any MS-DOS style paths to posix ones, expands ~, checks that file exists
113 and/or can be created, according to spec and returns the full path name
114 if so. or NULL. The return string is allocated on handle, and it is the
115 resposibility of the caller to free it, using messfree(), or
116 handleDestroy().
117
118 char *fileCheckName(char *filename, char *ending, char *spec)
119
120 does the same as filGetName, but returns TRUE is filGetName would have
121 returned non-NULL, or FALSE otherwise.
122
123 char *dbPathFilName(char* dir, char *file, char *ending, char *spec,
124 STORE_HANDLE handle)
125 returns absolute pathname for a file matching spec which exists in the
126 $ACEDB or $ACEDB_COMMON. rules for freeing return value as for
127 filGetName()
128
129 char *dbPathStrictFilName(char* dir, char *file, char *ending, char
130 *spec, STORE_HANDLE handle)
131 As dbPathFilname, but doesn't search COMMON directory.
132
133 char *dbPathMakeFilName(char* dir, char *file, char *ending,
134 STORE_HANDLE handle)
135 creates filename (in $ACEDB) but doesn't do existence or writability
136 checks (like setting spec to NULL in sessionFilName)
137
138 Note:
139
140 callScript() used to expand relative filenames in the $ACEDB /wscripts
141 path. It doesn't do that anymore, calling callScript with a simple
142 filename is only valid to run an executable on the user's path. To run
143 an exceutable in wscripts, call dbPathFilName() or dbPathStrictFilname()
144 with the name of the script, and pass the results to callScript. I've
145 changed all the relevant code.
146
147 </PRE>
148
149
150 <HR>
151 <ADDRESS><A href="mailto:[email protected]">Simon Kelley &lt;[email protected]&gt;</A></ADDRESS>
152 <!-- hhmts start -->
153 Last modified: Wed Apr 5 09:35:43 BST 2000
154 <!-- hhmts end -->
155
156 </BODY>
157 </HTML>
158