home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / setenvstat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  5.9 KB  |  241 lines

  1.  
  2. #include "bbs.h"
  3. void SendChatFlag(int opt);
  4. extern int UserIsDoing;
  5.  
  6. #ifdef JOECODE
  7. extern char mybbstitle[];
  8. extern struct StartOption *Sopt;
  9. void RegServer(void);
  10. extern int UserIsDoing;
  11. char MstrServe[]="ServerRP ";
  12. char MultiRP[] = "MultiRP ";
  13. struct MsgPort *ServerRP;
  14.  
  15. struct Master
  16. {
  17.     struct Message Msg;
  18.   char User[50];
  19.   char Location[50];
  20.   char Action[50];
  21.   char Baud[10];
  22.   int Data;
  23.   int Command;
  24.   int Node;
  25.   int LineNum;
  26.   struct Commands *MyCmds;
  27.   struct StartOption *Sopt;
  28. } *MasterMsg=NULL;
  29. void CreateServerRP(int node);
  30. void DeleteServerRP(void);
  31. int SetEnvStat(int Code)
  32. {
  33.   char Status[200];
  34.   char Environ[200];
  35.   
  36.  
  37.   if(!Sopt->Toggles[10]) UserIsDoing=Code;
  38.   else
  39.   {ObtainSemaphore((struct SignalSemaphore *)SingleNode);
  40.   strcpy(SingleNode->Handle,User.Name);
  41.   strcpy(SingleNode->Location,User.Location);
  42.   strcpy(SingleNode->Misc1,"");
  43.   strcpy(SingleNode->Misc2,"");
  44.   UserIsDoing=Code;
  45.   if(QuietNode) SingleNode->Status=0-(UserIsDoing+2);else
  46.   SingleNode->Status=UserIsDoing;
  47.   ReleaseSemaphore((struct SignalSemaphore *)SingleNode);
  48.   }
  49.  
  50.   sprintf(Environ,"STATS@%d",Cmds->AcLvl[LVL_NODE_NUMBER]);
  51.   sprintf(Status,"%-35s-%02d",User.Name,Code);
  52.   SetVar(Environ,Status,-1L,LV_VAR|GVF_GLOBAL_ONLY);
  53.  
  54. SendMaster();
  55.  
  56.  
  57.  
  58.   return(1);
  59. }
  60.  
  61. void SendMaster(void)
  62. {
  63.   char temp[10];
  64.   struct MsgPort *port;
  65.   strcpy(MasterMsg->User,User.Name);
  66.   strcpy(MasterMsg->Location,User.Location);
  67.   sprintf(temp,"%d",UserIsDoing);
  68.   strcpy(MasterMsg->Action,temp);
  69.   sprintf(temp,"%5d",Online_Baud);
  70.   strcpy(MasterMsg->Baud,temp);
  71.   if((port=(struct MsgPort *)FindPort("AE.Master")))
  72.   {
  73.      PutMsg(port,(struct Message *)MasterMsg);
  74.      (void)WaitPort(ServerRP);
  75.     (void)GetMsg(ServerRP);
  76.   }
  77. }
  78. void SetEnvMsg(char *s)
  79. {
  80.   char temp[10];
  81.   struct MsgPort *port;
  82.   strcpy(MasterMsg->User,s);
  83.   //strcpy(MasterMsg->Location,User.Location);
  84.   sprintf(temp,"%d",SV_NEWMSG);
  85.   strcpy(MasterMsg->Action,temp);
  86.  
  87.   if((port=(struct MsgPort *)FindPort("AE.Master")))
  88.   {
  89.      PutMsg(port,(struct Message *)MasterMsg);
  90.      (void)WaitPort(ServerRP);
  91.     (void)GetMsg(ServerRP);
  92.   }
  93. }
  94. void SendMasterUpload(char *filename)
  95. {
  96.   char temp[10];
  97.   struct MsgPort *port;
  98.   strcpy(MasterMsg->User,filename);
  99.   strcpy(MasterMsg->Location,User.Location);
  100.   sprintf(temp,"%d",UserIsDoing);
  101.   strcpy(MasterMsg->Action,temp);
  102.   MasterMsg->Command=3;
  103.  
  104.   if((port=(struct MsgPort *)FindPort("AE.Master")))
  105.   {
  106.      PutMsg(port,(struct Message *)MasterMsg);
  107.      (void)WaitPort(ServerRP);
  108.     (void)GetMsg(ServerRP);
  109.   }
  110.   if(Sopt->Toggles[10])
  111.   {
  112.   ObtainSemaphore((struct SignalSemaphore *)SingleNode);
  113.   strcpy(SingleNode->Misc1,filename);
  114.   ReleaseSemaphore((struct SignalSemaphore *)SingleNode);
  115.   }
  116.   MasterMsg->Command=1;
  117. }
  118. void SendMasterDownload(char *filename)
  119. {
  120.   char temp[10];
  121.   char temp1[43];
  122.   struct MsgPort *port;
  123.   sprintf(temp1,"%-16.16s",FilePart(filename));
  124.   strcpy(MasterMsg->User,temp1);
  125.   strcpy(MasterMsg->Location,User.Location);
  126.   sprintf(temp,"%d",UserIsDoing);
  127.   strcpy(MasterMsg->Action,temp);
  128.   MasterMsg->Command=2;
  129.  
  130.   if((port=(struct MsgPort *)FindPort("AE.Master")))
  131.   {
  132.      PutMsg(port,(struct Message *)MasterMsg);
  133.      (void)WaitPort(ServerRP);
  134.     (void)GetMsg(ServerRP);
  135.   }
  136.   if(Sopt->Toggles[10])
  137.   {
  138.    ObtainSemaphore((struct SignalSemaphore *)SingleNode);
  139.     strcpy(SingleNode->Misc1,FilePart(filename));
  140.     ReleaseSemaphore((struct SignalSemaphore *)SingleNode); 
  141.   }
  142.   MasterMsg->Command=1;
  143. }
  144. void SendChatFlag(int opt)
  145. {
  146.   struct MsgPort *port;
  147.   strcpy(MasterMsg->User,"");
  148.   strcpy(MasterMsg->Location,"");
  149.   strcpy(MasterMsg->Action,"");
  150.   MasterMsg->Command=opt+4;
  151.  
  152.   if((port=(struct MsgPort *)FindPort("AE.Master")))
  153.   {
  154.      PutMsg(port,(struct Message *)MasterMsg);
  155.      (void)WaitPort(ServerRP);
  156.     (void)GetMsg(ServerRP);
  157.   }
  158.   MasterMsg->Command=1;
  159. }
  160. void SendQuietFlag(int opt)
  161. {
  162.   struct MsgPort *port;
  163.   strcpy(MasterMsg->User,"");
  164.   strcpy(MasterMsg->Location,"");
  165.   strcpy(MasterMsg->Action,"");
  166.   MasterMsg->Command=opt+6;
  167.  
  168.   if((port=(struct MsgPort *)FindPort("AE.Master")))
  169.   {
  170.      PutMsg(port,(struct Message *)MasterMsg);
  171.      (void)WaitPort(ServerRP);
  172.     (void)GetMsg(ServerRP);
  173.   }
  174.   MasterMsg->Command=1;
  175.   if(Sopt->Toggles[10])
  176.   {
  177.    ObtainSemaphore((struct SignalSemaphore *)SingleNode);
  178.   strcpy(SingleNode->Handle,User.Name);
  179.   strcpy(SingleNode->Location,User.Location);
  180.   strcpy(SingleNode->Misc1,"");
  181.   strcpy(SingleNode->Misc2,"");
  182.   if(QuietNode) SingleNode->Status=0-(UserIsDoing+2);else
  183.   SingleNode->Status=UserIsDoing;
  184.   ReleaseSemaphore((struct SignalSemaphore *)SingleNode);
  185.   }
  186. }
  187. void CreateServerRP(int node)
  188. {
  189.   MstrServe[8]= node+'0';//Cmds->AcLvl[LVL_NODE_NUMBER]+'0';
  190.   MultiRP[7]= node+'0';
  191.   if(FindPort(MstrServe)) exit(0);
  192.   ServerRP=CreatePort(MstrServe,0L);
  193.   MasterMsg=(struct Master *)AllocMem(sizeof(struct Master),MEMF_PUBLIC|MEMF_CLEAR);
  194.   MasterMsg->Node=node;//Cmds->AcLvl[LVL_NODE_NUMBER];
  195.   MasterMsg->Command=1;
  196.   MasterMsg->Msg.mn_Node.ln_Type=NT_MESSAGE;
  197.   MasterMsg->Msg.mn_Length=sizeof(struct Master);
  198.   MasterMsg->Msg.mn_ReplyPort=ServerRP;
  199.   RegServer();
  200. }
  201. void SendACPCommand(char *string,int command,int node)
  202. {
  203.   struct MsgPort *port;
  204.   strcpy(MasterMsg->User,string);
  205.   strcpy(MasterMsg->Location,"");
  206.   strcpy(MasterMsg->Action,"");
  207.   MasterMsg->Command=8;
  208.   MasterMsg->Node=node;
  209.   MasterMsg->Data=command;
  210.  
  211.   if((port=(struct MsgPort *)FindPort("AE.Master")))
  212.   {
  213.      PutMsg(port,(struct Message *)MasterMsg);
  214.      (void)WaitPort(ServerRP);
  215.     (void)GetMsg(ServerRP);
  216.   }
  217.   MasterMsg->Node=Cmds->AcLvl[LVL_NODE_NUMBER];
  218.   MasterMsg->Command=1;
  219. }
  220. void RegServer(void)
  221. {
  222.   struct MsgPort *port;
  223.   MasterMsg->Command=SV_START;
  224.   while(!(port=(struct MsgPort *)FindPort("AE.Master")));
  225.  
  226.      PutMsg(port,(struct Message *)MasterMsg);
  227.      (void)WaitPort(ServerRP);
  228.     (void)GetMsg(ServerRP);
  229.   strcpy(mybbstitle,MasterMsg->User);
  230.   Cmds=MasterMsg->MyCmds;
  231.   Sopt=MasterMsg->Sopt;
  232.   MasterMsg->Command=1;
  233. }
  234. void DeleteServerRP(void)
  235. {
  236.   DeletePort((struct MsgPort *)ServerRP);
  237.   FreeMem(MasterMsg,sizeof(struct Master));
  238. }
  239.  
  240. #endif
  241.