home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 1.2 / amidev_cd_12.iso / contrib / iam / networking / envoy-2.0 / examples / remoterequest / requestserver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-30  |  2.3 KB  |  85 lines

  1. /* NIPC Example Program #2
  2. **
  3. ** This program is the server side of a pair of programs that allow
  4. ** you to bring up a simple requester on a remote machine.  This example shows
  5. ** the use of some of the more commonly used functions in NIPC.
  6. **
  7. ** You may compile this example with:
  8. **
  9. ** lc -v -O -L+lib:envoy.lib RequestServer.c
  10. **
  11. */
  12.  
  13. #include <exec/types.h>
  14. #include <intuition/intuition.h>
  15. #include <envoy/nipc.h>
  16. #include <envoy/errors.h>
  17. #include <dos/dos.h>
  18.  
  19. #include <clib/exec_protos.h>
  20. #include <clib/intuition_protos.h>
  21. #include <clib/nipc_protos.h>
  22.  
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <stdlib.h>
  26.  
  27. struct Library *NIPCBase;
  28. struct Library *IntuitionBase;
  29.  
  30. #ifdef LATTICE
  31. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL/C handling */
  32. #endif
  33.  
  34. void main(void)
  35. {
  36.     struct Entity *myentity;
  37.  
  38.     struct Transaction *trans;
  39.     ULONG bitnumber, signals, sigmask;
  40.     struct EasyStruct es;
  41.  
  42.     /* Open Intuition for our requesters. */
  43.  
  44.     if(IntuitionBase = OpenLibrary("intuition.library",37L))
  45.     {
  46.         /* Open NIPC for the network stuff */
  47.  
  48.         if(NIPCBase = OpenLibrary("nipc.library",37L))
  49.         {
  50.  
  51.             /* Create our public entity */
  52.  
  53.             if(myentity = CreateEntity(ENT_AllocSignal, &bitnumber,
  54.                                        ENT_Name, "RequestServer",
  55.                                        ENT_Public, TRUE,
  56.                                        TAG_DONE))
  57.             {
  58.                 sigmask = SIGBREAKF_CTRL_C | (1 << bitnumber);
  59.  
  60.                 while(TRUE)
  61.                 {
  62.                     signals = Wait(sigmask);
  63.  
  64.                     while(trans = GetTransaction(myentity))
  65.                     {
  66.                         es.es_StructSize = sizeof(struct EasyStruct);
  67.                         es.es_Flags = 0;
  68.                         es.es_Title = "Remote Request";
  69.                         es.es_TextFormat = (UBYTE *)trans->trans_RequestData;
  70.                         es.es_GadgetFormat = "Okay";
  71.                         EasyRequestArgs(NULL,&es,NULL,NULL);
  72.                         ReplyTransaction(trans);
  73.                     }
  74.                     if(signals & SIGBREAKF_CTRL_C)
  75.                         break;
  76.                 }
  77.                 DeleteEntity(myentity);
  78.             }
  79.             CloseLibrary(NIPCBase);
  80.         }
  81.         CloseLibrary(IntuitionBase);
  82.     }
  83. }
  84.  
  85.