home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / broad.exe / BROAD.C next >
C/C++ Source or Header  |  1995-01-04  |  4KB  |  123 lines

  1. /****************************************************************************
  2. **        DISCLAIMER
  3. **
  4. **  This program is provided as is and carries no warranty       
  5. **  whatsoever.  Novell disclaims and excludes any and all implied    
  6. **  warranties of merchantability, title and fitness for a particular 
  7. **  purpose.  Novell does not warrant that the software will satisfy  
  8. **  your requirements or that the software is without defect or error 
  9. **  or that operation of the software will be uninterrupted.  You are 
  10. **  using the software at your risk.  The software is not a product   
  11. **  of Novell, Inc. or any of subsidiaries.
  12. **
  13. ****************************************************************************
  14. **
  15. **    File:    broad.c
  16. **
  17. **    Desc: Program to send and get broadcast messages. 
  18. **
  19. **   API Calls:
  20. **         NWCallsInit()
  21. **         NWGetDefaultConnectionID()
  22. **         NWSetBroadcastMode()
  23. **         NWGetObjectConnectionNumbers()
  24. **         NWSendBroadcastMessage()
  25. **         NWGetBroadcastMessage()
  26. **         
  27. **    Programmers:
  28. **   Ini    Who                  Firm
  29. **   ------------------------------------------------------------------
  30. **      BBA    Belinda Adams      Novell Developer Support.
  31. **
  32. **    History:
  33. **       
  34. **      ------------------------------------------------------------------
  35. **      01-04-95    BBA    Original.
  36. */
  37.  
  38. /****************************************************************************
  39. ** Include Headers, Macros & function Prototypes.
  40. */
  41.  
  42. #include <stdlib.h>
  43. #include <stdio.h>
  44.  
  45. #define NWDOS
  46.  
  47. #include <nwcalls.h>
  48.  
  49. NWCCODE        cCode;
  50. NWCONN_HANDLE  connHandle;
  51.  
  52. void main(void)
  53.  
  54. {
  55.    int i;
  56.    char  msg[256], user[30];
  57.    NWFLAGS     resultList;
  58.    NWNUMBER    numConnections;
  59.    NWCONN_NUM  doubleWordConnList[50];
  60.    NWCONN_NUM_WORD wordConnList[50];
  61.  
  62.    /* Initialize NWCalls  */
  63.  
  64.    if ( cCode = NWCallsInit( NULL, NULL ) )
  65.    {
  66.       printf( "\nNWCallsInit failed: %04x", cCode );
  67.       exit(1);
  68.    }
  69.  
  70.    if (cCode = NWGetDefaultConnectionID(&connHandle) )
  71.    {
  72.       printf( "\nNWGetDefaultConnectionID: failed %04x", cCode );
  73.       exit(1);
  74.    }
  75.  
  76.    /* Set broadcast mode to 3:  all messages stored but not displayed */
  77.    if (cCode = NWSetBroadcastMode(connHandle, 0x0003) )
  78.       printf( "\nNWSetBroadcastMode: failed %04x", cCode );
  79.  
  80.    printf("\nSend broadcast message to? ");
  81.    /* expects user name to be in capital letters */
  82.    scanf("%s", user);
  83.  
  84.     if (cCode = NWGetObjectConnectionNumbers(connHandle, user, OT_USER,
  85.                            &numConnections, doubleWordConnList, 50) )
  86.    {
  87.       printf( "\nNWGetObjectConnectionNumbers: failed %04x", cCode );
  88.       exit(1);
  89.    }
  90.  
  91.    /* convert connection list from double word to word */
  92.    for (i=0; i < numConnections; i++)
  93.        wordConnList[i] = (WORD)doubleWordConnList[i];
  94.  
  95.    if (cCode = NWSendBroadcastMessage(connHandle, "Test Message 1" , numConnections,
  96.                                       wordConnList, &resultList) )
  97.    {
  98.       printf( "\nNWSendBroadcastMessage: failed %04x", cCode );
  99.       exit(1);
  100.    }
  101.  
  102.    /* Retrieve a stored broadcast message */
  103.    if (cCode = NWGetBroadcastMessage(connHandle, msg) )
  104.    {
  105.       printf( "\nNWGetBroadcastMessage: failed %04x", cCode );
  106.       exit(1);
  107.    }
  108.    printf("\nMessage Received:  %s", msg);
  109.  
  110.    /* Reset broadcast mode to default:  all messages displayed */
  111.    if (cCode = NWSetBroadcastMode(connHandle, 0x0000) )
  112.       printf( "\nNWSetBroadcastMode: failed %04x", cCode );
  113.  
  114.    if (cCode = NWSendBroadcastMessage(connHandle, "Test Message 2",
  115.                                       numConnections,
  116.                                       wordConnList, &resultList)                                       )
  117.    {
  118.       printf( "\nNWSendBroadcastMessage: failed %04x", cCode );
  119.       exit(1);
  120.    }
  121.  
  122. }
  123.