home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / comm / qamitrack / source / trackrexx_rxif.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-19  |  14.0 KB  |  412 lines

  1. /*
  2.  * Source generated with ARexxBox 1.12 (May 18 1993)
  3.  * which is Copyright (c) 1992,1993 Michael Balzer
  4.  */
  5.  
  6. #include <exec/types.h>
  7. #include <exec/memory.h>
  8. #include <dos/dos.h>
  9. #include <rexx/storage.h>
  10. #include <rexx/rxslib.h>
  11.  
  12. #ifdef __GNUC__
  13. /* GCC needs all struct defs */
  14. #include <dos/exall.h>
  15. #include <graphics/graphint.h>
  16. #include <intuition/classes.h>
  17. #include <devices/keymap.h>
  18. #include <exec/semaphores.h>
  19. #endif
  20.  
  21. #include <clib/alib_protos.h>
  22. #include <clib/exec_protos.h>
  23. #include <clib/dos_protos.h>
  24. #include <clib/rexxsyslib_protos.h>
  25.  
  26. #ifndef __NO_PRAGMAS
  27.  
  28. #ifdef AZTEC_C
  29. #include <pragmas/exec_lib.h>
  30. #include <pragmas/dos_lib.h>
  31. #include <pragmas/rexxsyslib_lib.h>
  32. #endif
  33.  
  34. #ifdef LATTICE
  35. #include <pragmas/exec_pragmas.h>
  36. #include <pragmas/dos_pragmas.h>
  37. #include <pragmas/rexxsyslib_pragmas.h>
  38. #endif
  39.  
  40. #endif /* __NO_PRAGMAS */
  41.  
  42. #include <stdlib.h>
  43. #include <stdio.h>
  44. #include <string.h>
  45. #include <ctype.h>
  46.  
  47. #ifdef LATTICE
  48. #undef toupper
  49. #define inline __inline
  50. #endif
  51.  
  52. #ifdef __GNUC__
  53. #undef toupper
  54. static inline char toupper( char c )
  55. {
  56.     return( islower(c) ? c - 'a' + 'A' : c );
  57. }
  58. #endif
  59.  
  60. #ifdef AZTEC_C
  61. #define inline
  62. #endif
  63.  
  64. #include "TrackRexx.h"
  65. #include "TrackRexx_rxif.h"
  66.  
  67. extern struct ExecBase *SysBase;
  68. extern struct DosLibrary *DOSBase;
  69. extern struct RxsLib *RexxSysBase;
  70.  
  71.  
  72. /* $ARB: I 848528372 */
  73.  
  74.  
  75. /* $ARB: B 17 QUIT */
  76. void rx_quit( struct RexxHost *host, struct rxd_quit **rxd, long action, struct RexxMsg *rexxmsg )
  77. {
  78.     struct rxd_quit *rd = *rxd;
  79.  
  80.     switch( action )
  81.     {
  82.         case RXIF_INIT:
  83.             *rxd = AllocVec( sizeof *rd, MEMF_CLEAR );
  84.             break;
  85.             
  86.         case RXIF_ACTION:
  87.             /* Insert your CODE here */
  88.             SetTrackFlag(CODE_QUIT);
  89.             rd->rc = RETURN_OK;
  90.             break;
  91.         
  92.         case RXIF_FREE:
  93.             /* FREE your local data here */
  94.             FreeVec( rd );
  95.             break;
  96.     }
  97.     return;
  98. }
  99. /* $ARB: E 17 QUIT */
  100.  
  101. /* $ARB: B 24 GET */
  102. void rx_get( struct RexxHost *host, struct rxd_get **rxd, long action, struct RexxMsg *rexxmsg )
  103. {
  104.     struct rxd_get *rd = *rxd;
  105.     int o = 0, i;
  106.     BOOL BMemErr = FALSE;
  107.     
  108.     switch( action )
  109.     {
  110.         case RXIF_INIT:
  111.             *rxd = AllocVec( sizeof *rd, MEMF_CLEAR );
  112.             if( rd = *rxd )
  113.             {
  114.                 /* set your DEFAULTS here */
  115.             }
  116.             break;
  117.             
  118.         case RXIF_ACTION:
  119. #define SetNextPtr(VAR, ARRAY) {rd->res.VAR = &rd->res.ARRAY[o++];}
  120.             /* Insert your CODE here */
  121.             UNLESS(
  122.               (rd->res.server     = strdup(szServerName))&&
  123.               (rd->res.comment    = strdup(myInfo->comment->buffer))&&
  124.               (rd->res.username   = strdup(myInfo->userName->buffer))&&
  125.               (rd->res.realname   = strdup(myInfo->realName->buffer))&&
  126.               (rd->res.logfile    = strdup(szLogFileName))&&
  127.               (rd->res.loglevel   = strdup(GetOutputLevelName(nLogLevel)))&&
  128.               (rd->res.viewby     = strdup(GetViewByName(nViewBy)))&&
  129.               (rd->res.visibleto  = strdup(szAccessTo))&&
  130.               (rd->res.logonscript     = strdup(rexxScripts[LOG_LOGON]))&&
  131.               (rd->res.logoffscript    = strdup(rexxScripts[LOG_LOGOFF]))&&
  132.               (rd->res.updatescript    = strdup(rexxScripts[LOG_UPDATE]))&&
  133.               (rd->res.connectscript   = strdup(rexxScripts[LOG_CONNECT]))&&
  134.               (rd->res.disconnectscript= strdup(rexxScripts[LOG_DISCONNECT]))&&
  135.               (rd->res.endscript       = strdup(rexxScripts[LOG_END]))&&
  136.               (rd->res.startscript     = strdup(rexxScripts[LOG_START]))&&
  137.               (rd->res.defaultscript   = strdup(rexxScripts[LOG_DEFAULT]))) BMemErr = TRUE;
  138.               
  139.             if (rd->res.port = malloc(20*sizeof(long)))
  140.             {
  141.               rd->res.port[o] = nPort;               SetNextPtr(port,port);
  142.               rd->res.port[o] = BConfirmAppLaunch;   SetNextPtr(confirm,port);
  143.               rd->res.port[o] = (session != NULL);   SetNextPtr(connected,port);
  144.               rd->res.port[o] = clientListLength;    SetNextPtr(numclients,port);
  145.               rd->res.port[o] = BEnabled;            SetNextPtr(enabled,port);
  146.               rd->res.port[o] = BBeepOnLog;          SetNextPtr(beeponlog,port);
  147.               rd->res.port[o] = nNumActions;         SetNextPtr(numactions,port); 
  148.               rd->res.port[o] = (TrackWindow==NULL); SetNextPtr(hidden,port);
  149.               rd->res.port[o] = nLastEntryClicked;   SetNextPtr(lastentryclicked,port);
  150.               rd->res.port[o] = currentAction;       SetNextPtr(currentaction, port);
  151.               rd->res.port[o] = maxLogListLen;       SetNextPtr(logviewlength, port);
  152.               rd->res.port[o] = GetLogViewLevelPercent(nLogViewLevel); SetNextPtr(logviewlevel, port);
  153.             }
  154.             else BMemErr = TRUE;
  155.             
  156.             /* Fill optional fields */
  157.             if (rd->arg.clients)
  158.             {
  159.              /* allocate & fill null-terminated array for client names */
  160.              if ((rd->res.clients     = malloc(sizeof(char *)*(clientListLength+1))) &&
  161.                  (rd->res.comments    = malloc(sizeof(char *)*(clientListLength+1))) &&
  162.                  (rd->res.usernames   = malloc(sizeof(char *)*(clientListLength+1))) &&
  163.                  (rd->res.realnames   = malloc(sizeof(char *)*(clientListLength+1))) &&
  164.                  (rd->res.winopen     = malloc(sizeof(long *)*((clientListLength+1)*2))) &&
  165.                  (rd->res.lastchanged = malloc(sizeof(long *)*((clientListLength+1)*2))))
  166.              {
  167.               struct Client * c = clientList.lh_Head;
  168.               long * lastChangedData = ((LONG *)rd->res.lastchanged)+clientListLength+1;
  169.               long * winOpenData     = ((LONG *)rd->res.winopen)+clientListLength+1;
  170.               time_t currentTime = time(NULL);
  171.                 
  172.               for(i=0; ((BMemErr==FALSE)&&(i<clientListLength)); i++)
  173.               {
  174.                 UNLESS(rd->res.clients[i]  = strdup(c->hostName->buffer)) BMemErr = TRUE;
  175.                 UNLESS(rd->res.comments[i] = strdup(c->comment->buffer))  BMemErr = TRUE;
  176.                 UNLESS(rd->res.usernames[i]= strdup(c->userName->buffer)) BMemErr = TRUE;
  177.                 UNLESS(rd->res.realnames[i]= strdup(c->realName->buffer)) BMemErr = TRUE;
  178.                 rd->res.winopen[i]     = winOpenData;
  179.                 rd->res.lastchanged[i] = lastChangedData;
  180.                 *lastChangedData = (currentTime-(c->timeStamp))/timeUnit; lastChangedData++;
  181.                 *winOpenData     = (c->winOpen->buffer[0] == 'Y'); winOpenData++;
  182.                 c = c->node.ln_Succ;
  183.               }
  184.               rd->res.clients[i] = rd->res.comments[i] = rd->res.usernames[i] = rd->res.realnames[i] = NULL; /* terminate the array! */
  185.               rd->res.lastchanged[i] = rd->res.winopen[i] = NULL;
  186.              }
  187.              else BMemErr = TRUE;
  188.             }
  189.             if (rd->arg.actions)
  190.             {
  191.               /* allocate & fill null-terminated array for action names */
  192.               /* allocate & fill null-terminated array for client names */
  193.               if ((rd->res.actions  = malloc(sizeof(char *)*(nNumActions+1))) &&
  194.                   (rd->res.commands = malloc(sizeof(char *)*(nNumActions+1))))
  195.               {
  196.                 for(i=0; ((BMemErr==FALSE)&&(i<nNumActions)); i++)
  197.                 {
  198.                   UNLESS(rd->res.actions[i]  = strdup(ActionLabels[i]))  BMemErr = TRUE;
  199.                   UNLESS(rd->res.commands[i] = strdup(Actions[i]))       BMemErr = TRUE;
  200.                 }
  201.                 rd->res.actions[i] = rd->res.commands[i] = NULL; /* terminate the array! */
  202.               }
  203.               else BMemErr = TRUE;
  204.             }
  205.  
  206.             rd->rc  = BMemErr ? RETURN_FAIL : RETURN_OK;
  207.             rd->rc2 = BMemErr ? ERROR_NO_FREE_STORE : RETURN_OK;
  208.             break;
  209.         
  210.         case RXIF_FREE:
  211.             /* FREE your local data here */
  212.             if (rd->res.clients)          FreeStringArray(rd->res.clients);
  213.             if (rd->res.comments)         FreeStringArray(rd->res.comments);
  214.             if (rd->res.usernames)        FreeStringArray(rd->res.usernames);
  215.             if (rd->res.realnames)        FreeStringArray(rd->res.realnames);
  216.             if (rd->res.actions)          FreeStringArray(rd->res.actions);
  217.             if (rd->res.commands)         FreeStringArray(rd->res.commands);
  218.             if (rd->res.winopen)          free(rd->res.winopen);
  219.             if (rd->res.lastchanged)      free(rd->res.lastchanged);
  220.             if (rd->res.viewby)           free(rd->res.viewby);
  221.             if (rd->res.visibleto)        free(rd->res.visibleto);
  222.             if (rd->res.server)           free(rd->res.server);
  223.             if (rd->res.comment)          free(rd->res.comment);
  224.             if (rd->res.username)         free(rd->res.username);
  225.             if (rd->res.realname)         free(rd->res.realname);
  226.             if (rd->res.logfile)          free(rd->res.logfile);
  227.             if (rd->res.loglevel)         free(rd->res.loglevel);
  228.             if (rd->res.port)             free(rd->res.port);
  229.             if (rd->res.logonscript)      free(rd->res.logonscript);
  230.             if (rd->res.logoffscript)     free(rd->res.logoffscript);
  231.             if (rd->res.updatescript)     free(rd->res.updatescript);
  232.             if (rd->res.connectscript)    free(rd->res.connectscript);
  233.             if (rd->res.disconnectscript) free(rd->res.disconnectscript);
  234.             if (rd->res.endscript)        free(rd->res.endscript);
  235.             if (rd->res.startscript)      free(rd->res.startscript);
  236.             if (rd->res.defaultscript)    free(rd->res.defaultscript);
  237.             FreeVec( rd );
  238.             break;
  239.     }
  240.     return;
  241. }
  242. /* $ARB: E 24 GET */
  243.  
  244. /* $ARB: B 25 SET */
  245. void rx_set( struct RexxHost *host, struct rxd_set **rxd, long action, struct RexxMsg *rexxmsg )
  246. {
  247.     struct rxd_set *rd = *rxd;
  248.     int flags = 0;
  249.     
  250.     switch( action )
  251.     {
  252.         case RXIF_INIT:
  253.             *rxd = AllocVec( sizeof *rd, MEMF_CLEAR );
  254.             if( rd = *rxd )
  255.             {
  256.                 /* set your DEFAULTS here */
  257.             }
  258.             break;
  259.             
  260.         case RXIF_ACTION:
  261.             /* Insert your CODE here */
  262.             rd->rc = 0;
  263.             if (rd->arg.beeponlog) {BBeepOnLog = ParseBool(rd->arg.beeponlog); flags |= 0x01;}
  264.             if (rd->arg.enabled) SetTrackFlag(ParseBool(rd->arg.enabled) ? CODE_ENABLE : CODE_DISABLE);
  265.             if (rd->arg.hidden)  SetTrackFlag(ParseBool(rd->arg.hidden)  ? CODE_HIDE   : CODE_SHOW);
  266.             if (rd->arg.confirm) {BConfirmAppLaunch = ParseBool(rd->arg.confirm); flags |= 0x01;}
  267.             if (rd->arg.loglevel){nLogLevel         = ParseOutputLevel(rd->arg.loglevel); flags |= 0x01;}
  268.             if (rd->arg.logfile) {char * n; if (n = strdup(rd->arg.logfile)) {free(szLogFileName); szLogFileName = n;}}
  269.             if (rd->arg.left)    {nWinLeft   = *rd->arg.left;   flags |= 0x02;}
  270.             if (rd->arg.top)     {nWinTop    = *rd->arg.top;    flags |= 0x02;}
  271.             if (rd->arg.width)   {nWinWidth  = *rd->arg.width;  flags |= 0x02;}
  272.             if (rd->arg.height)  {nWinHeight = *rd->arg.height; flags |= 0x02;}
  273.             if (rd->arg.comment) SetCommentString(TrackWindow, rd->arg.comment, TRUE);
  274.             if (rd->arg.server)  SetServerString(TrackWindow, rd->arg.server);
  275.             if (rd->arg.port)    SetPortNumber(TrackWindow, *rd->arg.port);
  276.             if (rd->arg.windowtitle) StatMessage(rd->arg.windowtitle);
  277.             if (rd->arg.currentactionindex) SetCurrentActionIndex(TrackWindow,*rd->arg.currentactionindex);
  278.             if (rd->arg.currentaction)    SetCurrentAction(TrackWindow, rd->arg.currentaction);
  279.             if (rd->arg.viewby)           SetViewBy(ParseViewBy(rd->arg.viewby));
  280.             if (rd->arg.logviewlength)    SetLogViewLength(*rd->arg.logviewlength);
  281.             if (rd->arg.logviewlevel)     
  282.             {
  283.               char temp[30];
  284.               sprintf(temp, "%i", *rd->arg.logviewlevel);
  285.               if (SetLogViewLevel(ParseLogViewLevel(temp))) flags |= 0x02;
  286.             }
  287.             if (rd->arg.logonscript)      SetRexxScript(LOG_LOGON,      rd->arg.logonscript);
  288.             if (rd->arg.logoffscript)     SetRexxScript(LOG_LOGOFF,     rd->arg.logoffscript);
  289.             if (rd->arg.updatescript)     SetRexxScript(LOG_UPDATE,     rd->arg.updatescript);
  290.             if (rd->arg.connectscript)    SetRexxScript(LOG_CONNECT,    rd->arg.connectscript);
  291.             if (rd->arg.disconnectscript) SetRexxScript(LOG_DISCONNECT, rd->arg.disconnectscript);
  292.             if (rd->arg.endscript)        SetRexxScript(LOG_END,        rd->arg.endscript);
  293.             if (rd->arg.startscript)      SetRexxScript(LOG_START,      rd->arg.startscript);
  294.             if (rd->arg.defaultscript)    SetRexxScript(LOG_DEFAULT,    rd->arg.defaultscript);
  295.             if ((rd->arg.action)&&(rd->res.actionindex=malloc(sizeof(long))))
  296.               *rd->res.actionindex = UpdateActions(TrackWindow, rd->arg.action);
  297.             if (flags & 0x01) SetMenuValues();
  298.             if ((flags & 0x02)&&(TrackWindow)) ChangeWindowBox(TrackWindow->win, nWinLeft, nWinTop, nWinWidth, nWinHeight);
  299.             break;
  300.         
  301.         case RXIF_FREE:
  302.             /* FREE your local data here */
  303.             if (rd->res.actionindex) free(rd->res.actionindex);
  304.             FreeVec( rd );
  305.             break;
  306.     }
  307.     return;
  308. }
  309. /* $ARB: E 25 SET */
  310.  
  311. /* $ARB: B 27 REQUEST */
  312. void rx_request( struct RexxHost *host, struct rxd_request **rxd, long action, struct RexxMsg *rexxmsg )
  313. {
  314.     struct rxd_request *rd = *rxd;
  315.  
  316.     switch( action )
  317.     {
  318.         case RXIF_INIT:
  319.             *rxd = AllocVec( sizeof *rd, MEMF_CLEAR );
  320.             if( rd = *rxd )
  321.             {
  322.                 /* set your DEFAULTS here */
  323.             }
  324.             break;
  325.             
  326.         case RXIF_ACTION:
  327.             /* Insert your CODE here */
  328.             if (rd->res.clicked = malloc(sizeof(long)))
  329.             {
  330.               *rd->res.clicked = MakeReq(
  331.                      rd->arg.title   ? rd->arg.title   : "AmiTrack Rexx Request",
  332.                      rd->arg.message ? rd->arg.message : "An ARexx script called my REQUEST function",
  333.                      rd->arg.buttons ? rd->arg.buttons : "Okay");
  334.               rd->rc = 0;
  335.             }
  336.             else 
  337.             {
  338.               rd->rc  = RETURN_ERROR;
  339.               rd->rc2 = ERROR_NO_FREE_STORE;
  340.             }
  341.             break;
  342.         
  343.         case RXIF_FREE:
  344.             /* FREE your local data here */
  345.             FreeVec( rd );
  346.             break;
  347.     }
  348.     return;
  349. }
  350. /* $ARB: E 27 REQUEST */
  351.  
  352. /* $ARB: B 28 CONNECT */
  353. void rx_connect( struct RexxHost *host, struct rxd_connect **rxd, long action, struct RexxMsg *rexxmsg )
  354. {
  355.     struct rxd_connect *rd = *rxd;
  356.     int connectto = -1, connectwith = -1;
  357.     
  358.     switch( action )
  359.     {
  360.         case RXIF_INIT:
  361.             *rxd = AllocVec( sizeof *rd, MEMF_CLEAR );
  362.             if( rd = *rxd )
  363.             {
  364.                 /* set your DEFAULTS here */
  365.             }
  366.             break;
  367.             
  368.         case RXIF_ACTION:
  369.             /* Insert your CODE here */
  370.             if ((rd->arg.actionindex)||(rd->arg.action))
  371.             {
  372.              if (rd->arg.actionindex) connectwith = *rd->arg.actionindex;
  373.              if (rd->arg.action)      connectwith = GetTrackActionByName(rd->arg.action);
  374.             }
  375.             else connectwith = currentAction;
  376.             
  377.             if ((rd->arg.hostindex)||(rd->arg.host))
  378.             {
  379.              if (rd->arg.hostindex)   connectto   = *rd->arg.hostindex;
  380.              if (rd->arg.host)        connectto   = GetTrackHostByName(rd->arg.host);
  381.             }
  382.             else connectto = nLastEntryClicked;
  383.             
  384.             if ((connectwith >= 0)&&(connectto >= 0)) 
  385.             {
  386.               rd->rc = DoAction(connectto, connectwith, 
  387.                          (rd->arg.confirm) ? ParseBool(rd->arg.confirm) : BConfirmAppLaunch);
  388.               if (rd->rc == -2) rd->rc = RETURN_WARN;
  389.               if (rd->rc == -1) rd->rc = RETURN_ERROR;
  390.             }
  391.             else rd->rc = RETURN_WARN;
  392.             break;
  393.         
  394.         case RXIF_FREE:
  395.             /* FREE your local data here */
  396.             FreeVec( rd );
  397.             break;
  398.     }
  399.     return;
  400. }
  401. /* $ARB: E 28 CONNECT */
  402.  
  403.  
  404. #ifndef RX_ALIAS_C
  405. char *ExpandRXCommand( struct RexxHost *host, char *command )
  406. {
  407.     /* Insert your ALIAS-HANDLER here */
  408.     return( NULL );
  409. }
  410. #endif
  411.  
  412.