/[ascend]/trunk/base/generic/compiler/module.c
ViewVC logotype

Diff of /trunk/base/generic/compiler/module.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 660 by johnpye, Fri Mar 31 08:52:57 2006 UTC revision 661 by johnpye, Wed Jun 14 06:20:50 2006 UTC
# Line 1  Line 1 
1  /*  /*  ASCEND modelling environment
2   *  Ascend Module Control      Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
3   *  by Tom Epperly      Copyright (C) 2006 Carnegie Mellon University
4   *  Created: 1/11/90  
5   *  Version: $Revision: 1.25 $      This program is free software; you can redistribute it and/or modify
6   *  Version control file: $RCSfile: module.c,v $      it under the terms of the GNU General Public License as published by
7   *  Date last modified: $Date: 1998/03/17 22:09:12 $      the Free Software Foundation; either version 2, or (at your option)
8   *  Last modified by: $Author: ballan $      any later version.
9   *  
10   *  This file is part of the Ascend Language Interpreter.      This program is distributed in the hope that it will be useful,
11   *      but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *      GNU General Public License for more details.
14   *  The Ascend Language Interpreter is free software; you can redistribute  
15   *  it and/or modify it under the terms of the GNU General Public License as      You should have received a copy of the GNU General Public License
16   *  published by the Free Software Foundation; either version 2 of the      along with this program; if not, write to the Free Software
17   *  License, or (at your option) any later version.      Foundation, Inc., 59 Temple Place - Suite 330,
18   *      Boston, MA 02111-1307, USA.
19   *  The Ascend Language Interpreter is distributed in hope that it will be  *//** @file
20   *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of      Ascend Module Control
21   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *//*
22   *  General Public License for more details.      by Tom Epperly
23   *      Created: 1/11/90
24   *  You should have received a copy of the GNU General Public License      Last in CVS: $Revision: 1.25 $ $Date: 1998/03/17 22:09:12 $ $Author: ballan $
25   *  along with the program; if not, write to the Free Software Foundation,  */
  *  Inc., 675 Mass Ave, Cambridge, MA 02139 USA.  Check the file named  
  *  COPYING.  
  *  
  */  
26    
27  #include <errno.h>  #include <errno.h>
28  #include <stdarg.h>  #include <stdarg.h>
# Line 127  CONST char *g_alt_ending[MOD_FILE_EXTS] Line 123  CONST char *g_alt_ending[MOD_FILE_EXTS]
123    
124  /* extern */  /* extern */
125  struct module_t *g_current_module = NULL;  struct module_t *g_current_module = NULL;
126  /*  /**<
127   *  The current module.  Even though this variable is "extern",   *  The current module.  Even though this variable is "extern",
128   *  do NOT use this variable directly.  Instead, use a call to   *  do NOT use this variable directly.  Instead, use a call to
129   *  Asc_CurrentModule() to get the current module.   *  Asc_CurrentModule() to get the current module.
130   */   */
131    
132  static int g_string_modules_processed = 0;  static int g_string_modules_processed = 0;
133  /*  /**<
134   * This is a counter, to be incremented each time it is used to   * This is a counter, to be incremented each time it is used to
135   * create a string module name. Should not be reset to 0   * create a string module name. Should not be reset to 0
136   * unless all modules have been destroyed.   * unless all modules have been destroyed.
# Line 143  static int g_string_modules_processed = Line 139  static int g_string_modules_processed =
139  static struct gl_list_t *g_module_list = NULL;  static struct gl_list_t *g_module_list = NULL;
140  #define G_MODULE_LIST_INIT_SIZE 20L  #define G_MODULE_LIST_INIT_SIZE 20L
141    
142    /*----------
143      forward declarations
144    */
145    
 /*  
  *---------- Forward Declarations ----------  
  */  
