2 Copyright (C) 1994-2007 Frans Slothouber, Jacco van Weert, Petteri Kettunen,
3 Bernd Koesling, Thomas Aglassinger, Anthon Pang, Stefan Kost, David Druffner,
4 Sasha Vasko, Kai Hofmann, Thierry Pierron, Friedrich Haase, and Gergely Budai.
6 This file is part of ROBODoc
8 ROBODoc is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 /****h* Docuwala/ROBODoc
25 * ROBODoc is intended to be a replacement for the original AutoDocs
26 * program. ROBODoc will extract the comment headers from a source
27 * file, and put them into a separate documentation file.
30 * Sourcecode ---> [ROBODoc] ---> Document.
32 * The whole ROBODoc process consists of three steps: scanning,
33 * analysing, generating.
37 * ROBODoc scans the source directory tree. This collects the names of
38 * all the source files.
42 * ROBODOc analyses all the sourcefiles. This reads the content of all
43 * source files and collects all the headers.
47 * In this step the headers are written to one or more documentation files.
51 * The data collected during scanning and analysing is stored in a
52 * number of structures.
54 * RB_Directory, it stores the names of the sourcefiles and directories in
55 * the source direcory tree. File names are stored in a RB_Filename
56 * structure, directory names in a RB_Path structure. Each RB_Filename
57 * contains a pointer (path) to a RB_Path structure that tells in which
58 * directory a file is located. Each RB_Path has a pointer (parent) to
59 * another RB_Path structure that tells in which directory is a directory
60 * located (of which directory it is a subdirectory). The only exception
61 * is the root directory.
63 * Besides the name of the sourcefile, the RB_Filename also stores the
64 * name of the documentation file.
66 * For each sourcefile there is an RB_Part structure. It contains a
67 * pointer (filename) to the RB_Filename and a list (headers) of
68 * RB_Header structure containing the headers found in the sourcefile.
70 * Every RB_Header structure contains a pointer (owner) to the RB_Part
71 * structure to which it belongs. Headers can form a hierarchy that is
72 * used to create sections and subsections in the documentation. To
73 * store this hierarchy every RB_header structure contains a pointer
74 * (parent) to its parent header. For instance, given the following two
75 * headers, SubModule is the parent of SubSubModule.
76 * ****h* TopModule/SubModule
80 * ****h* SubModule/SubSubModule
84 * In the documentation this creates the sections
89 * The RB_Directory and the linked list of RB_Part structures are
90 * stored in a RB_Document structure.
92 * During the generation of the documentation ROBODoc tries to create
93 * cross links between the mention of a header's name (an object) and the
94 * documentation generated from that header (the documentation for the
97 * To aid this proces there is an array of RB_link structures. This
98 * array is sorted for quick searching. RB_link structures the name
99 * of a header and the name of the label under which the documentation
100 * can be found in the documentation file.
103 * See AUTHORS in the archive.
105 * 20-Dec-94 Jacco van Weert.
106 * MODIFICATION HISTORY
107 * See ChangeLog in the archive. Latest version can be found on:
108 * o http://www.xs4all.nl/~rfsber/Robo/
110 * Other bugs? Catch them in a jar and send them to rfsber -(at)- xs4all.nl
113 * $Id: robodoc.c,v 1.106 2007/07/10 19:13:52 gumpu Exp $
120 #include <sys/stat.h>
133 #include "analyser.h"
134 #include "generator.h"
135 #include "document.h"
136 #include "directory.h"
137 #include "roboconfig.h"
138 #include "optioncheck.h"
144 /* Functions local to this file. */
146 T_RB_DocType Find_DocType(
149 actions_t Find_Actions(
158 static int PathBegin_Check(
161 static void Path_Check(
165 char *Find_Parameterized_Option(
168 char *RB_Find_In_Argv_Parameterized_Option(
173 static char *General_Find_Parameterized_Option(
178 static char *Fix_Path(
181 static char *Path_Convert_Win32_to_Unix(
184 static char *Find_And_Fix_Path(
187 static void RB_Summary(
188 struct RB_Document *document );
190 static void Find_Tabstops(
193 static void Find_And_Install_Document_Name(
195 unsigned char type );
198 "$VER: robodoc " VERSION " (" __DATE__
199 ") (c) by Maverick Software Development 1994-2006";
202 /****h* ROBODoc/UserInterface
204 * This module contains functions to parse the
205 * command line and inform the user about any errors.
210 /****v* UserInterface/use
212 * use -- usage string
214 * Inform the user how to use ROBODoc.
222 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
223 "ROBODoc Version " VERSION " autodocs formatter ($Revision: 1.106 $)\n"
224 "(c) 1994-2007 Frans Slothouber, Petteri Kettunen, \n"
225 " Gergely Budai and Jacco van Weert\n"
226 "ROBODoc comes with ABSOLUTELY NO WARRANTY.\n"
227 "This is free software, and you are welcome to redistribute it\n"
228 "under certain conditions; type `robodoc -c' for details.\n" "\n";
231 " robodoc --src <directory> --doc <directory> --multidoc [type] [options]\n"
232 " robodoc --src <directory> --doc <file> --singledoc [type] [options]\n"
233 " robodoc --src <file> --doc <file> --singlefile [type] [options]\n"
235 "Type:\n" " --html, --rtf, --latex, --ascii, --dbxml, --troff\n" "\n";
236 char use_options1[] =
238 " --charset NAME Add character encoding information (html only).\n"
239 " --cmode Use ANSI C grammar in source items (html only).\n"
240 " --css Specify the stylesheet to use.\n"
241 " --ext EXTENSION Set extension for generated files.\n"
242 " --footless Do not create the foot of a document.\n"
243 " --headless Do not create the head of a document.\n"
244 " --index Add an index.\n";
245 char use_options2[] =
246 " --internal Also include internal headers.\n"
247 " --internalonly Only include internal headers.\n"
248 " --lock Recognize only one header marker per file.\n"
249 " --nodesc Do not descent into subdirectories.\n"
250 " --no_subdirectories\n"
251 " Do no create documentation subdirectories.\n"
252 " --nopre Do not use <PRE> </PRE> in the HTML output.\n"
253 " --nosort Do not sort the headers.\n"
254 " --nosource Do not include SOURCE items.\n"
255 " --nogeneratedwith\n"
256 " Do not add the 'generated by robodoc' message\n"
257 " at the top of each documentation file.\n"
258 " --ignore_case_when_linking\n"
259 " Ignore the case of the symbols when trying\n"
260 " to create crosslinks.\n";
261 char use_options3[] =
262 " --rc Specify an alternate configuration file.\n"
263 " --sections Add sections and subsections.\n"
264 " --first_section_level NUMBER\n"
265 " Start the first section not at 1 but at \n"
267 " --tabsize NUMBER Set the tab size.\n"
268 " --tabstops a,b,..,n\n"
270 " --tell ROBODoc will tell you what it is doing.\n"
271 " --debug same as --tell, but with lots more details.\n"
272 " --toc Add a table of contents.\n"
273 " --version Print version info and exit.\n"
274 " --sectionnameonly\n"
275 " Generate section header with name only.\n"
276 " --compress Only supported by TROFF output format. Defines by which\n"
277 " program manpages will be compressed. Either bzip2 or gzip.\n"
278 " --mansection Manual section where pages will be inserted (default: 3).\n"
279 " --documenttitle TITLE\n"
280 " Set the document title\n"
281 " --altlatex Alternate LaTeX file format (bigger / clearer than normal)\n"
282 " --latexparts Make the first module level as PART in LaTeX output\n"
283 " --syntaxcolors Turn on all syntax highlighting features in SOURCE items\n"
285 " --syntaxcolors_enable quotes,squotes,line_comments,block_comments,\n"
286 " keywords,non_alpha\n"
287 " Enable only specific syntax highlighting features in\n"
288 " SOURCE items (html only)\n"
289 " --dotname NAME Specify the name (and path / options) of DOT tool\n"
290 " --masterindex title,filename\n"
291 " Specify the tile and filename for master index page\n"
292 " --sourceindex title,filename\n"
293 " Specify the tile and filename for source files index page\n"
294 " --document_header filename\n"
295 " Read document header from specified file\n"
296 " --document_footer filename\n"
297 " Read document footer from specified file\n"
298 " --one_file_per_header\n"
299 " Create a separate documentation file for each header\n"
300 " --module_index_menu\n"
301 " Create a module menu when used with --one_file_per_header\n"
303 " Create a header TOC when used with --one_file_per_header\n"
304 " --header_breaks NUMBER\n"
305 " Insert a linebreak after every NUMBER header names\n"
306 " (default value: 2, set to zero to disable)\n" "\n";
308 "Authors/Contributors:\n"
309 " Frans Slothouber, Jacco van Weert, Petteri Kettunen, Bernd Koesling,\n"
310 " Thomas Aglassinger, Anthon Pang, Stefan Kost, David Druffner, Sasha Vasko,\n"
311 " Kai Hofmann, Thierry Pierron, Friedrich Haase, Gergely Budai.\n";
315 /****v* UserInterface/copying
317 * Information about the ROBODoc licence.
321 * 2003-02-25/petterik: corrected link to GNU copyleft.
327 " Distributed under the GNU GENERAL PUBLIC LICENSE\n"
328 " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
329 " See the source archive for a copy of the complete licence\n"
330 " If you do not have it you can get it from URL\n"
331 " http://www.gnu.org/copyleft/gpl.html\n";
334 static void dump_version(
337 printf( "%s\n", VERSION );
338 /* TODO create an option to show robodoc configuration,
339 * including compiler setting etc..
340 printf( "Configuration:\n" );
341 printf( " locale: %s", setlocale( LC_ALL, "" ) );
345 /* TODO This function is too long. */
347 /****f* UserInterface/main
349 * Get and parse the arguments. Analyse document and generate the
350 * documentation. Everything starts from here.
360 struct RB_Document *document = NULL;
361 struct RB_Directory *srctree = NULL;
363 char *used_rc_file = NULL;
371 TODO, make setlocale work.
374 if ( (loc = getenv("LC_CTYPE") ) != NULL )
376 printf( ".... %s\n", loc );
377 setlocale( LC_ALL, loc);
381 setlocale(LC_ALL, "");
385 whoami = argv[0]; /* global me,myself&i */
387 // Init Actions global
388 course_of_action = No_Actions( );
390 /* Read the configuration file. This might contain
392 RB_SetCurrentFile( NULL );
393 used_rc_file = ReadConfiguration( argc, argv,
394 RB_Find_In_Argv_Parameterized_Option
395 ( argc, argv, "--rc" ) );
397 /* Force debug mode early if the user wants the debug mode */
398 debugmode = Find_DebugMode( );
399 course_of_action.do_tell = TRUE;
401 if ( Check_Options( ) == EXIT_FAILURE )
407 if ( Find_Option( "-c" ) )
409 printf( "%s", copying );
413 if ( Find_Option( "--version" ) )
419 if ( Find_Option( "--help" ) )
421 printf( "%s%s%s%s%s%s", use, use_usage, use_options1, use_options2,
422 use_options3, use_authors );
426 output_mode = Find_DocType( ); /* one of the globals that are still left */
427 if ( output_mode == UNKNOWN )
433 /* First the basics. */
434 document = RB_Get_RB_Document( );
435 document->doctype = output_mode;
436 document->actions = Find_Actions( );
437 debug = document->debugmode = Find_DebugMode( );
438 document->charset = Find_Parameterized_Option( "--charset" );
439 document->extension = Find_Parameterized_Option( "--ext" );
440 document->css = Find_Parameterized_Option( "--css" );
441 document->compress = Find_Parameterized_Option( "--compress" );
442 document->section = Find_Parameterized_Option( "--mansection" );
443 document_title = Find_Parameterized_Option( "--documenttitle" );
444 doc_h = Find_Parameterized_Option( "--document_header" );
445 doc_f = Find_Parameterized_Option( "--document_footer" );
446 optstr = Find_Parameterized_Option( "--first_section_level" );
449 document->first_section_level = atoi( optstr );
452 course_of_action = document->actions; /* a global */
453 debugmode = document->debugmode; /* a global */
455 RB_Say( "Using %s for defaults\n", SAY_INFO, used_rc_file );
456 free( used_rc_file ); /* No longer necessary */
461 document->css = Path_Convert_Win32_to_Unix( document->css );
464 if ( ( document->actions.do_index ) && output_mode == TROFF )
466 RB_Warning( "Index generation not supported for TROFF format.\n" );
467 document->actions.do_index = FALSE;
470 if ( Find_Parameterized_Option( "--doctype_name" ) &&
471 Find_Parameterized_Option( "--doctype_location" ) )
473 document->doctype_name =
474 Find_Parameterized_Option( "--doctype_name" );
475 document->doctype_location =
476 Find_Parameterized_Option( "--doctype_location" );
479 // Find tab sizes and tab stops
482 // Find master index file name
483 Find_And_Install_Document_Name( "--masterindex", HT_MASTERINDEXTYPE );
485 // Find source index file name
486 Find_And_Install_Document_Name( "--sourceindex", HT_SOURCEHEADERTYPE );
488 // Find DOT tool name
489 optstr = Find_Parameterized_Option( "--dotname" );
495 // Find number of headers before linebreak
496 optstr = Find_Parameterized_Option( "--header_breaks" );
499 int breaks = atoi( optstr );
503 breaks = MAX_HEADER_BREAKS;
505 header_breaks = breaks;
509 if ( !document->extension )
511 document->extension = RB_Get_Default_Extension( document->doctype );
515 /* Test if there is a --src and --doc */
516 if ( !Find_Parameterized_Option( "--src" ) )
518 printf( "Error: you need to specify a source"
519 " file or directory with --src.\n" );
523 if ( !Find_Parameterized_Option( "--doc" ) )
525 printf( "Error: you need to specify a documentation file"
526 " or directory with --doc.\n" );
531 /* Open header and footer files */
534 FILE *dh = fopen( doc_h, "r" );
537 printf( "Error: '%s' no such file or directory\n", doc_h );
542 memset( buffer, 0, sizeof( buffer ) );
543 r_len = fread ( buffer, 1, sizeof( buffer ), dh );
546 document_header = calloc( r_len, sizeof( *document_header ) );
547 memcpy( document_header, buffer, r_len );
553 FILE *df = fopen( doc_f, "r" );
556 printf( "Error: '%s' no such file or directory\n", doc_f );
561 memset( buffer, 0, sizeof( buffer ) );
562 r_len = fread ( buffer, 1, sizeof( buffer ), df );
565 document_footer = calloc( r_len, sizeof( *document_footer ) );
566 memcpy( document_footer, buffer, r_len );
571 /* What mode are we using? */
572 if ( Find_Option( "--multidoc" ) )
574 char *srcrootname; /* directory */
577 srcrootname = Find_And_Fix_Path( "--src" );
578 if ( !Stat_Path( 'e', srcrootname ) )
580 printf( "Error: %s does not exists\n", srcrootname );
585 if ( !Stat_Path( 'd', srcrootname ) )
587 printf( "Error: %s is not a directory\n", srcrootname );
591 document->srcroot = RB_Get_RB_Path( srcrootname );
593 docrootname = Find_And_Fix_Path( "--doc" );
594 Path_Check( srcrootname, docrootname );
596 document->docroot = RB_Get_RB_Path( docrootname );
598 srctree = RB_Get_RB_Directory( srcrootname, docrootname );
599 document->srctree = srctree;
601 RB_Document_Create_Parts( document );
602 RB_Analyse_Document( document );
603 RB_Generate_Documentation( document );
605 RB_Free_RB_Path( document->srcroot );
606 document->srcroot = 0;
607 RB_Free_RB_Path( document->docroot );
608 document->docroot = 0;
609 RB_Free_RB_Directory( srctree );
610 document->srctree = 0;
612 else if ( output_mode == TROFF )
614 RB_Panic( "Only --multidoc is supported for TROFF output.\n" );
616 else if ( Find_Option( "--singledoc" ) )
618 char *srcrootname; /* directory */
620 srcrootname = Find_And_Fix_Path( "--src" );
621 if ( !Stat_Path( 'e', srcrootname ) )
623 printf( "Error: %s does not exists\n", srcrootname );
628 if ( !Stat_Path( 'd', srcrootname ) )
630 printf( "Error: %s is not a directory\n", srcrootname );
634 document->srcroot = RB_Get_RB_Path( srcrootname );
636 document->docroot = 0;
637 document->singledoc_name = Find_And_Fix_Path( "--doc" );
639 srctree = RB_Get_RB_Directory( srcrootname, NULL );
640 document->srctree = srctree;
642 RB_Document_Create_Parts( document );
643 RB_Analyse_Document( document );
644 RB_Generate_Documentation( document );
646 RB_Free_RB_Directory( srctree );
648 else if ( Find_Option( "--singlefile" ) )
650 char *srcfile; /* file */
651 char *docfile; /* file */
653 document->docroot = 0;
654 docfile = Find_And_Fix_Path( "--doc" );
655 document->singledoc_name = docfile;
656 srcfile = Find_And_Fix_Path( "--src" );
657 if ( !Stat_Path( 'e', srcfile ) )
659 printf( "Error: %s does not exists\n", srcfile );
664 if ( !Stat_Path( 'f', srcfile ) )
666 printf( "Error: %s is not a file\n", srcfile );
671 document->srctree = RB_Get_RB_SingleFileDirectory( srcfile );
673 RB_Get_RB_Path( document->srctree->first_path->name );
675 RB_Document_Create_Parts( document );
676 RB_Analyse_Document( document );
677 RB_Generate_Documentation( document );
679 RB_Free_RB_Directory( document->srctree );
685 ( "\n\nError: Use either --multidoc, --singledoc, or --singlefile\n" );
689 RB_Summary( document );
690 RB_Free_RB_Document( document );
691 Free_Configuration( );
694 /* Mac OS X specific: print memory leaks */
695 if ( debug & SAY_DEBUG )
699 sprintf( cmd, "/usr/bin/leaks %d", getpid( ) );
702 #endif /* __APPLE__ */
710 /****if* UserInterface/Find_Tabstops
712 * This function looks for the tab stop configuration and fills out the
716 static void Find_Tabstops(
723 int tabsize = DEFAULT_TABSIZE;
727 optstr = Find_Parameterized_Option( "--tabsize" );
730 tabsize = atoi( optstr );
733 // Fill tabstop table with default values
734 for ( i = 0; i < MAX_TABS; i++ )
736 tab_stops[i] = tabsize * ( i + 1 );
740 optstr = Find_Parameterized_Option( "--tabstops" );
743 // Get TAB sizes and fill table
744 for ( str = strtok( optstr, TABSIZE_SEPARATOR ), i = 0;
745 str != NULL && i < MAX_TABS;
746 str = strtok( NULL, TABSIZE_SEPARATOR ), i++ )
748 tab_stops[i] = atoi( str ) - 1;
756 /****if* UserInterface/Find_And_Install_Document_Name
758 * Looks for specific option strings and installs special document titles
761 * Should be used to overwrite the HT_MASTERINDEXTYPE or HT_SOURCEHEADERTYPE
762 * entries in the header_type_lookup_table.
765 static void Find_And_Install_Document_Name(
770 * o option -- the option string to look for
771 * o type -- the type entry in header_type_lookup_table to overwrite
772 * (Should be either HT_MASTERINDEXTYPE or HT_SOURCEHEADERTYPE)
777 char *title = NULL, *filename = NULL, *optstr = NULL;
779 // First find the option
780 optstr = Find_Parameterized_Option( option );
784 // Break the option into substrings
785 title = strtok( optstr, "," );
786 filename = strtok( NULL, "," );
788 // If something missing
789 if ( title == NULL || filename == NULL )
791 RB_Panic( "Invalid %s option\n", option );
794 // Install document title and filename
795 RB_AddHeaderType( type, title, filename, 0 );
803 /****f* UserInterface/Find_And_Fix_Path
805 * Searches through the options to find a path.
806 * This path is converted to a propper path
807 * if it contains errors such as the use of
808 * '\' or when it does not start with ./ or a
810 * The option must exist.
813 static char *Find_And_Fix_Path(
817 * o option_name -- the option name for the path
819 * o path -- the path.
827 temp = Find_Parameterized_Option( option_name );
829 temp = Path_Convert_Win32_to_Unix( temp );
830 temp2 = Fix_Path( temp );
838 /****f* UserInterface/Path_Convert_Win32_to_Unix
840 * Although people are supposed to specify all paths
841 * with a '/' as seperator, sometimes people on Win32
842 * use '\', this causes problems later on in some
843 * other function of robodoc that expect a '/'.
844 * So to prevent this we replace all the '\' in a path
847 * In addition people sometimes add a '/' at the
848 * end of the path. We remove it.
852 static char *Path_Convert_Win32_to_Unix(
856 * o path -- the path.
858 * o path -- the converted path (in a newly allocated
865 /* First make a copy */
866 path = RB_StrDup( path );
867 for ( i = 0; i < strlen( path ); ++i )
869 if ( path[i] == '\\' )
875 /* Remove trailing '/' if there is one. */
876 if ( path[strlen( path ) - 1] == '/' )
878 path[strlen( path ) - 1] = '\0';
886 /****f* UserInterface/Path_Check
888 * Test the validity of the doc and source path. The doc path should
889 * not be a sub directory of the source path otherwise the generated
890 * documentation will be part of the generated documentation if
891 * robodoc is run more than once.
895 static void Path_Check(
900 * o sourcepath -- the path to the source files.
901 * o docpath -- the path to the documentation files.
912 dl = strlen( docpath );
913 sl = strlen( sourcepath );
919 for ( i = 0; i < sl; ++i )
921 if ( docpath[i] != sourcepath[i] )
927 if ( equal && ( dl == sl ) )
930 ( "The source path and document path can not be equal\n" );
943 /****f* UserInterface/PathBegin_Check
945 * Checks the validity of a path.
946 * A path should start with
951 * have a ':' some where
954 static int PathBegin_Check(
958 * o path -- the path to be cheked.
960 * o FALSE -- path is not OK.
961 * o TRUE -- path is OK.
966 int l = strlen( path );
970 result = ( path[0] == '.' );
974 result = ( ( path[0] == '.' ) && ( path[1] == '/' ) ) ||
975 ( path[0] == '/' ) || ( strchr( path, ':' ) != NULL );
988 /****f* UserInterface/Find_Option
990 * Search configuration.options for a specific option.
996 * o option -- the option to be found.
998 * o TRUE -- option does exist
999 * o FALSE -- option does not exist
1003 unsigned int parameter_nr;
1006 for ( parameter_nr = 0;
1007 parameter_nr < configuration.options.number; parameter_nr++ )
1009 if ( !RB_Str_Case_Cmp
1010 ( configuration.options.names[parameter_nr], option ) )
1021 /****f* UserInterface/Fix_Path
1023 * Add a "./" to a path if it does not start with a "./" or does not
1024 * contain a ":". If the path was "." just add a "/". Adding a
1025 * "./" simplifies the creating of relative links during the
1026 * generation process.
1030 static char *Fix_Path(
1034 * o path -- the path to be fixed.
1036 * A pointer to a newly allocated string containing the path.
1042 if ( !PathBegin_Check( path ) )
1044 char *prefix = "./";
1046 if ( strcmp( path, "." ) == 0 )
1048 result = RB_StrDup( prefix );
1052 int l = strlen( path );
1054 l += strlen( prefix ) + 1;
1055 result = malloc( l );
1058 strcat( result, prefix );
1059 strcat( result, path );
1064 result = RB_StrDup( path );
1072 /* TODO: FS Documentation */
1074 T_RB_DocType Find_DocType(
1077 T_RB_DocType doctype = UNKNOWN;
1078 unsigned int parameter_nr;
1080 for ( parameter_nr = 0;
1081 parameter_nr < configuration.options.number; parameter_nr++ )
1084 if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1090 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1096 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1102 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1108 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1114 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1120 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1123 doctype = XMLDOCBOOK;
1135 actions_t No_Actions(
1140 unsigned char *actptr;
1142 for ( i = 0, actptr = ( unsigned char * ) &actions;
1143 i < sizeof( actions ); i++, actptr++ )
1151 /* TODO: FS Documentation */
1152 actions_t Find_Actions(
1156 unsigned int parameter_nr;
1159 actions = No_Actions( );
1161 for ( parameter_nr = 0;
1162 parameter_nr < configuration.options.number; parameter_nr++ )
1164 if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1167 actions.do_singledoc = TRUE;
1169 if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1172 actions.do_singlefile = TRUE;
1174 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1177 actions.do_multidoc = TRUE;
1179 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1180 "--no_subdirectories" ) )
1182 actions.do_no_subdirectories = TRUE;
1184 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1185 "--one_file_per_header" ) )
1187 actions.do_one_file_per_header = TRUE;
1189 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1190 "--module_index_menu" ) )
1192 actions.do_module_index_menu = TRUE;
1194 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1197 actions.do_header_toc = TRUE;
1199 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1202 actions.do_sections = TRUE;
1204 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1207 actions.do_include_internal = TRUE;
1209 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1210 "--ignore_case_when_linking" ) )
1212 actions.do_ignore_case_when_linking = TRUE;
1214 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1215 "--internalonly" ) )
1217 actions.do_internal_only = TRUE;
1219 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1222 actions.do_toc = TRUE;
1224 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1227 actions.do_index = TRUE;
1229 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1232 actions.do_nosource = TRUE;
1234 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1237 actions.do_tell = TRUE;
1239 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1242 actions.do_tell = TRUE;
1244 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1247 actions.do_nodesc = TRUE;
1249 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1250 "--nogeneratedwith" ) )
1252 actions.do_nogenwith = TRUE;
1254 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1257 actions.do_quotes = TRUE;
1258 actions.do_squotes = TRUE;
1259 actions.do_line_comments = TRUE;
1260 actions.do_block_comments = TRUE;
1261 actions.do_keywords = TRUE;
1262 actions.do_non_alpha = TRUE;
1264 Install_C_Syntax( );
1266 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1269 actions.do_lockheader = TRUE;
1271 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1274 actions.do_footless = TRUE;
1276 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1279 actions.do_verbal = TRUE;
1281 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1284 actions.do_ms_errors = TRUE;
1286 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1289 actions.do_headless = TRUE;
1291 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1294 actions.do_nosort = TRUE;
1296 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1299 actions.do_nopre = TRUE;
1301 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1302 "--sectionnameonly" ) )
1304 actions.do_sectionnameonly = TRUE;
1306 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1309 actions.do_altlatex = TRUE;
1311 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1314 actions.do_latexparts = TRUE;
1316 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1317 "--syntaxcolors" ) )
1319 actions.do_quotes = TRUE;
1320 actions.do_squotes = TRUE;
1321 actions.do_line_comments = TRUE;
1322 actions.do_block_comments = TRUE;
1323 actions.do_keywords = TRUE;
1324 actions.do_non_alpha = TRUE;
1332 // Find specific syntax colors enable options
1333 optstr = Find_Parameterized_Option( "--syntaxcolors_enable" );
1339 for ( str = strtok( optstr, "," ); str; str = strtok( NULL, "," ) )
1341 if ( !RB_Str_Case_Cmp( str, "quotes" ) )
1343 actions.do_quotes = TRUE;
1345 else if ( !RB_Str_Case_Cmp( str, "squotes" ) )
1347 actions.do_squotes = TRUE;
1349 else if ( !RB_Str_Case_Cmp( str, "line_comments" ) )
1351 actions.do_line_comments = TRUE;
1353 else if ( !RB_Str_Case_Cmp( str, "block_comments" ) )
1355 actions.do_block_comments = TRUE;
1357 else if ( !RB_Str_Case_Cmp( str, "keywords" ) )
1359 actions.do_keywords = TRUE;
1361 else if ( !RB_Str_Case_Cmp( str, "non_alpha" ) )
1363 actions.do_non_alpha = TRUE;
1367 // Bad option specified
1368 RB_Panic( "Invalid --syntaxcolors_enable option: %s\n", str );
1376 /* TODO: FS Documentation */
1377 long Find_DebugMode(
1381 unsigned int parameter_nr;
1383 for ( parameter_nr = 0;
1384 parameter_nr < configuration.options.number; parameter_nr++ )
1386 if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1392 else if ( !RB_Str_Case_Cmp( configuration.options.names[parameter_nr],
1401 /****f* UserInterface/Find_Parameterized_Option
1403 * Search for an option of the form
1404 * --a_option_name a_value
1405 * in configuration.options.
1408 char *Find_Parameterized_Option(
1412 * optionname -- the name of the option to search for.
1414 * NULL if the option is not found, a pointer to the value
1417 * Results in a Panic if the option is found but
1418 * no value is specified.
1422 return General_Find_Parameterized_Option( configuration.options.number,
1423 &( configuration.options.
1424 names[0] ), optionname );
1430 /****f* UserInterface/RB_Find_In_Argv_Parameterized_Option
1432 * Search for an option of the form
1433 * --a_option_name a_value
1434 * in argv. The function is used to look for the
1436 * option that can be used to specify an
1437 * alternate robodoc configuration file.
1440 char *RB_Find_In_Argv_Parameterized_Option(
1446 * * argc -- the argument count as received by main().
1447 * * argv -- the array of argument values as received by main()
1448 * * optionname -- the name of the option to search for.
1450 * NULL if the option is not found, a pointer to the value
1453 * Results in a Panic if the option is found but
1454 * no value is specified.
1458 return General_Find_Parameterized_Option( argc, argv, optionname );
1464 /****f* UserInterface/General_Find_Parameterized_Option
1466 * Search for an option of the form
1467 * --a_option_name a_value
1470 static char *General_Find_Parameterized_Option(
1476 * o n -- the number of options in the options array.
1477 * o options -- the options array
1478 * o optionname -- the name of the option to search for.
1480 * NULL if the option is not found, a pointer to the value
1483 * Results in a Panic if the option is found but
1484 * no value is specified.
1491 for ( parameter_nr = 0; parameter_nr < n; parameter_nr++ )
1493 if ( !RB_Str_Case_Cmp( options[parameter_nr], optionname ) )
1495 if ( parameter_nr < n - 1 )
1497 value = options[parameter_nr + 1];
1498 if ( ( value[0] == '-' ) && ( value[1] == '-' ) )
1505 /* to few parameters. */
1509 RB_Panic( "you must be more specific"
1510 " with the %s option\n", optionname );
1520 /* TODO Documentation */
1522 static void RB_Summary(
1523 struct RB_Document *document )
1527 printf( "Ready\n" );
1530 printf( "Found %d headers\n", document->no_headers );
1532 if ( number_of_warnings )
1534 printf( "Found %d warnings\n", number_of_warnings );