|
|
1.1 root 1: /**************************************************************************** 1.1.1.2 ! root 2: Microsoft RPC Version 1.0 ! 3: Copyright Microsoft Corp. 1992 ! 4: Discriminated Union Example ! 5: ! 6: FILE: unionp.c 1.1 root 7: 8: PURPOSE: Remote procedures that are linked with the server 1.1.1.2 ! root 9: side of RPC distributed application ! 10: ! 11: FUNCTIONS: UnionParamProc() - union, discriminant are parameters ! 12: UnionStructProc() - union, discriminant in structure ! 13: ! 14: COMMENTS: This distributed application illustrates distriminated ! 15: union. 1.1 root 16: 17: ****************************************************************************/ 1.1.1.2 ! root 18: 1.1 root 19: #include <stdlib.h> 20: #include <stdio.h> 1.1.1.2 ! root 21: #include "dunion.h" // header file generated by MIDL compiler 1.1 root 22: 1.1.1.2 ! root 23: ! 24: void UnionParamProc(DISCRIM_UNION_PARAM_TYPE *up, ! 25: short sDiscrim) 1.1 root 26: { 27: printf("sDiscrim = %d, data = ", sDiscrim); 28: switch(sDiscrim) { 1.1.1.2 ! root 29: case 0: ! 30: printf("short %d\n", up->sVal); ! 31: break; ! 32: case 1: ! 33: printf("float %f\n", up->fVal); ! 34: break; ! 35: case 2: ! 36: printf("char %c\n", up->chVal); ! 37: break; ! 38: default: ! 39: printf("invalid\n"); ! 40: break; ! 41: } 1.1 root 42: } 43: 1.1.1.2 ! root 44: void UnionStructProc(DISCRIM_UNION_STRUCT_TYPE *u) 1.1 root 45: { 1.1.1.2 ! root 46: printf("sDiscrim = %d, data = ", u->sDiscrim); ! 47: switch(u->sDiscrim) { ! 48: case 0: ! 49: printf("short %d\n", u->u.sVal); ! 50: break; ! 51: case 1: ! 52: printf("float %f\n", u->u.fVal); ! 53: break; ! 54: case 2: ! 55: printf("char %c\n", u->u.chVal); ! 56: break; ! 57: default: ! 58: printf("invalid\n"); ! 59: break; ! 60: } 1.1 root 61: } 62: 63: void Shutdown(void) 64: { 65: RPC_STATUS status; 66: 67: printf("Calling RpcMgmtStopServerListening\n"); 68: status = RpcMgmtStopServerListening(NULL); 69: printf("RpcMgmtStopServerListening returned: 0x%x\n", status); 70: if (status) { 1.1.1.2 ! root 71: exit(status); 1.1 root 72: } 73: 74: printf("Calling RpcServerUnregisterIf\n"); 75: status = RpcServerUnregisterIf(NULL, NULL, FALSE); 76: printf("RpcServerUnregisterIf returned 0x%x\n", status); 77: if (status) { 1.1.1.2 ! root 78: exit(status); 1.1 root 79: } 80: } 81: 1.1.1.2 ! root 82: /* end file dunionp.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.