home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / misc / xref_v1.1.lha / XRef / Tools / source / loadxref.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-09  |  4.6 KB  |  183 lines

  1. ;/* execute me to make with SAS 6.x
  2. sc NOSTKCHK CSRC loadxref.c OPT IGNORE=73
  3. slink lib:c.o loadxref.o //Goodies/extrdargs/extrdargs.o TO /c/loadxref SMALLDATA SMALLCODE NOICONS LIB lib:amiga.lib lib:sc.lib /lib/xrefsupport.lib
  4. quit
  5. */
  6.  
  7. /*
  8. ** $PROJECT: XRef-Tools
  9. **
  10. ** $VER: loadxref.c 1.5 (04.09.94) 
  11. **
  12. ** by
  13. **
  14. ** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
  15. **
  16. ** (C) Copyright 1994
  17. ** All Rights Reserved !
  18. **
  19. ** $HISTORY:
  20. **
  21. ** 04.09.94 : 001.005 :  added workbench support FinalReadArgs()
  22. ** 06.07.94 : 001.004 :  index argument added
  23. ** 05.06.94 : 001.003 :  priority tag ignored if not specified
  24. ** 28.05.94 : 001.002 :  now uses the tags function
  25. ** 20.05.94 : 001.001 :  AutoDoc added
  26. ** 02.05.94 : 000.001 :  initial
  27. */
  28.  
  29. /* ------------------------------ includes -------------------------------- */
  30.  
  31. #include "Def.h"
  32.  
  33. #include "/lib/xrefsupport.h"
  34.  
  35. #include "loadxref_rev.h"
  36.  
  37. /* ---------------------------- version string ---------------------------- */
  38.  
  39. static char *version = VERSTAG;
  40. static char *prgname = "LoadXRef";
  41.  
  42. /* ------------------------------- AutoDoc -------------------------------- */
  43.  
  44. /*FS*/ /*"AutoDoc"*/
  45. /*GB*** XRef-Tools/LoadXRef **************************************************
  46.  
  47. $VER: LoadXRef.doc
  48.  
  49. NAME
  50.     LoadXRef - load a/some xreffiles for the xref.library into the memory
  51.  
  52. TEMPLATE
  53.     FILES/M/A,PRI/N/K,LOCK/S,INDEX/S
  54.  
  55. FORMAT
  56.     LoadXRef [FILES] file [file2 ..] [PRI priority] [LOCK] [INDEX]
  57.  
  58. FUNCTION
  59.     loads the given xreffiles into the memory. The priority is used to sort
  60.     the list of xreffiles.With the LOCK switch you can protect all xreffile 
  61.     from removing from memory during a memory flush.
  62.  
  63. INPUTS
  64.     FILES (STRINGS) - file(s) to be loaded into the memory
  65.  
  66.     PRI (NUMBER) - priority to be inserted in the list. Thus a high priority
  67.         inserts a xreffile before others and therefor is parsed before others
  68.         with lower priority
  69.  
  70.     LOCK (BOOLEAN) - if set, it locks all given xreffiles. Thus such files
  71.         are not expunged during a system memory flush.
  72.  
  73.     INDEX (BOOLEAN) - if set, the xref.library creates a index array for all
  74.         entries and uses for normal strcmp() , strncmp() a binary search
  75.         algorithm !
  76.  
  77. SEE ALSO
  78.     ExpungeXRef, ParseXRef, AGuideXRefV37, AGuideXRefV39, MakeXRef, XRefAttrs
  79.  
  80. COPYRIGHT
  81.     by Stefan Ruppert (C) 1994
  82.  
  83. HISTORY
  84.     LoadXRef 1.6 (22.9.94) :
  85.         - CATEGORY option removed , use this in MakeXRef
  86.  
  87.     LoadXRef 1.5 (4.9.94) :
  88.         - added workbench support FinalReadArgs() function
  89.  
  90.     LoadXRef 1.4 (6.7.94) :
  91.         - Index argument added UNLOCK option removed
  92.  
  93.     LoadXRef 1.3 (5.6.94) :
  94.         - now ignores priority if not specified
  95.  
  96.     LoadXRef 1.2 (28.5.94) :
  97.         - LOCK and UNLOCK options added
  98.  
  99.     LoadXRef 1.1 (20.5.94) :
  100.         - first beta release
  101.  
  102. *****************************************************************************/
  103. /*FE*/
  104.  
  105. /* ------------------------- template definition -------------------------- */
  106.  
  107. #define USETAG(tag,check)     ((check) ? (tag) : TAG_IGNORE)
  108.  
  109. #define template "FILES/M/A,XREFPRI/N/K,LOCK/S,INDEX/S"
  110.  
  111. enum {
  112.    ARG_FILES,
  113.    ARG_XREFPRI,
  114.    ARG_LOCK,
  115.    ARG_INDEX,
  116.    ARG_MAX};
  117.  
  118. /* --------------------------- main entry point --------------------------- */
  119.  
  120. int main(int ac,char *av[])
  121. {
  122.    struct ExtRDArgs eargs = {NULL};
  123.  
  124.    struct Library *XRefBase;
  125.    ULONG para[ARG_MAX];
  126.    LONG err;
  127.    STRPTR obj = prgname;
  128.  
  129.    LONG lock = -1;
  130.    LONG i;
  131.  
  132.    /* clear args buffer */
  133.    for(i = 0 ; i < ARG_MAX ; i++)
  134.       para[i] = 0;
  135.  
  136.    eargs.erda_Template      = template;
  137.    eargs.erda_Parameter     = para;
  138.    eargs.erda_FileParameter = ARG_FILES;
  139.  
  140.    if((err = ExtReadArgs(ac,av,&eargs)) == 0)
  141.    {      
  142.       obj = "xref.library";
  143.       if(XRefBase = OpenLibrary(obj,0))
  144.       {
  145.          STRPTR *files = (STRPTR *) para[ARG_FILES];
  146.  
  147.          obj = prgname;
  148.  
  149.          if(para[ARG_LOCK])
  150.             lock = XREF_LOCK;
  151.  
  152.          while(*files)
  153.          {
  154.             if(!XR_LoadXRefTags(*files,XREFA_Index                              ,para[ARG_INDEX],
  155.                                        USETAG(XREFA_Lock,(lock!=-1))            , lock,
  156.                                        USETAG(XREFA_Priority,para[ARG_XREFPRI]) ,(para[ARG_XREFPRI]) ? (*((LONG *) para[ARG_XREFPRI])) : 0,
  157.                                        TAG_DONE))
  158.                break;
  159.  
  160.             files++;
  161.          }
  162.          CloseLibrary(XRefBase);
  163.       }
  164.    }
  165.    ExtFreeArgs(&eargs);
  166.  
  167.    if(!err)
  168.       err = IoErr();
  169.  
  170.    if(err)
  171.    {
  172.       if(ac == 0)
  173.          showerror(prgname,obj,err);
  174.       else
  175.          PrintFault(err,obj);
  176.  
  177.       return(RETURN_ERROR);
  178.    }
  179.  
  180.    return(RETURN_OK);
  181. }
  182.  
  183.