146  static int CmpModulesNameVers(CONST struct module_t*, CONST struct module_t*);  static int CmpModulesNameVers(CONST struct module_t*, CONST struct module_t*);
147  static struct module_t *FindModuleFile(CONST char *, int * CONST, int);  static struct module_t *FindModuleFile(CONST char *, int * CONST, int);
148  static struct module_t *CreateStringModule(CONST char *, int * CONST, CONST char *);  static struct module_t *CreateStringModule(CONST char *, int * CONST, CONST char *);
# Line 163  static struct module_t *SearchForModule( Line 159  static struct module_t *SearchForModule(
159  static int StoreModule(CONST struct module_t *);  static int StoreModule(CONST struct module_t *);
160  static void WriteWhyNotFound(symchar *,  int);  static void WriteWhyNotFound(symchar *,  int);
161    
162    /*------------------------------------------------------------------------------
163      MODULE HANDLING
164    */
165    
166  /**  See the header file for this function's documentation  /* see module.h for details of functions not documented here */
167   **/  
168  int Asc_InitModules(unsigned long init_size)  int Asc_InitModules(unsigned long init_size){
 {  
169    if( g_module_list != NULL ) {    if( g_module_list != NULL ) {
170      return 0;      return 0;
171    }    }
# Line 182  int Asc_InitModules(unsigned long init_s Line 180  int Asc_InitModules(unsigned long init_s
180    
181  static DestroyFunc g_sldestroy;  static DestroyFunc g_sldestroy;
182    
183  static void DestroyModule(struct module_t *m)  static void DestroyModule(struct module_t *m){
 {  
184    if (m == NULL) return;    if (m == NULL) return;
185    if (m->s != NULL) {    if (m->s != NULL) {
186      ascfree((char *)m->s);      ascfree((char *)m->s);
# Line 201  static void DestroyModule(struct module_ Line 198  static void DestroyModule(struct module_
198    DeleteModule(m);    DeleteModule(m);
199  }  }
200    
201  /**  See the header file for this function's documentation  
202   **/  void Asc_DestroyModules(DestroyFunc f){
 void Asc_DestroyModules(DestroyFunc f)  
 {  
203    g_sldestroy = f;    g_sldestroy = f;
204    if (g_module_list != NULL) {    if (g_module_list != NULL) {
205      gl_iterate(g_module_list,(DestroyFunc)DestroyModule);      gl_iterate(g_module_list,(DestroyFunc)DestroyModule);
# Line 214  void Asc_DestroyModules(DestroyFunc f) Line 209  void Asc_DestroyModules(DestroyFunc f)
209  }  }
210    
211    
 /**  See the header file for this function's documentation  
  **/  
212  extern struct module_t *Asc_OpenStringModule(CONST char *inputstring,  extern struct module_t *Asc_OpenStringModule(CONST char *inputstring,
213                                               int *status,      int *status,
214                                               CONST char *prefix)      CONST char *prefix
215  {  ){
216    char *name = NULL;    char *name = NULL;
217    char *keep_string;    char *keep_string;
218    int dummy;    int dummy;
# Line 254  extern struct module_t *Asc_OpenStringMo Line 247  extern struct module_t *Asc_OpenStringMo
247    return result;    return result;
248  }  }
249    
250  /**  See the header file for this function's documentation  
251   **/  extern struct module_t *Asc_OpenModule(CONST char *name, int *status){
 extern struct module_t *Asc_OpenModule(CONST char *name, int *status)  
 {  
252    if( status != NULL ) {    if( status != NULL ) {
253      return OpenModuleInternal(name, status, FALSE, NULL);      return OpenModuleInternal(name, status, FALSE, NULL);
254    } else {    } else {
# Line 267  extern struct module_t *Asc_OpenModule(C Line 258  extern struct module_t *Asc_OpenModule(C
258  }  }
259    
260    
261  /**  See the header file for this function's documentation  extern struct module_t *Asc_RequireModule(CONST char *name, int *status){
  **/  
 extern struct module_t *Asc_RequireModule(CONST char *name, int *status)  
 {  
262    if( status != NULL ) {    if( status != NULL ) {
263      return OpenModuleInternal(name, status, TRUE, NULL);      return OpenModuleInternal(name, status, TRUE, NULL);
264    } else {    } else {
# Line 280  extern struct module_t *Asc_RequireModul Line 268  extern struct module_t *Asc_RequireModul
268  }  }
269    
270    
271  /*  /**
272   *  struct module_t *OpenModuleInternal(name, status, do_not_overwrite, str)      This function is the glue between the user callable Asc_OpenModule()
273   *      const char *name;      // filanem of the module to find      and Asc_RequireModule() functions and FindModuleFile().  Consult
274   *      int * const status;    // status to return to caller      those functions' documentation for more information.  The
275   *      int do_not_overwrite;  // Should we keep existing modules?      `do_not_overwrite' flag tells if we were called from
276   *      const char *str;       // String we keep and parse if not NULL.      Asc_OpenModule() (==FALSE) or Asc_RequireModule() (==TRUE).
277   *  
278   *  When str is NULL:      @param name filanem of the module to find
279   *  This function calls FindModuleFile() to find the module named `name'.      @param status status to return to caller
280   *  The status of FindModuleFile is returned to the caller in `status'.      @param do_not_overwrite Should we keep existing modules?
281   *  If the call to FindModuleFile is successful and do_not_overwrite is      @param str String we keep and parse if not NULL.
282   *  FALSE, we make the returned module the current module and inform  
283   *  the scanner of the change.      When str is NULL:
284   *  When str is NOT NULL:          This function calls FindModuleFile() to find the module named `name'.
285   *  Calls FindModuleFile to guard against duplication, then sets up          The status of FindModuleFile is returned to the caller in `status'.
286   *  module and scanner for string scanning.          If the call to FindModuleFile is successful and do_not_overwrite is
287   *          FALSE, we make the returned module the current module and inform
288   *  This function is the glue between the user callable Asc_OpenModule()          the scanner of the change.
289   *  and Asc_RequireModule() functions and FindModuleFile().  Consult      When str is NOT NULL:
290   *  those functions' documentation for more information.  The          Calls FindModuleFile to guard against duplication, then sets up
291   *  `do_not_overwrite' flag tells if we were called from          module and scanner for string scanning.
292   *  Asc_OpenModule() (==FALSE) or Asc_RequireModule() (==TRUE).  */
  */  
293  static  static
294  struct module_t *OpenModuleInternal(CONST char *name,  struct module_t *OpenModuleInternal(CONST char *name,
295                                      int * CONST status,                                      int * CONST status,
# Line 386  struct module_t *OpenModuleInternal(CONS Line 373  struct module_t *OpenModuleInternal(CONS
373  }  }
374    
375    
376  /*  /**
377   *  struct module_t *FindModuleFile(name, status, do_not_overwrite)      Find or create a module named `name'.  Return the module and put
378   *      const char *name;      an exit code in `status'.  If `do_not_overwrite' is TRUE, an existing
379   *      int * const status;      module named `name' will be returned; otherwise, a new module will
380   *      int do_not_overwrite;      be created, overwriting any existing module having that name.
381   *  
382   *  Find or create a module named `name'.  Return the module and put      The value put into `status' is one of:
383   *  an exit code in `status'.  If `do_not_overwrite' is TRUE, an existing         -3  a memory error occurred: not enough memory to create module;
384   *  module named `name' will be returned; otherwise, a new module will             returning NULL
385   *  be created, overwriting any existing module having that name.         -2  a potential file matching module name was found but the
386   *             file could not be opened for reading; returning NULL
387   *  The value put into `status' is one of:         -1  could not find a file for the module `name'; returning NULL
388   *      -3  a memory error occurred: not enough memory to create module;          0  a new module was successfully created and is being returned
389   *          returning NULL          1  a module with `name' already existed; the file it points to
390   *      -2  a potential file matching module name was found but the             does NOT match the file just found for module `name'; the old
391   *          file could not be opened for reading; returning NULL             module was overwritten and the new module is being returned
392   *      -1  could not find a file for the module `name'; returning NULL          2  a module with `name' already exited; the file it points to
393   *       0  a new module was successfully created and is being returned             matches the file just found for module `name'; the existing
394   *       1  a module with `name' already existed; the file it points to             module is being returned
395   *          does NOT match the file just found for module `name'; the old          3  a module with `name' already existed; it was an alias for
396   *          module was overwritten and the new module is being returned             for another module; the old module was overwritten and the
397   *       2  a module with `name' already exited; the file it points to             new module is being returned
398   *          matches the file just found for module `name'; the existing          4  a module with `name' already existed; it was being read when
399   *          module is being returned             we tried to open it again for reading (recursive require).
400   *       3  a module with `name' already existed; it was an alias for             The existing module is being returned.
401   *          for another module; the old module was overwritten and the          5  The argument `do_not_overwrite' is TRUE and a module named
402   *          new module is being returned             `name' was found, returning it
403   *       4  a module with `name' already existed; it was being read when  */
  *          we tried to open it again for reading (recursive require).  
  *          The existing module is being returned.  
  *       5  The argument `do_not_overwrite' is TRUE and a module named  
  *          `name' was found, returning it  
  */  
404  static  static
405  struct module_t *FindModuleFile(CONST char *name,  struct module_t *FindModuleFile(CONST char *name,
406                                  int * CONST status,                                  int * CONST status,
# Line 622  struct module_t *FindModuleFile(CONST ch Line 604  struct module_t *FindModuleFile(CONST ch
604    return new_module;    return new_module;
605  }  }
606    
607  /*  /** Create a module named `name'.  Return the module and put
  *  struct module_t *CreateStringModule(name, status, keep_string)  
  *      const char *name;  
  *      int * const status;  
  *      const char *keep_string;  
  *  
  *  Create a module named `name'.  Return the module and put  
608   *  an exit code in `status'.   *  an exit code in `status'.
609   *  Name is expected to be unique for all time (or at least until we   *  Name is expected to be unique for all time (or at least until we
610   *  reinit the compiler).   *  reinit the compiler).
# Line 893  struct module_t *CreateStringModule(CONS Line 869  struct module_t *CreateStringModule(CONS
869  }  }
870    
871    
872  /*  /** This function tries to find a file corresponding to the argument
  *  struct module_t *ModuleSearchPath(name, filename, m, error)  
  *      const char *name;  
  *      char *filename;  
  *      struct module_t *m;  
  *      int * const error;  
  *  
  *  This function tries to find a file corresponding to the argument  
873   *  "name" by sending "name" to the function ModuleStatFile() which   *  "name" by sending "name" to the function ModuleStatFile() which
874   *  will attempt to open "name" as a file.  If that fails, this   *  will attempt to open "name" as a file.  If that fails, this
875   *  function then prepends each entry in the search path   *  function then prepends each entry in the search path
# Line 983  int ModuleSearchPath(CONST char *name, Line 952  int ModuleSearchPath(CONST char *name,
952  }  }
953    
954    
955  /*  /** Attempt to stat and open the file `filename' for reading.  If the
  *  int ModuleStatFile(m, filename, error)  
  *      struct module_t * const m;  
  *      const char *filename;  
  *      int * const error;  
  *  
  *  Attempt to stat and open the file `filename' for reading.  If the  
956   *  stat call fails, set *error to the value of errno and return 1.  If   *  stat call fails, set *error to the value of errno and return 1.  If
957   *  the fopen call fails, set *error to errno and return -1.  If stat   *  the fopen call fails, set *error to errno and return -1.  If stat
958   *  and fopen calls are successful, set the fields `f', `linenum', and   *  and fopen calls are successful, set the fields `f', `linenum', and
# Line 1029  int ModuleStatFile(struct module_t * CON Line 992  int ModuleStatFile(struct module_t * CON
992  }  }
993    
994    
995  /*  /**
  *  void WriteWhyNotFound(filename,error)  
  *      const char *filename;  
  *      int error;  
  *  
996   *  Print an error (based on the errno `error') explaining why we could   *  Print an error (based on the errno `error') explaining why we could
997   *  not open/stat the file named `filename'.   *  not open/stat the file named `filename'.
998   */   */
# Line 1196  extern int Asc_ModuleCreateAlias(CONST s Line 1155  extern int Asc_ModuleCreateAlias(CONST s
1155    return -2;    return -2;
1156  }  }
1157    
1158  /*  /** Allocate space for a new module and set its fields to some
  *  struct module_t *NewModule(name);  
  *      const char *name;  
  *  
  *  Allocate space for a new module and set its fields to some  
1159   *  reasonable defaults.  If `name' is not NULL, set the module's   *  reasonable defaults.  If `name' is not NULL, set the module's
1160   *  base_name to point to the first character after the rightmost   *  base_name to point to the first character after the rightmost
1161   *  slash (`/' on UNIX, `/' on Windows) in `name', or to `name' if   *  slash (`/' on UNIX, `/' on Windows) in `name', or to `name' if
# Line 1253  struct module_t *NewModule(CONST char *n Line 1208  struct module_t *NewModule(CONST char *n
1208    return new;    return new;
1209  }  }
1210    
1211    /*------------------------------------------------------------------------------
1212      GLOBAL MODULE LIST MANAGEMENT
1213    
 /*  
  *-------------------------------------------------  
1214   *  The following four functions are used to store, remove, and search   *  The following four functions are used to store, remove, and search
1215   *  for modules in the global module list, the gl_list `g_module_list'.   *  for modules in the global module list, the gl_list `g_module_list'.
1216   *  We do this (instead of inlining the calls to gl_*()) to provide a   *  We do this (instead of inlining the calls to gl_*()) to provide a
# Line 1294  struct module_t *NewModule(CONST char *n Line 1249  struct module_t *NewModule(CONST char *n
1249   */   */
1250    
1251    
1252  /*  /** Store `m' in the global module gl_list `g_module_list', creating
  *  int StoreModule(m);  
  *      const struct module_t *m;  
  *  
  *  Store `m' in the global module gl_list `g_module_list', creating  
1253   *  the g_module_list if needed.  Return 0 for success or 1 if the   *  the g_module_list if needed.  Return 0 for success or 1 if the
1254   *  g_module_list could not be created.   *  g_module_list could not be created.
1255   *   *
# Line 1317  int StoreModule(CONST struct module_t *m Line 1268  int StoreModule(CONST struct module_t *m
1268  }  }
1269    
1270    
1271  /*  /** Remove `m' from the global module gl_list `g_module_list'.
  *  int RemoveModule(m);  
  *      const struct module_t *m;  
  *  
  *  Remove `m' from the global module gl_list `g_module_list'.  
1272   *   *
1273   *  This function searches backwards through g_module_list and uses   *  This function searches backwards through g_module_list and uses
1274   *  CmpModulesNameVers() to determine which module to remove.   *  CmpModulesNameVers() to determine which module to remove.
# Line 1343  void RemoveModule(CONST struct module_t Line 1290  void RemoveModule(CONST struct module_t
1290  }  }
1291    
1292    
1293  /*  /** Search for `m' in the global module gl_list `g_module_list'
  *  int SearchForModule(m);  
  *      const struct module_t *m;  
  *  
  *  Search for `m' in the global module gl_list `g_module_list'  
1294   *  and return it.  Return the matching module or NULL if no matching   *  and return it.  Return the matching module or NULL if no matching
1295   *  module exists or if the g_module_list is empty.   *  module exists or if the g_module_list is empty.
1296   *   *
# Line 1373  struct module_t *SearchForModule(CONST s Line 1316  struct module_t *SearchForModule(CONST s
1316  }  }
1317    
1318    
1319  /*  /** Compare the base_names and version numbers of the modules
  *  int CmpModulesNameVers(m1, m2);  
  *      const struct module_t *m1;  
  *      const struct module_t *m2;  
  *  
  *  Compare the base_names and version numbers of the modules  
1320   *  `m1' and `m2'.   *  `m1' and `m2'.
1321   *  Return:   *  Return:
1322   *      >0  m1->base_name > m2->base_name   *      >0  m1->base_name > m2->base_name
# Line 1403  int CmpModulesNameVers(CONST struct modu Line 1341  int CmpModulesNameVers(CONST struct modu
1341  }  }
1342    
1343    
1344  /**  See the header file for this function's documentation  
1345   **/  extern int Asc_CloseCurrentModule(void){
 extern int Asc_CloseCurrentModule(void)  
 {  
1346    struct module_t *prev;    struct module_t *prev;
1347    
1348    /*    /*
# Line 1461  extern int Asc_CloseCurrentModule(void) Line 1397  extern int Asc_CloseCurrentModule(void)
1397    return FALSE;    return FALSE;
1398  }  }
1399    
1400    
1401  int Asc_ModuleAddStatements(struct module_t *m, struct gl_list_t *l)  int Asc_ModuleAddStatements(struct module_t *m, struct gl_list_t *l)
1402  {  {
1403    if (l == NULL || gl_length(l) == 0 ||    if (l == NULL || gl_length(l) == 0 ||
# Line 1482  int Asc_ModuleAddStatements(struct modul Line 1419  int Asc_ModuleAddStatements(struct modul
1419  }  }
1420    
1421    
1422  /**  See the header file for this function's documentation  extern CONST struct module_t *Asc_GetModuleByName(CONST char *module_name){
  **/  
 extern CONST struct module_t *Asc_GetModuleByName(CONST char *module_name)  
 {  
1423    char name[PATH_MAX];    char name[PATH_MAX];
1424    unsigned long vers;    unsigned long vers;
1425    struct module_t *mod;    struct module_t *mod;
# Line 1531  extern CONST struct module_t *Asc_GetMod Line 1465  extern CONST struct module_t *Asc_GetMod
1465  }  }
1466    
1467    
1468  /*  /**
  *  static unsigned long ModuleNameToInternalNameVers(module_name, name);  
  *      const char *module_name;  
  *      char * const name;  
  *  
1469   *  Parse the module name given in `module_name' (e.g., "foo.a4c<0>")   *  Parse the module name given in `module_name' (e.g., "foo.a4c<0>")
1470   *  into an base name and a version number.  Copy the base_name   *  into an base name and a version number.  Copy the base_name
1471   *  into the string `name' and use the version number as the return   *  into the string `name' and use the version number as the return
# Line 1629  struct gl_list_t *Asc_ModuleStatementLis Line 1559  struct gl_list_t *Asc_ModuleStatementLis
1559    return m->stats;    return m->stats;
1560  }  }
1561    
1562  /**  See the header file for this function's documentation  
1563   **/  
1564  extern struct gl_list_t *Asc_ModuleList(int module_type)  extern struct gl_list_t *Asc_ModuleList(int module_type){
 {  
1565    struct gl_list_t *new = NULL;    struct gl_list_t *new = NULL;
1566    struct module_t *m;    struct module_t *m;
1567    struct gl_list_t *types = NULL;    struct gl_list_t *types = NULL;
# Line 1678  extern struct gl_list_t *Asc_ModuleList( Line 1607  extern struct gl_list_t *Asc_ModuleList(
1607  }  }
1608    
1609    
1610  /**  See the header file for this function's documentation  extern void Asc_ModuleWrite(FILE *f, CONST struct module_t *m){
  **/  
 extern void Asc_ModuleWrite(FILE *f, CONST struct module_t *m)  
 {  
1611    assert(m!=NULL);    assert(m!=NULL);
1612    FPRINTF(f,"MODULE: %s\nFILENAME: %s\n",SCP(m->name),SCP(m->filename));    FPRINTF(f,"MODULE: %s\nFILENAME: %s\n",SCP(m->name),SCP(m->filename));
1613    FPRINTF(f,(m->f!=NULL)?"OPEN\n":"CLOSED\n");    FPRINTF(f,(m->f!=NULL)?"OPEN\n":"CLOSED\n");
# Line 1689  extern void Asc_ModuleWrite(FILE *f, CON Line 1615  extern void Asc_ModuleWrite(FILE *f, CON
1615  }  }
1616    
1617    
1618  /**  See the header file for this function's documentation  extern struct module_t *Asc_CurrentModuleF(void){
  **/  
 extern struct module_t *Asc_CurrentModuleF(void)  
 {  
1619    return g_current_module;    return g_current_module;
1620  }  }
1621    
1622    
1623  /**  See the header file for this function's documentation  extern CONST char *Asc_ModuleName(CONST struct module_t *m){
  **/  
 extern CONST char *Asc_ModuleName(CONST struct module_t *m)  
 {  
1624    return (( m != NULL ) ? SCP(m->name) : "");    return (( m != NULL ) ? SCP(m->name) : "");
1625  }  }
1626    
1627    
1628  /**  See the header file for this function's documentation  extern CONST char *Asc_ModuleFileName(CONST struct module_t *m){
  **/  
 extern CONST char *Asc_ModuleFileName(CONST struct module_t *m)  
 {  
1629    return ((m != NULL) ? SCP(m->filename) : "");    return ((m != NULL) ? SCP(m->filename) : "");
1630  }  }
1631    
1632  /**  See the header file for this function's documentation  extern CONST char *Asc_ModuleBestName(CONST struct module_t *m){
  **/  
 extern CONST char *Asc_ModuleBestName(CONST struct module_t *m)  
 {  
1633    static char unk[] = "<UNKNOWN>";    static char unk[] = "<UNKNOWN>";
1634    if (m == NULL) return "";    if (m == NULL) return "";
1635    if (SCP(m->filename) != NULL) return SCP(m->filename);    if (SCP(m->filename) != NULL) return SCP(m->filename);
# Line 1724  extern CONST char *Asc_ModuleBestName(CO Line 1638  extern CONST char *Asc_ModuleBestName(CO
1638  }  }
1639    
1640    
1641  /**  See the header file for this function's documentation  extern unsigned long Asc_ModuleTimesOpened(CONST struct module_t *m){
  **/  
 extern unsigned long Asc_ModuleTimesOpened(CONST struct module_t *m)  
 {  
1642    return ((m != NULL) ? (m->open_count) : 0);    return ((m != NULL) ? (m->open_count) : 0);
1643  }  }
1644    
1645    
1646  /**  See the header file for this function's documentation  extern struct tm *Asc_ModuleTimeModified(CONST struct module_t *m){
  **/  
 extern struct tm *Asc_ModuleTimeModified(CONST struct module_t *m)  
 {  
1647    return ((m != NULL) ? localtime(&(m->time_last_modified)) : NULL);    return ((m != NULL) ? localtime(&(m->time_last_modified)) : NULL);
1648  }  }
1649    
1650  /**  See the header file for this function's documentation  extern int Asc_ModuleStringIndex(CONST struct module_t *m){
  **/  
 extern int Asc_ModuleStringIndex(CONST struct module_t *m)  
 {  
1651    return ((m != NULL) ? (int)(m->time_last_modified) : -1);    return ((m != NULL) ? (int)(m->time_last_modified) : -1);
1652  }  }

Legend:
Removed from v.660  
changed lines
  Added in v.661

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22