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

  1. ;/* execute me to make with SAS 6.x
  2. sc NOSTKCHK CSRC statxref.c OPT IGNORE=73
  3. slink lib:c.o statxref.o //Goodies/extrdargs/extrdargs.o TO /c/statxref 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: statxref.c 1.4 (24.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. ** 24.09.94 : 001.004 :  category output now 15 characters wide instead of 10
  22. ** 08.09.94 : 001.003 :  workbench support added
  23. ** 05.06.94 : 001.002 :  adaption to the xref.library
  24. ** 27.04.94 : 001.001 :  initial
  25. */
  26.  
  27. /* ------------------------------- includes ------------------------------- */
  28.  
  29. #include "Def.h"
  30.  
  31. #include <libraries/xref.h>
  32. #include <clib/xref_protos.h>
  33. #include <pragmas/xref_pragmas.h>
  34.  
  35. #include <debug.h>
  36.  
  37. #include "/lib/xrefsupport.h"
  38.  
  39. #include "statxref_rev.h"
  40.  
  41. /* ------------------------------- autodoc -------------------------------- */
  42.  
  43. /*FS*/ /*"AutoDoc"*/
  44. /*GB*** XRef-Tools/StatXRef **************************************************
  45.  
  46. $VER: StatXRef.doc
  47.  
  48. NAME
  49.     StatXRef - outputs information of the current settings of the xref.library
  50.  
  51. TEMPLATE
  52.     FILES/S
  53.  
  54. FORMAT
  55.     StatXRef [FILES]
  56.  
  57. FUNCTION
  58.     This command outputs information about the current settings of the
  59.     xref.library. The global path for xreffiles,the number of xref files
  60.     in memory, the linelength and column number for the dynamic node layout.
  61.     And optional if you specify the FILES switch, the information about the
  62.     single xref file like the name, length , priority and the lock status.
  63.  
  64. INPUTS
  65.     FILES (BOOLEAN) - output detail information about the xref files
  66.  
  67. SEE ALSO
  68.     LoadXRef, ExpungeXRef, XRefAttrs
  69.  
  70. HISTORY
  71.     StatXRef 1.5 (24.9.94) :
  72.         - category output no 15 charaters wide , instead of 10 charaters
  73.  
  74.     StatXRef 1.4 (8.9.94) :
  75.         - workbench support added
  76.  
  77.     StatXRef 1.3 (9.7.94) :
  78.         - Index and Global Path output added
  79.     
  80.     StatXRef 1.2 (5.6.94) :
  81.         - FILES option added
  82.  
  83. *****************************************************************************/
  84. /*FE*/
  85.  
  86. /* ---------------------------- constant items ---------------------------- */
  87.  
  88. static char *version = VERSTAG;
  89. static char *prgname = "StatXRef";
  90.  
  91. /* ------------------------- template definition -------------------------- */
  92.  
  93. #define template       "FILES/S"
  94.  
  95. enum {
  96.    ARG_FILES,
  97.    ARG_MAX};
  98.  
  99. int main(int ac,char *av[])
  100. {
  101.    struct ExtRDArgs eargs = {NULL};
  102.    struct Library *XRefBase;
  103.  
  104.    ULONG para[ARG_MAX];
  105.    STRPTR obj = prgname;
  106.    ULONG err;
  107.  
  108.    struct List *list;
  109.    struct Node *xrnode;
  110.  
  111.    STRPTR xrefdir   = NULL;
  112.    UWORD linelength = 0;
  113.    UWORD columns    = 0;
  114.    ULONG num        = 0;
  115.    ULONG limit      = 0;
  116.  
  117.    ULONG handle;
  118.  
  119.    LONG i;
  120.  
  121.    /* clear args buffer */
  122.    for(i = 0 ; i < ARG_MAX ; i++)
  123.       para[i] = 0;
  124.  
  125.    eargs.erda_Template      = template;
  126.    eargs.erda_Parameter     = para;
  127.    eargs.erda_FileParameter = -1;
  128.  
  129.    if((err = ExtReadArgs(ac,av,&eargs)) == 0)
  130.    {
  131.       obj = "xref.library";
  132.       if(XRefBase = OpenLibrary(obj,1))
  133.       {
  134.          struct Buffer *buf;
  135.  
  136.          handle = LockXRefBase(0);
  137.  
  138.          if(GetXRefBaseAttrs(XREFBA_List         ,&list,
  139.                              XREFBA_LineLength   ,&linelength,
  140.                              XREFBA_Columns      ,&columns,
  141.                              XREFBA_DefaultLimit ,&limit,
  142.                              XREFBA_XRefDir      ,&xrefdir,
  143.                              TAG_DONE) == 5)
  144.          if((buf = AllocMem(sizeof(struct Buffer),MEMF_ANY)))
  145.          {
  146.             buf->b_Ptr = buf->b_Buffer;
  147.  
  148.             mysprintf(buf,"xref.library v%ld.%ld\n\n",XRefBase->lib_Version,
  149.                                                       XRefBase->lib_Revision);
  150.  
  151.             for(xrnode = list->lh_Head ;
  152.                 xrnode->ln_Succ ;
  153.                 xrnode = xrnode->ln_Succ)
  154.                num++;
  155.  
  156.             mysprintf(buf,"XRefFile Dir        : %s\n"
  157.                           "Number of XRefFiles : %10ld\n"
  158.                           "Default Entry Limit : %10ld\n"
  159.                           "DNode LineLength    : %10ld\n"
  160.                           "DNode Columns       : %10ld\n\n",
  161.                            xrefdir,num,limit,linelength,columns);
  162.  
  163.             if(para[ARG_FILES])
  164.             {
  165.                STRPTR category;
  166.                STRPTR name;
  167.                ULONG length;
  168.                BOOL index;
  169.                BOOL lock;
  170.                BYTE pri;
  171.  
  172.                mysprintf(buf,"\n%-31s %15s %8s %8s %6s %6s\n\n","XRefFile",
  173.                                                                 "Category",
  174.                                                                 "Length",
  175.                                                                 "Priority",
  176.                                                                 "Locked",
  177.                                                                 "Index");
  178.  
  179.                for(xrnode = list->lh_Head ;
  180.                    xrnode->ln_Succ ;
  181.                    xrnode = xrnode->ln_Succ)
  182.                {
  183.                   if(GetXRefFileAttrs((struct XRefFileNode *) xrnode,
  184.                                       XREFA_Category,&category,
  185.                                       XREFA_Length  ,&length,
  186.                                       XREFA_Name    ,&name,
  187.                                       XREFA_Index   ,&index,
  188.                                       XREFA_Lock    ,&lock,
  189.                                       XREFA_Priority,&pri,
  190.                                       TAG_DONE) == 6)
  191.                   {
  192.                      mysprintf(buf,"%-31s %15s %8ld %8ld %6s %6s\n",name,category,length,pri,
  193.                                                                     (lock)  ? "Yes" : "No",
  194.                                                                     (index) ? "Yes" : "No");
  195.                   }
  196.                }
  197.             }
  198.  
  199.             if(ac == 0)
  200.             {
  201.                struct EasyStruct es = {
  202.                   sizeof(struct EasyStruct),
  203.                   0,
  204.                   NULL,
  205.                   "%s",
  206.                   "Ok"};
  207.  
  208.                es.es_Title = prgname;
  209.  
  210.                EasyRequest(NULL,&es,NULL,buf->b_Buffer);
  211.             } else
  212.                PutStr(buf->b_Buffer);
  213.  
  214.             FreeMem(buf,sizeof(struct Buffer));
  215.          }
  216.  
  217.          UnlockXRefBase(handle);
  218.  
  219.          CloseLibrary(XRefBase);
  220.       }
  221.    }
  222.    ExtFreeArgs(&eargs);
  223.  
  224.    if(!err)
  225.       err = IoErr();
  226.  
  227.    if(err)
  228.    {
  229.       if(ac == 0)
  230.          showerror(prgname,obj,err);
  231.       else
  232.          PrintFault(err,obj);
  233.  
  234.       return(RETURN_ERROR);
  235.    }
  236.  
  237.    return(RETURN_OK);
  238. }
  239.  
  240.