rpc_util.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* @(#)rpc_util.h 1.5 90/08/29 */
  2. /*
  3. * Copyright (c) 2010, Oracle America, Inc.
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following
  12. * disclaimer in the documentation and/or other materials
  13. * provided with the distribution.
  14. * * Neither the name of the "Oracle America, Inc." nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  21. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  22. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  25. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  27. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. * rpc_util.h, Useful definitions for the RPC protocol compiler
  32. */
  33. #include <stdlib.h>
  34. #define alloc(size) malloc((unsigned)(size))
  35. #define ALLOC(object) (object *) malloc(sizeof(object))
  36. #define s_print (void) sprintf
  37. #define f_print (void) fprintf
  38. struct list {
  39. definition *val;
  40. struct list *next;
  41. };
  42. typedef struct list list;
  43. struct xdrfunc {
  44. char *name;
  45. int pointerp;
  46. struct xdrfunc *next;
  47. };
  48. typedef struct xdrfunc xdrfunc;
  49. #define PUT 1
  50. #define GET 2
  51. /*
  52. * Global variables
  53. */
  54. #define MAXLINESIZE 1024
  55. extern char curline[MAXLINESIZE];
  56. extern const char *where;
  57. extern int linenum;
  58. extern const char *infilename;
  59. extern FILE *fout;
  60. extern FILE *fin;
  61. extern list *defined;
  62. extern bas_type *typ_list_h;
  63. extern bas_type *typ_list_t;
  64. extern xdrfunc *xdrfunc_head, *xdrfunc_tail;
  65. /*
  66. * All the option flags
  67. */
  68. extern int inetdflag;
  69. extern int pmflag;
  70. extern int tblflag;
  71. extern int logflag;
  72. extern int newstyle;
  73. extern int Cflag; /* C++ flag */
  74. extern int CCflag; /* C++ flag */
  75. extern int tirpcflag; /* flag for generating tirpc code */
  76. extern int inlineflag; /* if this is 0, then do not generate inline code */
  77. extern int mtflag;
  78. /*
  79. * Other flags related with inetd jumpstart.
  80. */
  81. extern int indefinitewait;
  82. extern int exitnow;
  83. extern int timerflag;
  84. extern int nonfatalerrors;
  85. /*
  86. * rpc_util routines
  87. */
  88. void storeval(list **lstp, definition *val);
  89. #define STOREVAL(list,item) storeval(list,item)
  90. definition *findval(list *lst, const char *val,
  91. int (*cmp)(const definition *, const char *));
  92. #define FINDVAL(list,item,finder) findval(list, item, finder)
  93. const char *fixtype(const char *type);
  94. const char *stringfix(const char *type);
  95. char *locase(const char *str);
  96. void pvname_svc(const char *pname, const char *vnum);
  97. void pvname(const char *pname, const char *vnum);
  98. void ptype(const char *prefix, const char *type, int follow);
  99. int isvectordef(const char *type, relation rel);
  100. int streq(const char *a, const char *b);
  101. void error(const char *msg);
  102. void tabify(FILE *f, int tab);
  103. void record_open(const char *file);
  104. bas_type *find_type(const char *type);
  105. /*
  106. * rpc_cout routines
  107. */
  108. void emit(definition *def);
  109. /*
  110. * rpc_hout routines
  111. */
  112. void print_datadef(definition *def);
  113. void print_funcdef(definition *def);
  114. /*
  115. * rpc_svcout routines
  116. */
  117. void write_most(const char *infile, int netflag, int nomain);
  118. void write_register(void);
  119. void write_rest(void);
  120. void write_programs(const char *storage);
  121. void write_svc_aux(int nomain);
  122. void write_inetd_register(const char *transp);
  123. void write_netid_register(const char *);
  124. void write_nettype_register(const char *);
  125. /*
  126. * rpc_clntout routines
  127. */
  128. void write_stubs(void);
  129. /*
  130. * rpc_tblout routines
  131. */
  132. void write_tables(void);