| 1 |
/**< |
/* |
| 2 |
* Ascend Module Control |
* Ascend Module Control |
| 3 |
* by Tom Epperly |
* by Tom Epperly |
| 4 |
* Created: 1/10/90 |
* Created: 1/10/90 |
| 25 |
* along with the program; if not, write to the Free Software Foundation, |
* along with the program; if not, write to the Free Software Foundation, |
| 26 |
* Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named |
* Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named |
| 27 |
* COPYING. |
* COPYING. |
|
* |
|
| 28 |
*/ |
*/ |
| 29 |
|
|
| 30 |
|
/** @file |
| 31 |
/**< |
* Ascend Module Control. |
| 32 |
|
* <pre> |
| 33 |
* When #including module.h, make sure these files are #included first: |
* When #including module.h, make sure these files are #included first: |
| 34 |
|
* #include "utilities/ascConfig.h" |
| 35 |
* #include "compiler.h" |
* #include "compiler.h" |
| 36 |
|
* </pre> |
| 37 |
*/ |
*/ |
| 38 |
|
|
| 39 |
#ifndef __MODULE_H_SEEN__ |
#ifndef __MODULE_H_SEEN__ |
| 40 |
#define __MODULE_H_SEEN__ |
#define __MODULE_H_SEEN__ |
| 41 |
|
|
|
|
|
| 42 |
#define PATHENVIRONMENTVAR "ASCENDLIBRARY" |
#define PATHENVIRONMENTVAR "ASCENDLIBRARY" |
| 43 |
/**< |
/**< |
| 44 |
* The name of the environment variable containing a list' of paths |
* The name of the environment variable containing a list' of paths |
| 45 |
* to search when trying to open a module. The list is in the style |
* to search when trying to open a module. The list is in the style |
| 46 |
* of the native OS: colon-separated on UNIX and semicolon separated |
* of the native OS: colon-separated on UNIX and semicolon separated |
| 47 |
* under Windows. |
* under Windows. |
| 48 |
*/ |
*/ |
| 49 |
|
|
| 50 |
|
#define MOD_FILE_EXTS 6 |
| 51 |
#define MOD_FILE_EXTS 6 |
#define MOD_OLD_CODE ".asc" |
| 52 |
#define MOD_OLD_CODE ".asc" |
/**< Extension for old code files. */ |
| 53 |
#define MOD_OLD_LIBRARY ".lib" |
#define MOD_OLD_LIBRARY ".lib" |
| 54 |
#define MOD_NEW_CODE ".a4c" |
/**< Extension for old library files. */ |
| 55 |
|
#define MOD_NEW_CODE ".a4c" |
| 56 |
|
/**< Extension for new code files. */ |
| 57 |
#define MOD_NEW_LIBRARY ".a4l" |
#define MOD_NEW_LIBRARY ".a4l" |
| 58 |
#define MOD_NEW_UNITS ".a4u" |
/**< Extension for new library files. */ |
| 59 |
#define MOD_CATCHALL "" |
#define MOD_NEW_UNITS ".a4u" |
| 60 |
|
/**< Extension for new units files. */ |
| 61 |
|
#define MOD_CATCHALL "" |
| 62 |
|
/**< Extension for general files. */ |
| 63 |
extern CONST char *g_alt_ending[MOD_FILE_EXTS]; |
extern CONST char *g_alt_ending[MOD_FILE_EXTS]; |
| 64 |
/**< |
/**< |
| 65 |
* This array defines the expected file extensions for |
* This array defines the expected file extensions for |
| 70 |
* made a mistake. |
* made a mistake. |
| 71 |
*/ |
*/ |
| 72 |
|
|
|
|
|
| 73 |
struct module_t; |
struct module_t; |
| 74 |
|
|
| 75 |
|
extern int Asc_InitModules(unsigned long init_length); |
|
extern int Asc_InitModules(unsigned long); |
|
| 76 |
/**< |
/**< |
| 77 |
* int Asc_InitModules(init_length) |
* <!-- int Asc_InitModules(init_length) --> |
| 78 |
* unsigned long init_length; // initial length of module list |
* <!-- unsigned long init_length; // initial length of module list --> |
| 79 |
* |
* |
| 80 |
* Create the data structures required by the modules code. Returns |
* Create the data structures required by the modules code. Returns |
| 81 |
* nonzero if not enough memory to initialize the modules; zero for |
* nonzero if not enough memory to initialize the modules; zero for |
| 82 |
* success. Clients to not need to call this function since calls to |
* success. Clients to not need to call this function since calls to |
| 83 |
* OpenModule() or RequireModule() will initialize the data structures |
* OpenModule() or RequireModule() will initialize the data structures |
| 84 |
* if needed. |
* if needed.<br><br> |
| 85 |
* |
* |
| 86 |
* The initial length of the module list will be set to `init_length'; |
* The initial length of the module list will be set to `init_length'; |
| 87 |
* since the module list will grow as needed, this number isn't too |
* since the module list will grow as needed, this number isn't too |
| 89 |
*/ |
*/ |
| 90 |
|
|
| 91 |
|
|
| 92 |
extern void Asc_DestroyModules(DestroyFunc); |
extern void Asc_DestroyModules(DestroyFunc func); |
| 93 |
/**< |
/**< |
| 94 |
* void Asc_DestroyModules((DestroyFunc)DestroyStatementList); |
* <!-- void Asc_DestroyModules((DestroyFunc)DestroyStatementList); --> |
| 95 |
* |
* |
| 96 |
* Deallocate all of the modules. This should be done when all types |
* Deallocate all of the modules. This should be done when all types |
| 97 |
* are destroyed and just before exiting. |
* are destroyed and just before exiting. |
| 98 |
* The function argument is not optional. |
* The function argument is not optional. |
| 99 |
*/ |
*/ |
| 100 |
|
|
| 101 |
extern struct module_t *Asc_OpenStringModule(CONST char *, int *, CONST char *); |
extern struct module_t *Asc_OpenStringModule(CONST char *inputstring, |
| 102 |
/**< |
int *status, |
| 103 |
* struct module_t *Asc_OpenStringModule(inputstring,status, nameprefix) |
CONST char *nameprefix); |
| 104 |
* const char *inputstring; // string to be parsed and saved |
/**< |
| 105 |
* const char *nameprefix; // prefix to use when making the module name |
* <!-- struct module_t *Asc_OpenStringModule(inputstring,status, nameprefix) --> |
| 106 |
* int *status; // the return status |
* <!-- const char *inputstring; // string to be parsed and saved --> |
| 107 |
|
* <!-- const char *nameprefix; // prefix to use when making the module name --> |
| 108 |
|
* <!-- int *status; // the return status --> |
| 109 |
* This function returns a module which behaves just as a regular |
* This function returns a module which behaves just as a regular |
| 110 |
* file module, except that it is always there unless there is |
* file module, except that it is always there unless there is |
| 111 |
* insufficient memory to make the required internal copy of the |
* insufficient memory to make the required internal copy of the |
| 112 |
* string. The scanner will use the non-input-modifying version |
* string. The scanner will use the non-input-modifying version |
| 113 |
* of its functions when operating on the copy of the input string. |
* of its functions when operating on the copy of the input string. |
| 116 |
* to zz_lex. |
* to zz_lex. |
| 117 |
*/ |
*/ |
| 118 |
|
|
| 119 |
extern struct module_t *Asc_OpenModule(CONST char *, int *); |
extern struct module_t *Asc_OpenModule(CONST char *name, int *status); |
|
extern struct module_t *Asc_RequireModule(CONST char *, int *); |
|
| 120 |
/**< |
/**< |
| 121 |
* struct module_t *Asc_OpenModule(name,status) |
* Attempt to find and open (for reading) a file whose |
| 122 |
* struct module_t *Asc_RequireModule(name,status) |
* name is based on `name'. |
| 123 |
* const char *inputstring; // the string statements to parse |
* @see Asc_RequireModule() for additional information. |
| 124 |
* const char *name; // the name of the file to find and open |
*/ |
| 125 |
* int *status; // the return status |
extern struct module_t *Asc_RequireModule(CONST char *name, int *status); |
| 126 |
* |
/**< |
| 127 |
* These functions attempt to find and open (for reading) a file whose |
* <!-- struct module_t *Asc_OpenModule(name,status) --> |
| 128 |
* name is based on `name'. `name' can either be a full path name to |
* <!-- struct module_t *Asc_RequireModule(name,status) --> |
| 129 |
* the file (in the native format) or a string that will be appended to |
* <!-- const char *inputstring; // the string statements to parse --> |
| 130 |
* each of the paths listed in the PATHENVIRONMENTVAR to try and find |
* <!-- const char *name; // the name of the file to find and open --> |
| 131 |
* the file. |
* <!-- int *status; // the return status --> |
| 132 |
|
* |
| 133 |
|
* Attempt to find and open (for reading) a file whose |
| 134 |
|
* name is based on `name'. |
| 135 |
|
* |
| 136 |
|
* The following applies to both Asc_OpenModule() and Asc_RequireModule(). |
| 137 |
|
* `name' can either be a full path name to the file (in the native format) |
| 138 |
|
* or a string that will be appended to each of the paths listed in the |
| 139 |
|
* PATHENVIRONMENTVAR to try and find the file.<br><br> |
| 140 |
* |
* |
| 141 |
* Past versions (pre July-97) of these functions used to append known |
* Past versions (pre July-97) of these functions used to append known |
| 142 |
* extensions to `name' to try and find the file. That behavior is no |
* extensions to `name' to try and find the file. That behavior is no |
| 143 |
* longer supported. |
* longer supported.<br><br> |
| 144 |
* |
* |
| 145 |
* The integer that `status' points to will be set to the return status |
* The integer that `status' points to will be set to the return status |
| 146 |
* of the function. If you are not concerned about the return status, |
* of the function. If you are not concerned about the return status, |
| 147 |
* pass in NULL as the second argument. |
* pass in NULL as the second argument.<br><br> |
| 148 |
* |
* |
| 149 |
* The portion of `name' after the rightmost slash (`/' on UNIX, `\' on |
* The portion of `name' after the rightmost slash (`/' on UNIX, `\' on |
| 150 |
* Windows) is used as the "base-name" part of the module's |
* Windows) is used as the "base-name" part of the module's |
| 152 |
* the module's name is a version number enclosed in angle brackets. |
* the module's name is a version number enclosed in angle brackets. |
| 153 |
* Version numbers start at zero and increase. For example, the first |
* Version numbers start at zero and increase. For example, the first |
| 154 |
* time OpenModule("/foo/bar/baz.a4c") is called, a module with the |
* time OpenModule("/foo/bar/baz.a4c") is called, a module with the |
| 155 |
* name "baz.a4c<0>" is created. Module names are unique. |
* name "baz.a4c<0>" is created. Module names are unique.<br><br> |
| 156 |
* |
* |
| 157 |
* ASC_REQUIREMODULE ONLY: |
* ASC_REQUIREMODULE ONLY:<br> |
| 158 |
* If the base-name of the module name you specify matches an |
* If the base-name of the module name you specify matches an |
| 159 |
* existing module's base-name or a module's alias, `status' is set |
* existing module's base-name or a module's alias, `status' is set |
| 160 |
* to 5 and the existing module is returned. For example, if you |
* to 5 and the existing module is returned. For example, if you |
| 161 |
* call OpenModule("/foo/bar/baz.a4c") successfully, and then |
* call Asc_OpenModule("/foo/bar/baz.a4c") successfully, and then |
| 162 |
* RequireModule("/food/beer/baz.a4c"), the existing module |
* Asc_RequireModule("/food/beer/baz.a4c"), the existing module |
| 163 |
* "baz.a4c<0>" is returned. The pathnames of the files are not |
* "baz.a4c<0>" is returned. The pathnames of the files are not |
| 164 |
* compared, and no searching of the file system occurs. See |
* compared, and no searching of the file system occurs. See |
| 165 |
* Asc_ModuleCreateAlias() for details on aliases. |
* Asc_ModuleCreateAlias() for details on aliases.<br><br> |
| 166 |
* |
* |
| 167 |
* If attempting to access `name' directly fails, and searching over |
* If attempting to access `name' directly fails, and searching over |
| 168 |
* PATHENVIRONMENTVAR produces no valid filenames, `status' is set to |
* PATHENVIRONMENTVAR produces no valid filenames, `status' is set to |
| 170 |
* fopen() call fails, `status' is set to -2 and NULL is returned. |
* fopen() call fails, `status' is set to -2 and NULL is returned. |
| 171 |
* Note that fopen() is only attempted one time; once we have a name |
* Note that fopen() is only attempted one time; once we have a name |
| 172 |
* that looks like a valid directory entry (a stat() call returns 0), |
* that looks like a valid directory entry (a stat() call returns 0), |
| 173 |
* we stop searching. |
* we stop searching.<br><br> |
| 174 |
* |
* |
| 175 |
* If a filename is found and the file is successfully opened for |
* If a filename is found and the file is successfully opened for |
| 176 |
* reading, the base-name of the module is compared against existing |
* reading, the base-name of the module is compared against existing |
| 179 |
* module we are currently scanning (if any---this only occurs when the |
* module we are currently scanning (if any---this only occurs when the |
| 180 |
* user calls RequireModule) is pushed onto a stack, the scanner is |
* user calls RequireModule) is pushed onto a stack, the scanner is |
| 181 |
* told to scan the newly opened file, `status' is set to 0, and the |
* told to scan the newly opened file, `status' is set to 0, and the |
| 182 |
* new module is returned. |
* new module is returned.<br><br> |
| 183 |
* |
* |
| 184 |
* If the base-name of the filename we found matches a module alias, we |
* If the base-name of the filename we found matches a module alias, we |
| 185 |
* treat the filename as a new module and the actions listed in the |
* treat the filename as a new module and the actions listed in the |
| 186 |
* above paragraph occur, except that `status' is set to 3. See the |
* above paragraph occur, except that `status' is set to 3. See the |
| 187 |
* documentation under Asc_ModuleCreateAlias() for details on aliases. |
* documentation under Asc_ModuleCreateAlias() for details on aliases.<br><br> |
| 188 |
* |
* |
| 189 |
* If the filename we found and an existing module have the same |
* If the filename we found and an existing module have the same |
| 190 |
* base-name, the pathnames and timestamps of the files are compared. |
* base-name, the pathnames and timestamps of the files are compared. |
| 201 |
* scanner is told to scan the newly opened file, `status' is set to 1, |
* scanner is told to scan the newly opened file, `status' is set to 1, |
| 202 |
* and the new module is returned. Note that a string comparison is |
* and the new module is returned. Note that a string comparison is |
| 203 |
* used to compare filenames, so "./foo" and "././foo" are seen as two |
* used to compare filenames, so "./foo" and "././foo" are seen as two |
| 204 |
* separate files. |
* separate files.<br><br> |
| 205 |
* |
* |
| 206 |
* If the argument `name' is NULL or has zero length, `status' is set |
* If the argument `name' is NULL or has zero length, `status' is set |
| 207 |
* to -4 and NULL is returned. |
* to -4 and NULL is returned.<br><br> |
| 208 |
* |
* |
| 209 |
* If any attempts to allocate memory fail, `status' is set to -3 and |
* If any attempts to allocate memory fail, `status' is set to -3 and |
| 210 |
* NULL is returned. |
* NULL is returned.<br><br> |
| 211 |
* |
* |
| 212 |
* Summary of values put into `status': |
* Summary of values put into `status': |
| 213 |
* -4 bad input: NULL or zero length name |
* - -4 bad input: NULL or zero length name |
| 214 |
* -3 a memory error occurred: not enough memory to create module |
* - -3 a memory error occurred: not enough memory to create module |
| 215 |
* -2 a filename was found but it could not be opened for reading |
* - -2 a filename was found but it could not be opened for reading |
| 216 |
* -1 a filename could not find a file for `name' |
* - -1 a filename could not find a file for `name' |
| 217 |
* 0 a new module was successfully created |
* - 0 a new module was successfully created |
| 218 |
* 1 a new version of an existing module was created |
* - 1 a new version of an existing module was created |
| 219 |
* 2 an existing module is being returned |
* - 2 an existing module is being returned |
| 220 |
* 3 a new module was created, overwriting a module's alias |
* - 3 a new module was created, overwriting a module's alias |
| 221 |
* 4 an attempt to do a recursive require was caught |
* - 4 an attempt to do a recursive require was caught |
| 222 |
* 5 the module you are REQUIREing already exists |
* - 5 the module you are REQUIREing already exists |
| 223 |
*/ |
*/ |
| 224 |
|
|
| 225 |
|
|
| 226 |
extern int Asc_ModuleCreateAlias(CONST struct module_t *, CONST char *); |
extern int Asc_ModuleCreateAlias(CONST struct module_t *m, CONST char *name); |
| 227 |
/**< |
/**< |
| 228 |
* int Asc_ModuleCreateAlias(m, name); |
* <!-- int Asc_ModuleCreateAlias(m, name); --> |
| 229 |
* const struct module_t *m; |
* <!-- const struct module_t *m; --> |
| 230 |
* const char *name; |
* <!-- const char *name; --> |
| 231 |
* |
* |
| 232 |
* This function takes the string given in `name' and converts it |
* This function takes the string given in `name' and converts it |
| 233 |
* to a module "base-name" by removing all path information---i.e., |
* to a module "base-name" by removing all path information---i.e., |
| 234 |
* only characters after the rightmost slash (`/' on UNIX, '\' on |
* only characters after the rightmost slash (`/' on UNIX, '\' on |
| 235 |
* Windows) are used in the base-name. This base-name---along with |
* Windows) are used in the base-name. This base-name---along with |
| 236 |
* the version number zero---acts as an alias for the module `m'. |
* the version number zero---acts as an alias for the module `m'.<br><br> |
| 237 |
* |
* |
| 238 |
* The number of aliases a module may have is only limited by the |
* The number of aliases a module may have is only limited by the |
| 239 |
* computer's memory. |
* computer's memory.<br><br> |
| 240 |
* |
* |
| 241 |
* Clients can use the alias to retrieve the module `m'. For example, |
* Clients can use the alias to retrieve the module `m'. For example, |
| 242 |
* if the following sequence occurs: |
* if the following sequence occurs: |
| 243 |
|
* <pre> |
| 244 |
* m = Asc_OpenModule("foo.a4c",NULL); |
* m = Asc_OpenModule("foo.a4c",NULL); |
| 245 |
* Asc_ModuleCreateAlias(m, "bar.a4c"); |
* Asc_ModuleCreateAlias(m, "bar.a4c"); |
| 246 |
* then |
* then |
| 247 |
* m == Asc_GetModuleByName("bar.a4c<0>") |
* m == Asc_GetModuleByName("bar.a4c<0>") |
| 248 |
* == Asc_GetModuleByName("foo.a4c<0>") |
* == Asc_GetModuleByName("foo.a4c<0>") |
| 249 |
|
* </pre> |
| 250 |
* |
* |
| 251 |
* The typical reason to create a module-alias is to satisfy subsequent |
* The typical reason to create a module-alias is to satisfy subsequent |
| 252 |
* calls to Asc_RequireModule(); recall that Asc_RequireModule() checks |
* calls to Asc_RequireModule(); recall that Asc_RequireModule() checks |
| 262 |
* PROVIDE system.lib (the PROVIDE keyword calls |
* PROVIDE system.lib (the PROVIDE keyword calls |
| 263 |
* Asc_ModuleCreateAlias()) to say that ivpsystem.lib satisfies what |
* Asc_ModuleCreateAlias()) to say that ivpsystem.lib satisfies what |
| 264 |
* system.lib typically provides, in effect, to say that system.lib has |
* system.lib typically provides, in effect, to say that system.lib has |
| 265 |
* been provided. |
* been provided.<br><br> |
| 266 |
* |
* |
| 267 |
* The base-name of the module-alias that is created must not conflict |
* The base-name of the module-alias that is created must not conflict |
| 268 |
* with the base-names of any existing modules (it may conflict with |
* with the base-names of any existing modules (it may conflict with |
| 272 |
* the current-module's (as returned by Asc_CurrentModule) base-name. |
* the current-module's (as returned by Asc_CurrentModule) base-name. |
| 273 |
* This can occur if the file for module "foo" contains the statement |
* This can occur if the file for module "foo" contains the statement |
| 274 |
* ``PROVIDE "foo"''. In this case, a module-alias is not created and |
* ``PROVIDE "foo"''. In this case, a module-alias is not created and |
| 275 |
* 1 is returned. |
* 1 is returned.<br><br> |
| 276 |
* |
* |
| 277 |
* If the alias's base-name does not conflict with any other alias's |
* If the alias's base-name does not conflict with any other alias's |
| 278 |
* base-name, a new module-alias is created and 0 is returned. |
* base-name, a new module-alias is created and 0 is returned.<br><br> |
| 279 |
* |
* |
| 280 |
* Attempts to create an alias with the same base-name to the same |
* Attempts to create an alias with the same base-name to the same |
| 281 |
* module are ignored, and 2 is returned. |
* module are ignored, and 2 is returned.<br><br> |
| 282 |
* |
* |
| 283 |
* If a module-alias with the same base-name exists, the filenames of |
* If a module-alias with the same base-name exists, the filenames of |
| 284 |
* `m' and the aliased module are compared. If they do not match, a |
* `m' and the aliased module are compared. If they do not match, a |
| 285 |
* warning is printed; if they match, we are rereading a file and no |
* warning is printed; if they match, we are rereading a file and no |
| 286 |
* warning is printed. In either case, the old module-alias is |
* warning is printed. In either case, the old module-alias is |
| 287 |
* destroyed, a new module-alias is created, and 3 is returned. |
* destroyed, a new module-alias is created, and 3 is returned.<br><br> |
| 288 |
* |
* |
| 289 |
* If `name' is NULL or has zero length, -4 is returned. `m' not be a |
* If `name' is NULL or has zero length, -4 is returned. `m' not be a |
| 290 |
* module-alias; if it is a module-alias, an error is printed and -4 is |
* module-alias; if it is a module-alias, an error is printed and -4 is |
| 291 |
* returned. |
* returned.<br><br> |
| 292 |
* |
* |
| 293 |
* If any attempts to allocate memory fail, -3 is returned. |
* If any attempts to allocate memory fail, -3 is returned. |
| 294 |
*/ |
*/ |
| 295 |
|
|
|
|
|
| 296 |
extern int Asc_CloseCurrentModule(void); |
extern int Asc_CloseCurrentModule(void); |
| 297 |
/**< |
/**< |
| 298 |
* int Asc_CloseCurrentModule() |
* <!-- int Asc_CloseCurrentModule() --> |
| 299 |
* |
* |
| 300 |
* This function will close the current module, and restore the module |
* This function will close the current module, and restore the module |
| 301 |
* (tell the scanner to scan the module) that REQUIREd it. |
* (tell the scanner to scan the module) that REQUIREd it.<br><br> |
| 302 |
* |
* |
| 303 |
* If no module REQUIREd the current module (so that this module is the |
* If no module REQUIREd the current module (so that this module is the |
| 304 |
* last open module), return TRUE; otherwise, return FALSE. |
* last open module), return TRUE; otherwise, return FALSE. |
| 305 |
*/ |
*/ |
| 306 |
|
|
| 307 |
extern int Asc_ModuleAddStatements(struct module_t *,struct gl_list_t *); |
extern int Asc_ModuleAddStatements(struct module_t *mod, struct gl_list_t *stats); |
| 308 |
/**< |
/**< |
| 309 |
* err = Asc_ModuleAddStatements(Asc_CurrentModule(),stats); |
* <!-- err = Asc_ModuleAddStatements(Asc_CurrentModule(),stats); --> |
| 310 |
* struct gl_list_t *stats; // list of StatementList *. |
* <!-- struct gl_list_t *stats; // list of StatementList *. --> |
| 311 |
|
* Add statements to a Module. |
| 312 |
* Returns 0 or 1 if successful, or -1 if not. The usual cause for |
* Returns 0 or 1 if successful, or -1 if not. The usual cause for |
| 313 |
* failure is that the module is a file module and not a string |
* failure is that the module is a file module and not a string |
| 314 |
* module. File modules cannot have loose GLOBAL statements in them. |
* module. File modules cannot have loose GLOBAL statements in them. |
| 315 |
* Return: Caller should do: |
* <pre> |
| 316 |
* -1 Destroy stats and the statementlists in it. |
* Return: Caller should do: |
| 317 |
* 0 Forget stats-- we now track it. |
* -1 Destroy stats and the statementlists in it. |
| 318 |
* 1 Destroy stats, but not the statementlists in it, |
* 0 Forget stats-- we now track it. |
| 319 |
* as we are now tracking the statementslists. |
* 1 Destroy stats, but not the statementlists in it, |
| 320 |
|
* as we are now tracking the statementslists. |
| 321 |
|
* </pre> |
| 322 |
*/ |
*/ |
| 323 |
|
|
| 324 |
extern CONST struct module_t *Asc_GetModuleByName(CONST char *); |
extern CONST struct module_t *Asc_GetModuleByName(CONST char *name); |
| 325 |
/**< |
/**< |
| 326 |
* struct module_t *Asc_GetModuleByName(name); |
* <!-- struct module_t *Asc_GetModuleByName(name); --> |
| 327 |
* const char *name; |
* <!-- const char *name; --> |
| 328 |
* |
* |
| 329 |
* Return the module whose name is `name.' `name' should be in the |
* Return the module whose name is `name.' `name' should be in the |
| 330 |
* style returned by Asc_ModuleName(), namely, a base-name and a |
* style returned by Asc_ModuleName(), namely, a base-name and a |
| 331 |
* version number: "foo.a4c<0>". |
* version number: "foo.a4c<0>".<br><br> |
| 332 |
* |
* |
| 333 |
* If `name' refers to a module-alias, the module it is an alias for is |
* If `name' refers to a module-alias, the module it is an alias for is |
| 334 |
* returned. |
* returned.<br><br> |
| 335 |
* |
* |
| 336 |
* If `name' is not properly formated, print an error and return NULL. |
* If `name' is not properly formated, print an error and return NULL. |
| 337 |
* If a module with the requested name is not found, ruturn NULL. |
* If a module with the requested name is not found, ruturn NULL. |
| 338 |
*/ |
*/ |
| 339 |
|
|
| 340 |
|
extern struct gl_list_t *Asc_ModuleList(int module_type); |
| 341 |
extern struct gl_list_t *Asc_ModuleList(int); |
/**< |
| 342 |
/**< |
* <!-- nameslist = struct gl_list_t *Asc_ModuleList(module_type); --> |
| 343 |
* nameslist = struct gl_list_t *Asc_ModuleList(module_type); |
* <pre> |
|
* |
|
| 344 |
* module_type 0; |
* module_type 0; |
| 345 |
* Returns a gl_list containing the name of each module that currently |
* Returns a gl_list containing the name of each module that currently |
| 346 |
* has at least one type definitions based on the module's contents. |
* has at least one type definitions based on the module's contents. |
| 352 |
* module_type 2; |
* module_type 2; |
| 353 |
* Returns a gl_list containing the name of each module that currently |
* Returns a gl_list containing the name of each module that currently |
| 354 |
* has statements. |
* has statements. |
| 355 |
* |
* </pre> |
| 356 |
* This function returns NULL if no modules are currently loaded or if |
* This function returns NULL if no modules are currently loaded or if |
| 357 |
* there is not enough memory to create a new gl_list. |
* there is not enough memory to create a new gl_list.<br><br> |
| 358 |
* |
* |
| 359 |
* The caller is resposible for calling gl_destroy() when finished |
* The caller is resposible for calling gl_destroy() when finished |
| 360 |
* using the list. The names contained in the gl_list are the property |
* using the list. The names contained in the gl_list are the property |
| 363 |
* Asc_DestroyModules(). |
* Asc_DestroyModules(). |
| 364 |
*/ |
*/ |
| 365 |
|
|
| 366 |
|
extern void Asc_ModuleWrite(FILE *f, CONST struct module_t *m); |
| 367 |
extern void Asc_ModuleWrite(FILE *, CONST struct module_t *); |
/**< |
| 368 |
/**< |
* <!-- void Asc_ModuleWrite(f,m) --> |
| 369 |
* void Asc_ModuleWrite(f,m) |
* <!-- FILE *f; --> |
| 370 |
* FILE *f; |
* <!-- const struct module_t *m; --> |
|
* const struct module_t *m; |
|
| 371 |
* |
* |
| 372 |
* Write the name, filename, open/closed-state, and time-last-modified |
* Write the name, filename, open/closed-state, and time-last-modified |
| 373 |
* of module `m' to the file pointer `f'. */ |
* of module `m' to the file pointer `f'. */ |
| 374 |
|
|
|
|
|
| 375 |
extern struct module_t *Asc_CurrentModuleF(void); |
extern struct module_t *Asc_CurrentModuleF(void); |
| 376 |
|
/**< |
| 377 |
|
* Implementation function for debug version of Asc_CurrentModule(). |
| 378 |
|
* Do not call this function directly - use Asc_CurrentModule() instead. |
| 379 |
|
*/ |
| 380 |
#ifndef NDEBUG |
#ifndef NDEBUG |
| 381 |
#define Asc_CurrentModule() Asc_CurrentModuleF() |
#define Asc_CurrentModule() Asc_CurrentModuleF() |
| 382 |
|
/**< |
| 383 |
|
* Returns a pointer to the current module (debug mode). |
| 384 |
|
* @see Asc_CurrentModuleF() |
| 385 |
|
*/ |
| 386 |
#else |
#else |
| 387 |
extern struct module_t *g_current_module; |
extern struct module_t *g_current_module; |
| 388 |
#define Asc_CurrentModule() g_current_module |
/**< |
| 389 |
#endif /**< NDEBUG */ |
* Pointer to the current module. |
| 390 |
/**< |
* Do not access directly. Use Asc_CurrentModule(). |
|
* struct module_t *Asc_CurrentModule() |
|
|
* |
|
|
* Returns a pointer to the current module. |
|
| 391 |
*/ |
*/ |
| 392 |
|
#define Asc_CurrentModule() g_current_module |
| 393 |
|
/**< Returns a pointer to the current module (release mode). */ |
| 394 |
|
#endif /* NDEBUG */ |
| 395 |
|
|
| 396 |
|
extern CONST char *Asc_ModuleName(CONST struct module_t *m); |
| 397 |
extern CONST char *Asc_ModuleName(CONST struct module_t *); |
/**< |
| 398 |
/**< |
* <!-- const char *Asc_ModuleName(m) --> |
| 399 |
* const char *Asc_ModuleName(m) |
* <!-- const struct module_t *m; --> |
|
* const struct module_t *m; |
|
| 400 |
* |
* |
| 401 |
* Return the name of module m. |
* Return the name of module m. |
| 402 |
*/ |
*/ |
| 403 |
|
|
| 404 |
extern struct gl_list_t *Asc_ModuleStatementLists(CONST struct module_t *); |
extern struct gl_list_t *Asc_ModuleStatementLists(CONST struct module_t *m); |
| 405 |
/**< |
/**< |
| 406 |
* Returns a gl_list_t *, or NULL if none, containing pointers to |
* Returns a gl_list_t *, or NULL if none, containing pointers to |
| 407 |
* struct StatementList *. The batches of statements are in order |
* struct StatementList *. The batches of statements are in order |
| 408 |
* parsed. File modules will never have statements. |
* parsed. File modules will never have statements. |
| 409 |
* One may, (though we don't recommend it) combine all the statements |
* One may, (though we don't recommend it) combine all the statements |
| 414 |
* all the statements. module.c owns the gl_list. |
* all the statements. module.c owns the gl_list. |
| 415 |
*/ |
*/ |
| 416 |
|
|
| 417 |
extern CONST char *Asc_ModuleString(CONST struct module_t *); |
extern CONST char *Asc_ModuleString(CONST struct module_t *m); |
| 418 |
/**< |
/**< |
| 419 |
* const char *Asc_ModuleString(m) |
* <!-- const char *Asc_ModuleString(m) --> |
| 420 |
* const struct module_t *m; |
* <!-- const struct module_t *m; --> |
| 421 |
* |
* |
| 422 |
* Return the string of module m, if it is an interactive |
* Return the string of module m, if it is an interactive |
| 423 |
* string module, or NULL if it is a file module. |
* string module, or NULL if it is a file module. |
| 424 |
*/ |
*/ |
| 425 |
|
|
| 426 |
extern CONST char *Asc_ModuleFileName(CONST struct module_t *); |
extern CONST char *Asc_ModuleFileName(CONST struct module_t *m); |
| 427 |
/**< |
/**< |
| 428 |
* const char *Asc_ModuleFileName(m) |
* <!-- const char *Asc_ModuleFileName(m) --> |
| 429 |
* const struct module_t *m; |
* <!-- const struct module_t *m; --> |
| 430 |
* |
* |
| 431 |
* Return the filename of module m. |
* Return the filename of module m. |
| 432 |
*/ |
*/ |
| 433 |
|
|
| 434 |
extern CONST char *Asc_ModuleBestName(CONST struct module_t *); |
extern CONST char *Asc_ModuleBestName(CONST struct module_t *m); |
| 435 |
/**< |
/**< |
| 436 |
* const char *Asc_ModuleBestName(m) |
* <!-- const char *Asc_ModuleBestName(m) --> |
| 437 |
* const struct module_t *m; |
* <!-- const struct module_t *m; --> |
| 438 |
* |
* |
| 439 |
* Return the filename of module m, if it is a file, or the |
* Return the filename of module m, if it is a file, or the |
| 440 |
* buffer name if it is a string. |
* buffer name if it is a string. |
| 443 |
*/ |
*/ |
| 444 |
|
|
| 445 |
|
|
| 446 |
extern unsigned long Asc_ModuleTimesOpened(CONST struct module_t *); |
extern unsigned long Asc_ModuleTimesOpened(CONST struct module_t *m); |
| 447 |
/**< |
/**< |
| 448 |
* unsigned long Asc_ModuleTimesOpened(m) |
* <!-- unsigned long Asc_ModuleTimesOpened(m) --> |
| 449 |
* const struct module_t *m; |
* <!-- const struct module_t *m; --> |
| 450 |
* |
* |
| 451 |
* Return the number of times that this module has been opened. This is |
* Return the number of times that this module has been opened. This is |
| 452 |
* necessary to determine when you are reloading a module. |
* necessary to determine when you are reloading a module. |
| 453 |
*/ |
*/ |
| 454 |
|
|
| 455 |
|
|
| 456 |
extern struct tm *Asc_ModuleTimeModified(CONST struct module_t *); |
extern struct tm *Asc_ModuleTimeModified(CONST struct module_t *m); |
| 457 |
/**< |
/**< |
| 458 |
* struct tm Asc_ModuleTimeModified(m) |
* <!-- struct tm Asc_ModuleTimeModified(m) --> |
| 459 |
* const struct module_t *m; |
* <!-- const struct module_t *m; --> |
| 460 |
* |
* |
| 461 |
* Return the time that the module was last modified; the time is |
* Return the time that the module was last modified. The time is |
| 462 |
* coverted to the local time. |
* coverted to the local time. |
| 463 |
*/ |
*/ |
| 464 |
|
|
| 465 |
extern int Asc_ModuleStringIndex(CONST struct module_t *); |
extern int Asc_ModuleStringIndex(CONST struct module_t *m); |
| 466 |
/**< |
/**< |
| 467 |
* int Asc_ModuleTime(m) |
* <!-- int Asc_ModuleTime(m) --> |
| 468 |
* const struct module_t *m; |
* <!-- const struct module_t *m; --> |
| 469 |
* |
* |
| 470 |
* Return the string index (the place in the sequence of parsing |
* Return the string index (the place in the sequence of parsing |
| 471 |
* strings. |
* strings. |
| 472 |
*/ |
*/ |
| 473 |
|
|
| 474 |
#define Asc_ModulesEqual(m1,m2) ((m1)==(m2)) |
#define Asc_ModulesEqual(m1,m2) ((m1)==(m2)) |
| 475 |
/**< |
/**< |
| 476 |
* int Asc_ModulesEqual(m1,m2) |
* <!-- int Asc_ModulesEqual(m1,m2) --> |
| 477 |
* struct module_t m1; |
* <!-- struct module_t m1; --> |
| 478 |
* struct module_t m2; |
* <!-- struct module_t m2; --> |
| 479 |
* |
* |
| 480 |
* This macro will evaluate to TRUE if module `m1' equals module `m2'; |
* This macro will evaluate to TRUE if module `m1' equals module `m2'; |
| 481 |
*/ |
*/ |
| 482 |
|
|
| 483 |
#endif /**< __MODULE_H_SEEN__ */ |
#endif /* __MODULE_H_SEEN__ */ |
| 484 |
|
|