home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume6 / rpc2 / part11 / rpc / rpcgen / test / demo_xdr.x < prev    next >
Encoding:
Text File  |  1986-11-30  |  1.8 KB  |  103 lines

  1. /*
  2.  *  This file defines the protocol to support a demo rpc
  3.  *  service and is designed to be processed by the `rpcgen'
  4.  *  protocol compiler.  The Sun ctime(3) routines are used
  5.  *  as examples.  See the rpcgen manual page for more detailed
  6.  *  information.
  7.  */
  8.  
  9. #ifdef REL3_0
  10. #ifndef NULL
  11. #       define NULL 0
  12. #endif
  13. #endif
  14.  
  15.  
  16. /*
  17.  *  argument / result data types
  18.  */
  19.  
  20. #define DATELEN 26
  21. typedef string date[DATELEN];
  22.  
  23. #define STRLEN 80
  24. typedef string str[STRLEN];
  25.  
  26. typedef long clock;
  27.  
  28. struct tm {
  29.     int tm_sec;
  30.     int tm_min;
  31.     int tm_hour;
  32.     int tm_mday;
  33.     int tm_mon;
  34.     int tm_year;
  35.     int tm_wday;
  36.     int tm_yday;
  37.     int tm_isdst;
  38. };
  39.  
  40. struct timeval {
  41.     u_long    tv_sec;
  42.     long    tv_usec;
  43. };
  44.  
  45. struct timez {
  46.     int    tz_minuteswest;
  47.     int    tz_dsttime;
  48. };
  49.  
  50. struct tzargs {
  51.     int    zone;
  52.     int    dst;
  53. };
  54.  
  55.  
  56. /*
  57.  *  There is one generic data type for the result.  This is implemented
  58.  *  as a union switch.  The specific union element returned is specified
  59.  *  by ret_status.
  60.  */
  61.  
  62. enum ret_status {
  63.     RET_DATE, RET_TM, RET_STR, RET_DAYS, RET_CLOCK, RET_TZ, RET_YEAR,
  64.     RET_ERROR
  65. };
  66.  
  67. struct ret_err {
  68.     int    err_number;
  69.     str    err_text;
  70. };
  71.  
  72. union demo_res switch (ret_status which) {
  73.     case RET_DATE:
  74.         date    date;
  75.     case RET_TM:
  76.         tm    *tmp;
  77.     case RET_STR:
  78.         str    str;
  79.     case RET_DAYS:
  80.         int    days;
  81.     case RET_ERROR:
  82.         ret_err err;
  83. };
  84.  
  85.  
  86. /*
  87.  *  This section declares the individual procedures which are supported
  88.  *  by this protocol.  The program number and version numbers are
  89.  *  arbitrary in this case.  Procedures correspond to the ctime(3)
  90.  *  time routines.
  91.  */
  92.  
  93. program DEMOPROG {
  94.     version DEMOVERS {
  95.     demo_res    /* date */    CTIME(clock)        = 1;
  96.     demo_res    /* tm   */    LOCALTIME(clock)    = 2;
  97.     demo_res    /* tm   */    GMTIME(clock)        = 3;
  98.     demo_res    /* date */    ASCTIME(tm)        = 4;
  99.     demo_res    /* str  */    TIMEZONE(tzargs)    = 5;
  100.     demo_res    /* days */    DYSIZE(int)        = 6;
  101.     } = 5;
  102. } = 123456;
  103.