home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 553.lha / NewAvailFonts / NewAF.c < prev    next >
C/C++ Source or Header  |  1991-09-09  |  4KB  |  174 lines

  1. /* NewAF.c -
  2.  * compiled with SASC 5.10a
  3.  * LC -b0 -cfist -v NewAF.c
  4.  * Blink FROM LIB:c.o,NewAF.o TO NewAF LIBRARY LIB:LC.lib,LIB:Amiga.lib
  5.  *
  6.  * Écrit par Jean-Michel Bezeau © 1991
  7.  * Ceci est la version modifié de l'exemple de commodité paru dans AmigaMail
  8.  *
  9.  * Création:    1991-08-14
  10.  *
  11.  */
  12. #include <exec/libraries.h>
  13. #include <libraries/commodities.h>
  14. #include <dos/dos.h>
  15. #include <dos/dostags.h>
  16. //#include <proto/exec.h>
  17. #include <clib/exec_protos.h>
  18. #include <pragmas/exec.h>
  19. #include <proto/dos.h>
  20. #include <proto/commodities.h>
  21. #include <libraries/diskfont.h>
  22. #include <clib/alib_protos.h>
  23. #include <clib/alib_stdio_protos.h>
  24.  
  25. #include <string.h>
  26.  
  27. int CXBRK(void) { return(0); }    /* Disable Lattice CTRL/C handling */
  28. int chkabort(void) { return(0); }
  29.  
  30. struct Library *CxBase, *IconBase;
  31.  
  32. struct MsgPort *Broker_mp;
  33.  
  34. S Library    *DFBase;
  35.  
  36. CxObj *Broker;
  37.  
  38. char Version[] = "NewAF v1.0 © Jean-Michel Bezeau 1991\0$VER: NewAF 1.0 (14-08-91)";
  39.  
  40. struct NewBroker NewBroker = {
  41.     NB_VERSION,
  42.     "NewAF",                        /* string to identify this broker */
  43.     Version,
  44.     "Patch system to force CG fonts",
  45.     NBU_UNIQUE | NBU_NOTIFY,        /* Don't want any new commodities
  46.                                      * starting with this    name.  If someone
  47.                                      * tries it, let me know */
  48.     0,
  49.     0,
  50.     0,
  51.     0
  52. };
  53.  
  54. ULONG cxsigflag;
  55.  
  56. //#pragma libcall DiskfontBase AvailFonts 24 10803
  57. LONG (* __asm __saveds oldAvailFonts) (    register __a0 struct AvailFontsHeader *buffer,
  58.                                         register __d0 LONG bufBytes,
  59.                                         register __d1 ULONG flags,
  60.                                         register __a6 ULONG base );
  61.  
  62.  
  63. /* ------------------------------------------------------------------------    */
  64. LONG __asm __saveds newAvailFonts(    register __a0 struct AvailFontsHeader *buffer,
  65.                                     register __d0 LONG bufBytes,
  66.                                     register __d1 ULONG flags,
  67.                                     register __a6 ULONG base )
  68. {
  69.     if (flags == 0xff)    // Pour prowrite
  70.         flags = AFF_SCALED | AFF_DISK | AFF_MEMORY;
  71.  
  72.     flags |= AFF_SCALED;
  73.  
  74.     return oldAvailFonts (buffer, bufBytes, flags, base);
  75. }
  76.  
  77. /* ------------------------------------------------------------------------    */
  78. LONG ProcessMsg(void)
  79. {
  80. extern struct MsgPort *Broker_mp;
  81. extern CxObj *Broker;
  82.  
  83. extern ULONG cxsigflag;
  84.  
  85. CxMsg *msg;
  86.  
  87. ULONG sigrcvd, msgid, msgtype;
  88. LONG returnvalue = 1L;
  89.  
  90.     sigrcvd = Wait(SIGBREAKF_CTRL_C | cxsigflag);
  91.  
  92.     while(msg = (CxMsg *)GetMsg(Broker_mp)) {
  93.         msgid = CxMsgID(msg);
  94.         msgtype = CxMsgType(msg);
  95.         ReplyMsg((struct Message *)msg);
  96.  
  97.         switch(msgtype) {
  98.             case CXM_COMMAND:
  99.                 switch(msgid) {
  100.                     case CXCMD_DISABLE:
  101.                         if (oldAvailFonts != NULL) {
  102.                             SetFunction (DFBase, -(0x24), (APTR)oldAvailFonts);
  103.                             oldAvailFonts = NULL;
  104.                             ActivateCxObj(Broker, 0L);
  105.                             }
  106.                         break;
  107.  
  108.                     case CXCMD_ENABLE:
  109.                         if (oldAvailFonts == NULL) {
  110.                             oldAvailFonts = SetFunction (DFBase, -(0x24), (APTR)newAvailFonts);
  111.                             ActivateCxObj(Broker, 1L);
  112.                             }
  113.                         break;
  114.  
  115.                     case CXCMD_KILL:
  116.                         returnvalue = 0L;
  117.                         break;
  118.  
  119.                     case CXCMD_UNIQUE:        // Pour être tout seul à rouler sous ce nom
  120.                         returnvalue = 0L;
  121.                         break;
  122.                     default:
  123.                         break;
  124.                     }
  125.                 break;
  126.  
  127.             default:
  128.                 break;
  129.             }
  130.         }
  131.  
  132.  
  133.     if (sigrcvd & SIGBREAKF_CTRL_C) {
  134.         returnvalue = 0L;
  135.         }
  136.  
  137.     return(returnvalue);
  138. }
  139.  
  140. /* ------------------------------------------------------------------------    */
  141. void main(int argc, char **argv)
  142. {
  143.     if (CxBase = OpenLibrary("commodities.library", 37L)) {
  144.         if (Broker_mp = CreateMsgPort()) {
  145.             NewBroker.nb_Port =    Broker_mp;
  146.             cxsigflag = 1L << Broker_mp->mp_SigBit;
  147.  
  148.             if (Broker = CxBroker(&NewBroker, NULL)) {
  149.                 DFBase = OpenLibrary ("diskfont.library", 37L);
  150.                 if (DFBase != NULL) {
  151.                     oldAvailFonts = SetFunction (DFBase, -(0x24), (APTR)newAvailFonts);
  152.  
  153.                     ActivateCxObj(Broker, 1L);
  154.                     while (ProcessMsg());
  155.  
  156.                     DeleteCxObj(Broker);
  157.  
  158.                     if (oldAvailFonts != NULL)
  159.                         SetFunction (DFBase, -(0x24), (APTR)oldAvailFonts);
  160.  
  161.                     CloseLibrary (DFBase);
  162.                     }
  163.                 }
  164.             DeleteMsgPort(Broker_mp);
  165.             }
  166.  
  167.         CloseLibrary(CxBase);
  168.         }
  169.  
  170.     return;
  171. }
  172.  
  173.  
  174.