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

  1. ;/* execute me to make with SAS 6.x compile v37 part
  2. sc NOSTKCHK CSRC aguidexrefv37.c OPT IGNORE=73
  3. slink lib:c.o aguidexrefv37.o //Goodies/extrdargs/extrdargs.o TO /c/aguidexrefv37 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: aguidexrefv37.c 0.14 (22.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. ** 22.09.94 : 000.014 :  now uses ENTRYA_NodeName for the guide nodename
  22. ** 08.09.94 : 000.013 :  workbench support added
  23. ** 07.08.94 : 000.012 :  now v37,v39 versions separatly
  24. ** 29.07.94 : 000.011 :  major changes to v39 version
  25. ** 12.06.94 : 000.010 :  font support for v39 version
  26. ** 10.06.94 : 000.009 :  file highlight added
  27. ** 05.06.94 : 000.008 :  now different tmpfiles and v39 datatype skeleton added
  28. ** 28.05.94 : 000.007 :  now uses the tags function
  29. ** 18.05.94 : 000.006 :  file support added
  30. ** 18.05.94 : 000.005 :  cachedir option added
  31. ** 14.05.94 : 000.004 :  XRefAddDynamicHost added
  32. ** 09.05.94 : 000.003 :  support of diffrent main pages (categories)
  33. ** 06.05.94 : 000.002 :  column support added
  34. ** 02.05.94 : 000.001 :  initial
  35. */
  36.  
  37.  
  38. #define OSV37     1
  39.  
  40. /* ------------------------------- includes ------------------------------- */
  41.  
  42. #include "aguidexref.h"
  43.  
  44. #include "aguidexrefv37_rev.h"
  45.  
  46. /* ------------------------------- AutoDoc -------------------------------- */
  47.  
  48. /*FS*/ /*"AutoDoc"*/
  49. /*GB*** XRef-Tools/AGuideXRefV37 *********************************************
  50.  
  51. $VER: AGuideXRefV37.doc
  52.  
  53. NAME
  54.     AGuideXRefV37 - searches the xref-lists for a given string/pattern and
  55.                     shows a amigaguide text for the found entries
  56.  
  57. TEMPLATE
  58.     STRING,CATEGORY,FILE/K,CACHEDIR/K,LINELENGTH/N/K,COLUMNS/N/K,LIMIT/N/K,
  59.     NOPATTERN/S,NOCASE/S,PUBSCREEN/K,PORTNAME/K
  60.  
  61. FORMAT
  62.     AGuideXRef [[STRING] string|pattern] [[CATEGORY] category] [FILE xreffile]
  63.                [CACHEDIR dir] [LIMIT maxentries] [LINELENGTH numchars] 
  64.                [COLUMNS numcolumns] [NOPATTERN] [NOCASE] [PUBSCREEN pubname]
  65.                [PORTNAME arexxportname]
  66.  
  67. FUNCTION
  68.     this command gives an CLI interface to the xref.library, which uses the
  69.     AmigaGuide system to display some found xref entries and have a link to
  70.     its real documentation.
  71.     If you specify the CACHEDIR, this directory will be used to save the
  72.     AmigaGuide files, if there are more the one entries for the given string
  73.     or pattern. Any next call with this CACHEDIR and the given string/pattern,
  74.     it will no longer call the xref.library function, but uses this file.
  75.     If you do not specify a CATEGORY all xreffiles in the xref.library are
  76.     parsed.From xref.library 1.8 the categorystring can be a pattern !
  77.  
  78. INPUTS
  79.     STRING (STRING) - string|pattern to search for
  80.  
  81.     CATEGORY (STRING) - category to parse (no specified category matches
  82.         all categories). Can be a pattern !
  83.  
  84.     FILE (STRING) - file to parse, this argument overrides the CATEGORY
  85.         argument
  86.  
  87.     CACHEDIR (STRING) - if you want to save all generated AmigaGuide files
  88.         to have a fast access to it, just specify here the directory, in which
  89.         these files will saved
  90.  
  91.     LIMIT (NUMBER) - specifies the maximal number of entries to match
  92.         (default : xref.library default (XREFBA_DefaultLimit))
  93.  
  94.     LINELENGTH (NUMBER) - specifies the number of chars for a line
  95.         (default : xref.library default (XREFBA_LineLength))
  96.  
  97.     COLUMNS (NUMBER) - specifies the number of columns, which will be used
  98.         if more than one entry matches
  99.         (default : xref.library default (XREFBA_Columns))
  100.  
  101.     NOPATTERN (BOOLEAN) - interprets the given string as a normal string
  102.         instead of a pattern
  103.  
  104.     NOCASE (BOOLEAN) - makes the search case-insensitive
  105.  
  106.     PUBSCREEN (STRING) - specifies the screen, on which the AmigaGuide window
  107.         should be opened
  108.  
  109. EXAMPLES
  110.     The following example searches all xreffiles of the AutoDoc category for
  111.     xrefentries with the word "Window" inside and tries to open a window on the
  112.     GoldEd Screen, if it has found some entry matches this pattern :
  113.  
  114.         AGuideXRefV37 #?Window#? #?AutoDoc#? PUBSCREEN=GOLDED.1
  115.  
  116. SEE ALSO
  117.     LoadXRef,MakeXRef,ParseXRef,dos.library/ParsePattern()
  118.  
  119. COPYRIGHT
  120.     by Stefan Ruppert (C) 1994
  121.  
  122. HISTORY
  123.     AGuideXRefV37 1.10 (22.9.94) :
  124.         - ENTRYA_NodeName wasn't used for the guide node. This is fixed !
  125.  
  126.     AGuideXRefV37 1.9 (8.9.94) :
  127.         - workbench support added
  128.  
  129.     AGuideXRefV37 1.8 (3.9.94) :
  130.         - some tagnames changed
  131.  
  132.     AGuideXRefV37 1.7 (10.8.94) :
  133.         - now V37,V39 versions are two programs
  134.  
  135.     AGuideXRef 1.6 (29.7.94) :
  136.         - major changes for V39 version
  137.         - entries now sorted to files
  138.  
  139.     AGuideXRef 1.5 (10.6.94) :
  140.         - File highlighted added
  141.  
  142.     AGuideXRef 1.4 (5.6.94) :
  143.         - now unique tempfiles
  144.         - V39 datatype skeleton
  145.         - V39 datatype entry with the FORCEV39 switch
  146.  
  147.     AGuideXRef 1.3 (28.5.94) :
  148.         - CACHEDIR and PORTNAME options added
  149.  
  150.     AGuideXRef 1.2 (20.5.94) :
  151.         - LINELENGTH and COLUMNS options added
  152.  
  153.     AGuideXRef 1.1 (10.5.94) :
  154.         - first beta release
  155.  
  156. *****************************************************************************/
  157. /*FE*/
  158.  
  159. /* ------------------------------ Prototypes ------------------------------ */
  160.  
  161. /*FS*/ /*"Prototypes"*/
  162.  
  163. void openamigaguide(struct GlobalData *gd);
  164.  
  165. /*FE*/
  166.  
  167. /* ------------------------- template definition -------------------------- */
  168.  
  169. /*FS*/ /*"Template Definition"*/
  170.  
  171. #define template "STRING,CATEGORY,FILE/K,CACHEDIR/K,LINELENGTH/N/K," \
  172.                  "COLUMNS/N/K,LIMIT/N/K,NOPATTERN/S,NOCASE/S," \
  173.                  "PUBSCREEN/K,PORTNAME/K"
  174.  
  175. enum {
  176.    ARG_STRING,     /* string to parse for */
  177.    ARG_CATEGORY,   /* category to parse \  mutual   */
  178.    ARG_FILE,       /* file to parse     / exclusive */
  179.    ARG_CACHEDIR,   /* diretory to hold amigaguide files for a specified STRING */
  180.    ARG_LINELENGTH, /* linelength for the amigaguide window */
  181.    ARG_COLUMNS,    /* columns to use for the amigaguide window */
  182.    ARG_LIMIT,      /* maximal number of entries */
  183.    ARG_NOPATTERN,  /* just a string instead of a pattern-string */
  184.    ARG_NOCASE,     /* ignore letter-case */
  185.    ARG_PUBSCREEN,  /* pubscreen to open the amigaguide window */
  186.    ARG_PORTNAME,   /* arexx portname to use */
  187.    ARG_MAX};
  188.  
  189. char *prgname = "AGuideXRefV37";
  190.  
  191. /*FE*/
  192.  
  193. /* ---------------------- include generic functions ----------------------- */
  194.  
  195. #include "aguidexref.c"
  196.  
  197. /* ---------------------- open an amigaguide window ----------------------- */
  198.  
  199. /*FS*//*"void openamigaguide(struct GlobalData *gd)"*/
  200. void openamigaguide(struct GlobalData *gd)
  201. {
  202.    struct Library *AmigaGuideBase;
  203.    struct NewAmigaGuide nag = {NULL};
  204.  
  205.    /* default node */
  206.    nag.nag_Node = "main";
  207.  
  208.    if(gd->gd_Num == 0)
  209.       nag.nag_Node = gd->gd_MainBuffer;
  210.    else if(gd->gd_Num == 1)
  211.    {
  212.       nag.nag_Node = gd->gd_LastEntry.e_NodeName;
  213.       nag.nag_Line = gd->gd_LastEntry.e_Line;
  214.  
  215.       sprintf(gd->gd_FileBuffer,"%s%s",gd->gd_LastEntry.e_Path,
  216.                                        gd->gd_LastEntry.e_File);
  217.    }
  218.  
  219.    gd->gd_Object = "amigaguide.library";
  220.    if(AmigaGuideBase = OpenLibrary(gd->gd_Object,34))
  221.    {
  222.       AMIGAGUIDECONTEXT handle;
  223.  
  224.       nag.nag_PubScreen  = (STRPTR) gd->gd_Para[ARG_PUBSCREEN];
  225.       nag.nag_ClientPort = (STRPTR) gd->gd_Para[ARG_PORTNAME];
  226.  
  227.       nag.nag_Name      = gd->gd_FileBuffer;
  228.  
  229.       DB(("file : %s\n",nag.nag_Name));
  230.       DB(("node : %s\n",nag.nag_Node));
  231.       DB(("line : %ld\n",nag.nag_Line));
  232.  
  233.       if(handle = OpenAmigaGuide(&nag, NULL))
  234.          CloseAmigaGuide(handle);
  235.  
  236.       CloseLibrary(AmigaGuideBase);
  237.    }
  238. }
  239. /*FE*/
  240.  
  241. /* ---------------------------- main function ----------------------------- */
  242.  
  243. /*FS*/ /*"int main(int ac,char *av[]) "*/
  244. int main(int ac,char *av[])
  245. {
  246.    struct ExtRDArgs eargs = {NULL};
  247.    struct GlobalData *gd;
  248.  
  249.    ULONG para[ARG_MAX];
  250.    STRPTR obj = prgname;
  251.    LONG err;
  252.  
  253.    LONG i;
  254.  
  255.    /* clear args buffer */
  256.    for(i = 0 ; i < ARG_MAX ; i++)
  257.       para[i] = 0;
  258.  
  259.    eargs.erda_Template      = template;
  260.    eargs.erda_Parameter     = para;
  261.    eargs.erda_FileParameter = ARG_FILE;
  262.  
  263.    if((err = ExtReadArgs(ac,av,&eargs)) == 0)
  264.    {
  265.       if(gd = AllocMem(sizeof(struct GlobalData) , MEMF_CLEAR))
  266.       {
  267.          obj = "xref.library";
  268.  
  269.          if(XRefBase = OpenLibrary(obj,0))
  270.          {
  271.             getstdargs(gd,para);
  272.  
  273.             parsexref(gd);
  274.  
  275.             openamigaguide(gd);
  276.  
  277.             /* last object that caused an error */
  278.             obj = gd->gd_Object;
  279.             err = gd->gd_Error;
  280.  
  281.             CloseLibrary(XRefBase);
  282.  
  283.             /* delete all tempory files */
  284.             while(gd->gd_TempCount > 0)
  285.             {
  286.                gd->gd_TempCount--;
  287.                DeleteFile(tmpname(gd));
  288.                gd->gd_TempCount--;
  289.             }
  290.          }
  291.          FreeMem(gd,sizeof(struct GlobalData));
  292.       }
  293.    }
  294.    ExtFreeArgs(&eargs);
  295.  
  296.    if(!err)
  297.       err = IoErr();
  298.  
  299.    if(err)
  300.    {
  301.       if(ac == 0)
  302.          showerror(prgname,obj,err);
  303.       else
  304.          PrintFault(err,obj);
  305.       return(RETURN_ERROR);
  306.    }
  307.  
  308.    return(RETURN_OK);
  309. }
  310. /*FE*/
  311.  
  312.