wmloutmm.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these librararies and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * @OSF_COPYRIGHT@
  25. * COPYRIGHT NOTICE
  26. * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
  27. * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
  28. * the full copyright text.
  29. */
  30. /*
  31. * HISTORY
  32. */
  33. #ifdef REV_INFO
  34. #ifndef lint
  35. static char rcsid[] = "$XConsortium: wmloutmm.c /main/9 1995/08/29 11:10:59 drk $"
  36. #endif
  37. #endif
  38. /*
  39. * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
  40. /*
  41. * This module contains routines responsible for writing the .mm files
  42. * produced by WML. All files are written into the current directory.
  43. *
  44. * Input:
  45. * The resolved objects
  46. *
  47. * Output:
  48. * wml-uil.mm
  49. *
  50. */
  51. #include "wml.h"
  52. #if defined(__STDC__)
  53. #include <string.h>
  54. #endif
  55. #include <stdio.h>
  56. /*
  57. * Routines used only in this module
  58. */
  59. void wmlOutputWmlUilMm ();
  60. void wmlOutputWmlUilMmClass ();
  61. /*
  62. * globals
  63. */
  64. int tabno = 1; /* table number */
  65. /*
  66. * lists re-used repeatedly to order lists for printing
  67. */
  68. DynamicHandleListDef mm_arg;
  69. DynamicHandleListDefPtr mm_arg_ptr = &mm_arg;
  70. DynamicHandleListDef mm_rsn;
  71. DynamicHandleListDefPtr mm_rsn_ptr = &mm_rsn;
  72. DynamicHandleListDef mm_ctl;
  73. DynamicHandleListDefPtr mm_ctl_ptr = &mm_ctl;
  74. /*
  75. * Output control routine, which simply outputs each .mm file in turn.
  76. */
  77. void wmlOutputMmFiles ()
  78. {
  79. wmlOutputWmlUilMm ();
  80. }
  81. /*
  82. * Routine to write out wml-uil.mm
  83. *
  84. * This .mm file contains the tables which are to be included as an
  85. * appendix to the Uil manual. The tables give the arguments with their
  86. * default values, reasons, constraints, and controls for each class
  87. * in the class vectors.
  88. */
  89. void wmlOutputWmlUilMm ()
  90. {
  91. FILE *outfil; /* output file */
  92. int ndx; /* loop index */
  93. WmlClassDefPtr clsobj; /* class object */
  94. /*
  95. * Open the output file. Write the canned header stuff
  96. */
  97. outfil = fopen ("wml-uil.mm", "w");
  98. if ( outfil == NULL )
  99. {
  100. printf ("\nCouldn't open wml-uil.mm");
  101. return;
  102. }
  103. /*
  104. * Initialize order lists for the tables.
  105. */
  106. wmlInitHList (mm_arg_ptr, 200, TRUE);
  107. wmlInitHList (mm_rsn_ptr, 200, TRUE);
  108. wmlInitHList (mm_ctl_ptr, 200, TRUE);
  109. /*
  110. * Write out a table for each class, for both widget and gadget variants
  111. */
  112. for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
  113. {
  114. clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
  115. wmlOutputWmlUilMmClass (outfil, clsobj, clsobj->syndef->name);
  116. }
  117. /*
  118. * close the output file
  119. */
  120. printf ("\nCreated wml-uil.mm");
  121. fclose (outfil);
  122. }
  123. /*
  124. * Routine to write a table for a class entry
  125. */
  126. void wmlOutputWmlUilMmClass (outfil, clsobj, name)
  127. FILE *outfil;
  128. WmlClassDefPtr clsobj;
  129. char *name;
  130. {
  131. char *canned1 =
  132. ".bp\n\
  133. .ps 12\n";
  134. char *canned2 =
  135. ".ps 10\n\
  136. .vs 12\n\
  137. .LP\n\
  138. .TS H\n\
  139. tab(@);\n\
  140. lB lB\n\
  141. l l.\n\
  142. _\n\
  143. .sp 6p\n\
  144. Controls@Reasons\n\
  145. .sp 6p\n\
  146. _\n\
  147. .sp 6p\n\
  148. .TH\n";
  149. char *canned3 =
  150. ".TE\n\
  151. .TS H\n\
  152. tab(@);\n\
  153. lB lB lB\n\
  154. l l l.\n\
  155. _\n\
  156. .sp 6p\n\
  157. UIL Argument Name@Argument Type@Default Value\n\
  158. .sp 6p\n\
  159. _\n\
  160. .sp 6p\n\
  161. .TH\n";
  162. char *canned4 =
  163. ".TE\n";
  164. WmlClassResDefPtr argref; /* current argument reference */
  165. WmlClassResDefPtr rsnref; /* current reason reference */
  166. WmlClassCtrlDefPtr ctlref; /* current controls reference */
  167. int argndx; /* to access ordered vector */
  168. int rsnndx; /* to access ordered vector */
  169. int ctlndx; /* to access ordered vector */
  170. /*
  171. * Write out header information
  172. */
  173. fprintf (outfil, canned1);
  174. fprintf (outfil, "%s\n", name);
  175. fprintf (outfil, canned2);
  176. /*
  177. * Alphabetize the controls, reason, and argument lists
  178. */
  179. wmlClearHList (mm_arg_ptr);
  180. wmlClearHList (mm_rsn_ptr);
  181. wmlClearHList (mm_ctl_ptr);
  182. argref = clsobj->arguments;
  183. while ( argref!= NULL )
  184. {
  185. while ( argref != NULL && argref->exclude == WmlAttributeTrue )
  186. argref = argref->next;
  187. if ( argref != NULL )
  188. {
  189. wmlInsertInHList (mm_arg_ptr,
  190. argref->act_resource->syndef->name,
  191. (ObjectPtr)argref);
  192. argref = argref->next;
  193. }
  194. }
  195. rsnref = clsobj->reasons;
  196. while ( rsnref!=NULL )
  197. {
  198. while ( rsnref != NULL && rsnref->exclude == WmlAttributeTrue )
  199. rsnref = rsnref->next;
  200. if ( rsnref != NULL )
  201. {
  202. wmlInsertInHList (mm_rsn_ptr,
  203. rsnref->act_resource->syndef->name,
  204. (ObjectPtr)rsnref);
  205. rsnref = rsnref->next;
  206. }
  207. }
  208. ctlref = clsobj->controls;
  209. while ( ctlref != NULL )
  210. {
  211. wmlInsertInHList (mm_ctl_ptr,
  212. ctlref->ctrl->syndef->name,
  213. (ObjectPtr)ctlref);
  214. ctlref = ctlref->next;
  215. }
  216. /*
  217. * Write out the controls and reason table.
  218. */
  219. rsnndx = 0;
  220. ctlndx = 0;
  221. if ( mm_ctl_ptr->cnt == 0 )
  222. fprintf (outfil, "No children are supported");
  223. while ( rsnndx<mm_rsn_ptr->cnt || ctlndx<mm_ctl_ptr->cnt )
  224. {
  225. if ( ctlndx < mm_ctl_ptr->cnt )
  226. {
  227. ctlref = (WmlClassCtrlDefPtr) mm_ctl_ptr->hvec[ctlndx].objptr;
  228. fprintf (outfil, "%s@",
  229. ctlref->ctrl->syndef->name);
  230. ctlndx += 1;
  231. }
  232. else
  233. fprintf (outfil, "@");
  234. if ( rsnndx < mm_rsn_ptr->cnt )
  235. {
  236. rsnref = (WmlClassResDefPtr) mm_rsn_ptr->hvec[rsnndx].objptr;
  237. fprintf (outfil, "%s\n",
  238. rsnref->act_resource->syndef->name);
  239. rsnndx += 1;
  240. }
  241. else
  242. fprintf (outfil, "\n");
  243. }
  244. fprintf (outfil, canned3);
  245. /*
  246. * Write out the argument table
  247. */
  248. argndx = 0;
  249. while ( argndx < mm_arg_ptr->cnt )
  250. {
  251. argref = (WmlClassResDefPtr) mm_arg_ptr->hvec[argndx].objptr;
  252. fprintf (outfil, "%s@%s@",
  253. argref->act_resource->syndef->name,
  254. argref->act_resource->dtype_def->syndef->name);
  255. if ( argref->dflt != NULL )
  256. {
  257. if ( strchr(argref->dflt,' ') != 0 )
  258. fprintf (outfil, "T{\n%s\nT}\n",
  259. argref->dflt);
  260. else
  261. fprintf (outfil, "%s\n",
  262. argref->dflt);
  263. }
  264. else
  265. {
  266. if (argref->act_resource->syndef->dflt != NULL) {
  267. if ( strchr(argref->act_resource->syndef->dflt,' ') != 0 )
  268. fprintf (outfil, "T{\n%s\nT}\n",
  269. argref->act_resource->syndef->dflt);
  270. else
  271. fprintf (outfil, "%s\n",
  272. argref->act_resource->syndef->dflt);
  273. }
  274. else
  275. fprintf (outfil, " \n");
  276. }
  277. argndx += 1;
  278. }
  279. fprintf (outfil, canned4);
  280. }