home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / rpc / pipes / common.h next >
C/C++ Source or Header  |  1996-07-23  |  2KB  |  45 lines

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  2. /*                  Copyright Microsoft Corp. 1992-1996                 */
  3. /*                      Remote Machine pipe sample                      */
  4. /*                                                                      */
  5. /*  FILE    :   common.h                                                */
  6. /*                                                                      */
  7. /*  PURPOSE :   Definitions used in the program                         */
  8. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  9. #ifndef __COMMON_PIPE_SAMPLE__      // If this file has be included before  
  10. #define __COMMON_PIPE_SAMPLE__      // Don't include it again
  11.  
  12. #include <shellapi.h>               // CommandLineToArgvw is defined here
  13. #include <tchar.h>                  // Included to support UNICODE/ANSI
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16.  
  17. // Common type definition and defines used in the program
  18. // Return values from the program to the OS
  19. #define EXECUTION_FAILED    -1
  20. #define EXECUTION_OK        0
  21.  
  22. // Exception handler macro
  23. #define DO_EXCEPTION        1       // Execute the exception block
  24.  
  25. #define SCRAMBLE    1               // Action to take - Encode the file
  26. #define UNSCRAMBLE  2               // Action to take - Decode the file
  27.  
  28. #define PROTOCOL_SEQUENCE   TEXT("ncacn_np")
  29. #define END_POINT           TEXT("\\pipe\\pipe_sample")
  30.     
  31. // This struct is used by the client to keep track of the state    
  32. typedef struct    {
  33.     FILE        *hOld;          // Handle to the old file
  34.     FILE        *hNew;          // Handle to the new file
  35.     _TUCHAR     *pszOldName;       // Name of the old file
  36.     _TUCHAR     *pszNewName;       // Name of the new file
  37. } pipe_state;
  38.  
  39. // Macro for printing out error message and exit the program if an 
  40. // error occured
  41. #define EXIT_IF_FAIL(x, string){   \
  42.     ((x) != RPC_S_OK)?_tprintf(TEXT("%s returned with error: %d\n"), \
  43.     TEXT(string), (x)),exit(x):0;} 
  44.  
  45. #endif  //  __COMMON_PIPE_SAMPLE__