home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / monitors / rsys / source.lha / src / RSysSpecialList.c < prev    next >
C/C++ Source or Header  |  1995-01-09  |  7KB  |  293 lines

  1. /*
  2. ***************************************************************************
  3. *
  4. * Datei:
  5. *    RSysSpecialList.c
  6. *
  7. * Inhalt:
  8. *    void RSysAmigaGuideRefList(void);
  9. *    void SysBrokerList(void);
  10. *    void SysAvailFontsList(void);
  11. *
  12. * Bemerkungen:
  13. *    Spezielle Listen, die unter keine der anderen Kategorien fallen.
  14. *
  15. * Erstellungsdatum:
  16. *    07-Jul-93    Rolf Böhme
  17. *
  18. * Änderungen:
  19. *    07-Jul-93    Rolf Böhme    Erstellung
  20. *
  21. ***************************************************************************
  22. */
  23.  
  24. #include "RSysDebug.h"
  25. #include "RSysFunc.h"
  26.  
  27.  
  28. void
  29. RSysAmigaGuideRefList(void)
  30. {
  31.    struct List listbuff, *list = &listbuff;
  32.    struct Node *node;
  33.    struct XRef *xrefnode;
  34.    LONG key;
  35.    register int i;
  36.    UBYTE *fpart, filename[16];
  37.    char *XRefTypes[] = {
  38.       "LINK", "FUNC", "COMM", "INCL", "MACR",
  39.       "STRU", "FIEL", "TYPD", "DEFI"
  40.    };
  41.  
  42.    PrintHeader(AGUIDEXREF, NULL);
  43.  
  44.    EmptyListView();
  45.  
  46.    countentries = 0;
  47.  
  48.    if (AmigaGuideBase = (struct AmigaGuideBase *)OpenLibrary ((STRPTR)"amigaguide.library", 33))
  49.    {
  50.       key = LockAmigaGuideBase(NULL);
  51.  
  52.       if (GetAmigaGuideAttr(AGA_XRefList, NULL, (ULONG *)&list))
  53.       {
  54.          countentries = CountNodes(list);
  55.  
  56.          if (!NoEntries())
  57.          {
  58.             Entries = AllocScrollEntries(countentries);
  59.  
  60.             for(node = list->lh_Head, i = 0; node->ln_Succ && (i < countentries);
  61.                 node = node->ln_Succ, i++)
  62.             {
  63.                xrefnode = (struct XRef *)node;
  64.  
  65.                fpart = FilePart(xrefnode->xr_File);
  66.  
  67.                if(fpart != xrefnode->xr_File)
  68.                   sprintf((char *)filename,"+%-14s.14s",fpart);
  69.                else
  70.                   strncpy((char *)filename, (char *)xrefnode->xr_File, 15);
  71.  
  72.                sprintf(Entries[i].se_Entry, EntryAttr[32].ea_dataformat,
  73.                        xrefnode->xr_Name, XRefTypes[node->ln_Type],
  74.                        filename, xrefnode->xr_Line);
  75.             }
  76.  
  77.             CreateEntryList(SORT);
  78.          }
  79.       }
  80.  
  81.       UnlockAmigaGuideBase(key);
  82.  
  83.       CloseLibrary((struct Library *)AmigaGuideBase);
  84.    }
  85.    else
  86.       ErrorHandle(LIBRARY_ERR, OPEN_FAIL, KILL);
  87.  
  88.    PrintStatistics();
  89.  
  90.    return;
  91. }
  92.  
  93. /*
  94.  * Das sind die neuen Funktionen, die ich mit pragmas einbinde. Damit
  95.  * entfällt auch gleich das Prototyping. Alle Daten können mit dem
  96.  * Exchange-Programm überprüft werden. Die Funktionen sind in den fd-Files
  97.  * als private gekennzeichnet, was aber kein Prob sein sollte :-) Den
  98.  * Namen und die Übergaberegisterbelegung entnahm ich dem Program
  99.  * LIBSearcher v2.01 von Joep Grooten (lib201).
  100.  */
  101.  
  102. /*
  103.  * FindBroker() gibt die Adresse des Brokers zurück, dessen Name in a0
  104.  * übergeben werden muß.
  105. #pragma amicall(CxBase, 108, FindBroker(a0))
  106. struct Node *FindBroker(STRPTR name);
  107.  */
  108.  
  109. /*
  110.  * CopyBrokerList() kopiert den Listenkopf der Knoten mit den Commodities
  111.  * in eine zu übergebene mit MEMF_PUBLIC allozierte Liste. Offenbar gibt
  112.  * die Funktion die Anzahl der eingetragenen Commodities zurück. Die Liste
  113.  * scheint eine einfache normale struct List zu sein, ebenso wie die
  114.  * Knoten. Jedenfalls gibts beim Auslesen keine Probleme.
  115. #pragma amicall(CxBase, 186, CopyBrokerList(a0))
  116. LONG  CopyBrokerList(struct List *bList);
  117.  */
  118.  
  119. /*
  120.  * FreeBrokerList() scheint den Inhalt der allozierten Liste wieder
  121.  * freizugeben. Allerdings sind Seiteneffekte zu vermuten. Vielleicht wird
  122.  * auch die Commodities-Liste gekillt!
  123. #pragma amicall(CxBase, 192, FreeBrokerList(a0))
  124. void  FreeBrokerList(struct List *bList);
  125.  */
  126.  
  127. #define MAX_BROKER_ENTRIES 40
  128.  
  129. void
  130. SysBrokerList(void)
  131. {
  132.    struct Node *node,
  133.         *nodes[MAX_BROKER_ENTRIES],
  134.         *StartNode,
  135.         *foundBroker = NULL;
  136.    char  name[MAX_BROKER_ENTRIES][22];
  137.    int   pri[MAX_BROKER_ENTRIES],
  138.          i,
  139.          cnt;
  140.    extern CxObj *broker;
  141.  
  142.    PrintHeader(COMMODITIES, NULL);
  143.  
  144.    EmptyListView();
  145.  
  146.       /*
  147.        * Analog zu FindName() oder FindPort() kann auch hier ein
  148.        * Schutzprotokoll nötig sein. Da Commodities auch mit Interrupts
  149.        * arbeiten müssen (InputHandler!), sollte gleich mit
  150.        * Disable()/Enable() hingelangt werden!
  151.        */
  152.    Disable();
  153. /*   foundBroker = FindBroker((STRPTR) "RSys");*/
  154.  
  155.    foundBroker = (struct Node *)broker;
  156.  
  157.    for (node = foundBroker; node->ln_Pred; node = node->ln_Pred)
  158.       StartNode = node;
  159.  
  160.    for (node = StartNode, cnt = 0;
  161.         node->ln_Succ && (cnt < MAX_BROKER_ENTRIES);
  162.         node = node->ln_Succ)
  163.    {
  164.          /*
  165.           * Vitale Daten kopieren; der Type ist unbekannt! Damit
  166.           * dennoch die Namen ausgegeben werden können, übergebe ich
  167.           * einfach den Node-Typen.
  168.           */
  169.       savestrcpy(name[cnt], node, 22, (int)node->ln_Type);
  170.  
  171.       pri[cnt]       = node->ln_Pri;
  172.       nodes[cnt++]   = node;
  173.    }
  174.  
  175.    Enable();
  176.  
  177.    countentries = cnt;
  178.  
  179.    if(NoEntries())
  180.       return;
  181.  
  182.    Entries = AllocScrollEntries(countentries);
  183.  
  184.    for (i = 0; i < cnt; i++)
  185.    {
  186.       sprintf(Entries[i].se_Entry,
  187.               EntryAttr[26].ea_dataformat,
  188.               name[i],
  189.               pri[i]);
  190.  
  191.       AddNodeToList(i, SORT);
  192.    }
  193.  
  194.    PrintStatistics();
  195.  
  196.    return;
  197. }
  198.  
  199.    /*
  200.     * SysAvailFontsList() listet alle Fonts im Verzeichnis
  201.     * FONTS: auf
  202.     */
  203. void
  204. SysAvailFontsList(void)
  205. {
  206.    char  Style[MAXSHOW];
  207.    char *Type[5] =
  208.    {
  209.       "-", "ROM", "DISK", "-", "SCAL"
  210.    };
  211.    struct AvailFontsHeader *afh;
  212.    struct AvailFonts *AF;
  213.    int   extrabytes,
  214.          initialsize = sizeof(struct AvailFontsHeader),
  215.          i;
  216.  
  217.    DPOS;
  218.  
  219.    PrintHeader(ALLFONTS, NULL);
  220.  
  221.    EmptyListView();
  222.  
  223.    PrintInfo("Read all Fonts", NO_SPEAK, 0);
  224.  
  225.    do
  226.    {
  227.       afh = (struct AvailFontsHeader *)
  228.             MyAllocVec(initialsize, MEMF_CLEAR | MEMF_ANY, KILL);
  229.  
  230.       if (afh)
  231.       {
  232.          extrabytes = AvailFonts((STRPTR) afh, initialsize, AFF_DISK);
  233.          if (extrabytes)
  234.          {
  235.             MyFreeVec(afh);
  236.             initialsize += extrabytes;
  237.          }
  238.       }
  239.    }
  240.    while (extrabytes);
  241.  
  242.    countentries = afh->afh_NumEntries;
  243.  
  244.    if (NoEntries())
  245.       return;
  246.  
  247.    Entries = AllocScrollEntries(countentries);
  248.  
  249.    AF = (struct AvailFonts *) & (afh[1]);
  250.  
  251.    for (i = 0; i < countentries; i++)
  252.    {
  253.       strcpy(Style, "       ");
  254.  
  255.       if (!(AF[i].af_Attr.ta_Style & FS_NORMAL))
  256.          Style[0] = 'N';
  257.  
  258.       if (AF[i].af_Attr.ta_Style & FSF_UNDERLINED)
  259.          Style[1] = 'U';
  260.  
  261.       if (AF[i].af_Attr.ta_Style & FSF_BOLD)
  262.          Style[2] = 'B';
  263.  
  264.       if (AF[i].af_Attr.ta_Style & FSF_ITALIC)
  265.          Style[3] = 'I';
  266.  
  267.       if (AF[i].af_Attr.ta_Style & FSF_EXTENDED)
  268.          Style[4] = 'E';
  269.  
  270.       if (AF[i].af_Attr.ta_Style & FSF_COLORFONT)
  271.          Style[5] = 'C';
  272.  
  273.       if (AF[i].af_Attr.ta_Style & FSF_TAGGED)
  274.          Style[6] = 'T';
  275.  
  276.       Style[7] = STRINGEND;
  277.  
  278.       sprintf(Entries[i].se_Entry, EntryAttr[17].ea_dataformat,
  279.               AF[i].af_Attr.ta_Name,
  280.               Type[AF[i].af_Type],
  281.               AF[i].af_Attr.ta_YSize,
  282.               Style);
  283.  
  284.       AddNodeToList(i, SORT);
  285.    }
  286.  
  287.    MyFreeVec(afh);
  288.  
  289.    PrintStatistics();
  290.  
  291.    return;
  292. }
  293.