diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-03-08 16:52:38 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-03-08 16:52:38 +0000 |
commit | 92288b460b1f5d92b8d3d4eaedbab75bc3abcae4 (patch) | |
tree | e176b73e49125de01a311fb375dab57111bb5995 | |
parent | ef81cdf7771a03823664fb4c88a8af4c24da53fa (diff) | |
download | ATCD-92288b460b1f5d92b8d3d4eaedbab75bc3abcae4.tar.gz |
*** empty log message ***
-rw-r--r-- | ace/Parse_Node.cpp | 4 | ||||
-rw-r--r-- | ace/Parse_Node.h | 4 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 12 | ||||
-rw-r--r-- | ace/Service_Config.h | 8 | ||||
-rw-r--r-- | ace/Svc_Conf.h | 4 | ||||
-rw-r--r-- | ace/Svc_Conf_Lexer_Guard.cpp | 4 | ||||
-rw-r--r-- | ace/Svc_Conf_l.cpp | 5 | ||||
-rw-r--r-- | ace/Svc_Conf_y.cpp | 8 | ||||
-rw-r--r-- | ace/config-all.h | 13 | ||||
-rwxr-xr-x | bin/svcconf-convert.pl | 288 |
10 files changed, 326 insertions, 24 deletions
diff --git a/ace/Parse_Node.cpp b/ace/Parse_Node.cpp index 37ad2d1b4d0..a89b49e9e73 100644 --- a/ace/Parse_Node.cpp +++ b/ace/Parse_Node.cpp @@ -7,7 +7,7 @@ // Provide the class hierarchy that defines the parse tree of Service // Nodes. -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) #if !defined (__ACE_INLINE__) #include "ace/Parse_Node.i" @@ -651,4 +651,4 @@ ACE_Static_Function_Node::~ACE_Static_Function_Node (void) #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ diff --git a/ace/Parse_Node.h b/ace/Parse_Node.h index 288b2a42210..a47889d3e6b 100644 --- a/ace/Parse_Node.h +++ b/ace/Parse_Node.h @@ -22,7 +22,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) /** * @class ACE_Parse_Node * @@ -339,7 +339,7 @@ extern int ace_yyerrno; // Global variable used to communicate between the parser and the main // program. extern ACE_Service_Config *ace_this_svc; -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ #include "ace/post.h" #endif /* ACE_PARSE_NODE_H */ diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index a40f54eb946..a8dc3c0da09 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -298,7 +298,7 @@ ACE_Service_Config::initialize (const ACE_Service_Type *sr, } } -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) int ACE_Service_Config::process_directives_i (ACE_Svc_Conf_Param *param) { @@ -323,7 +323,7 @@ ACE_Service_Config::process_directives_i (ACE_Svc_Conf_Param *param) else return 0; } -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ int ACE_Service_Config::process_file (const ACE_TCHAR file[]) @@ -332,7 +332,7 @@ ACE_Service_Config::process_file (const ACE_TCHAR file[]) int result = 0; -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) FILE *fp = ACE_OS::fopen (file, ACE_LIB_TEXT ("r")); @@ -357,7 +357,7 @@ ACE_Service_Config::process_file (const ACE_TCHAR file[]) (void) ACE_OS::fclose (fp); } -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ return result; } @@ -372,7 +372,7 @@ ACE_Service_Config::process_directive (const ACE_TCHAR directive[]) ACE_LIB_TEXT ("Service_Config::process_directive - %s\n"), directive)); -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) ACE_UNUSED_ARG (directive); ACE_Svc_Conf_Param d (directive); @@ -382,7 +382,7 @@ ACE_Service_Config::process_directive (const ACE_TCHAR directive[]) return result; #else return -1; -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ } // Process service configuration requests as indicated in the queue of diff --git a/ace/Service_Config.h b/ace/Service_Config.h index f84ff86b7c3..f61b3e7497f 100644 --- a/ace/Service_Config.h +++ b/ace/Service_Config.h @@ -31,9 +31,9 @@ class ACE_Service_Type; class ACE_Allocator; class ACE_Reactor; class ACE_Thread_Manager; -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) class ACE_Svc_Conf_Param; -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF ==1 */ extern "C" { @@ -357,12 +357,12 @@ protected: /// command-line. Returns the number of errors that occurred. static int process_commandline_directives (void); -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) /// This is the implementation function that process_directives() /// and process_directive() both call. Returns the number of errors /// that occurred. static int process_directives_i (ACE_Svc_Conf_Param *param); -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ /// Become a daemon. static int start_daemon (void); diff --git a/ace/Svc_Conf.h b/ace/Svc_Conf.h index 971699fc9af..d0f5a0efefc 100644 --- a/ace/Svc_Conf.h +++ b/ace/Svc_Conf.h @@ -28,7 +28,7 @@ #include "ace/Service_Config.h" #include "ace/Parse_Node.h" -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) // Forward declarations. struct ace_yy_buffer_state; @@ -196,7 +196,7 @@ extern ACE_TCHAR *ace_yytext; /// Holds the length of the lexeme for the current token extern int ace_yyleng; -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ /// Factory that creates a new ACE_Service_Type_Impl. extern ACE_Service_Type_Impl * diff --git a/ace/Svc_Conf_Lexer_Guard.cpp b/ace/Svc_Conf_Lexer_Guard.cpp index 74e4db70461..582b84cd82f 100644 --- a/ace/Svc_Conf_Lexer_Guard.cpp +++ b/ace/Svc_Conf_Lexer_Guard.cpp @@ -1,8 +1,8 @@ // -*- C++ -*- -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) #include "ace/Svc_Conf.h" +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) #include "ace/Svc_Conf_Lexer_Guard.h" ACE_RCSID (ace, @@ -35,4 +35,4 @@ ACE_Svc_Conf_Lexer_Guard::~ACE_Svc_Conf_Lexer_Guard (void) ::ace_yy_pop_buffer (this->buffer_); } -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ diff --git a/ace/Svc_Conf_l.cpp b/ace/Svc_Conf_l.cpp index 5dcfda2d7f0..ad6e397365f 100644 --- a/ace/Svc_Conf_l.cpp +++ b/ace/Svc_Conf_l.cpp @@ -1,4 +1,3 @@ -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) #define ACE_YY_NO_UNPUT /* A lexical scanner generated by flex */ @@ -39,6 +38,8 @@ #endif /* __STDC__ */ #endif /* ! __cplusplus */ +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) + #ifdef __TURBOC__ #pragma warn -rch #pragma warn -use @@ -1840,4 +1841,4 @@ ace_yy_pop_buffer (ace_yy_buffer_state *buffer) ace_yy_switch_to_buffer (buffer); } -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ diff --git a/ace/Svc_Conf_y.cpp b/ace/Svc_Conf_y.cpp index e64cc1ace3d..00213e1d2e2 100644 --- a/ace/Svc_Conf_y.cpp +++ b/ace/Svc_Conf_y.cpp @@ -2,7 +2,7 @@ /* A Bison parser, made from Svc_Conf.y by GNU Bison version 1.28 */ -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) #define ACE_YYBISON 1 /* Identify Bison output. */ #define ACE_DYNAMIC 257 @@ -19,7 +19,7 @@ #define ACE_PATHNAME 268 #define ACE_IDENT 269 #define ACE_STRING 270 -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ // $Id$ @@ -33,7 +33,7 @@ ACE_RCSID (ace, Svc_Conf_y, "$Id$") -#if defined (ACE_HAS_LEGACY_SERVICE_CONFIG) +#if defined (ACE_HAS_CLASSIC_SVC_CONF) && (ACE_HAS_CLASSIC_SVC_CONF == 1) // Prototypes. static ACE_Module_Type *ace_get_module (ACE_Static_Node *str_rec, ACE_Static_Node *svc_type); @@ -1369,7 +1369,7 @@ main (int argc, ACE_TCHAR *argv[]) return ace_yyparse (¶m); } #endif /* DEBUGGING */ -#endif /* ACE_HAS_LEGACY_SERVICE_CONFIG */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF && ACE_HAS_CLASSIC_SVC_CONF == 1 */ ACE_Service_Type_Impl * ace_create_service_type (const ACE_TCHAR *name, diff --git a/ace/config-all.h b/ace/config-all.h index a4e65d8f278..31765055c2b 100644 --- a/ace/config-all.h +++ b/ace/config-all.h @@ -615,6 +615,19 @@ typedef void *(*ACE_THR_C_FUNC)(void *); #endif /* ACE_HAS_PACE */ // ============================================================================ +// ACE_HAS_CLASSIC_SVC_CONF macro +// ============================================================================ + +// For now, default is to use the classic svc.conf format. +#if !defined (ACE_HAS_CLASSIC_SVC_CONF) +# if defined (ACE_HAS_XML_SVC_CONF) +# define ACE_HAS_CLASSIC_SVC_CONF 0 +# else +# define ACE_HAS_CLASSIC_SVC_CONF 1 +# endif /* ACE_HAS_XML_SVC_CONF */ +#endif /* ACE_HAS_CLASSIC_SVC_CONF */ + +// ============================================================================ // Miscellaneous macros // ============================================================================ diff --git a/bin/svcconf-convert.pl b/bin/svcconf-convert.pl new file mode 100755 index 00000000000..44bfce65270 --- /dev/null +++ b/bin/svcconf-convert.pl @@ -0,0 +1,288 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# +# File: svcconf-convert.pl: +# Purpose: This perl script convert classic svc.conf file into XML svc.conf file format. +# Usage: svcconf-convert.pl [-i infile] [-o outfile] [-verbose] [-nocomment] +# -i: Specify the input classic svc.conf filename. +# If omitted, the default input filename is "svc.conf". +# -o: Specify the output XML svc.conf filename. +# If this argument is omitted, the resulting XML file will be written +# to file called <input filename>.xml. +# -verbose: Verbose output. +# -nocomment: Remove all comments. Use this argument if you have comments +# mixing in the middle of a classic svc.conf directive. + +$indent = 0; + +sub inc_indent +{ + $indent += 2; +} + +sub dec_indent +{ + $indent -= 2; +} + +sub get_indent +{ + $retv = 0; + print STDERR "$0 (", $lineno, "): Unbalanced macro pairs\n" if ($indent < 0); + $retv = $indent - 1 if ($indent > 0); + $retv; +} + +sub acexml_comment +{ + my $comment = shift; + print OUT " " x &get_indent (), "<!-- $comment -->\n"; +} + +sub acexml_start +{ + my $name = shift; + my $standalone = shift; + + print OUT " " x &get_indent (), "<$name"; + + + while (@attnames) + { + print OUT " ", pop (@attnames), '="', pop (@attvalues), '"'; + } + + if ($standalone != 0) + { + print OUT "/>\n"; + } + else + { + print OUT ">\n"; + inc_indent (); + } +} + +sub acexml_end +{ + my $name = shift; + + dec_indent (); + print OUT " " x &get_indent (), "</$name>\n"; +} + +$verbose = 0; +$nocomment = 0; +@attvalues = (); +@attnames = (); +$stream = ""; +$infile = ""; +$outfile = ""; + +while ( $#ARGV >= 0) +{ + if ($ARGV[0] =~ m/^-i/i) { + shift; + $infile = "$ARGV[0]"; + } + elsif ($ARGV[0] =~ m/^-o/i) { + shift; + $outfile = "$ARGV[0]"; + } + elsif ($ARGV[0] =~ m/^-verbose/i) { + $verbose = 1; + } + elsif ($ARGV[0] =~ m/^-nocomment/i) { + $nocomment = 1; + } + elsif ($ARGV[0] =~ m/^-(\?|h|help)/i) { # Help information + print "Options\n"; + print "-verbose - Make some noise\n"; + exit; + } + elsif ($ARGV[0] =~ m/^-/) { + warn "$0: unknown option $ARGV[0]\n"; + exit 1; + } + else { + die "unknow argument\n"; + } + shift; +} + +if ($infile eq "") { + $infile = "svc.conf"; +} + + +if ($outfile eq "") { + $outfile = "$infile.xml"; +} +print "OUTFILE = $outfile \n"; +open (OUT, "> $outfile") or die "Unable to open $outfile\n"; + +undef $/; +open (FH, "< $infile"); +$_ = <FH>; + +if ($nocomment) { + if (s/^\#(.*)$//mg) { + print "ts = $_\n" if ($verbose != 0); + } +} + +print "------------------------------------------------------------\n" if ($verbose != 0); + +print OUT "<?xml version='1.0'?>\n"; +print OUT "<!-- Converted from $infile by svcconf-convert.pl -->\n"; +acexml_start ("ACE_Svc_Conf", 0); + +while (length ($_) != 0) { + s/^\s*$//mg; + + print "INPUT =\n$_\n" if ($verbose); + PARSE: { + if (s/^\s*\#(.*)//) { + acexml_comment ($1); + print "# $1\n" if ($verbose); + } + if (s/^\s*{//) { + acexml_start ("module", 0); + print "open module\n" if ($verbose); + } + + if (s/^\s*}//) { + acexml_end ("module"); + acexml_end ($stream); + print "close module\n" if ($verbose); + } + + if (s/^\s*stream\s+dynamic\s+(\w+)\s+(\w+)\s*\*\s*(\S+):(\S+)\s*\(\s*\)(\s+"([^"]+)")?(\s+(active|inactive))?//) { + $name = $1; + $type = $2; + $init = $3; + $path = $4; + $param = $6; + $state = $8; + acexml_start ("streamdef"); + if ($status ne "") { + push @attnames, ("status"); + push @attvalues, ("$state"); + } + push @attnames, ("type"); + push @attvalues, ("$type"); + push @attnames, ("id"); + push @attvalues, ("$name"); + acexml_start ("dynamic", 0); + if ($param ne "") { + push @attnames, ("params"); + push @attvalues, ("$param"); + } + push @attnames, ("init"); + push @attvalues, ("$init"); + push @attnames, ("path"); + push @attvalues, ("$path"); + acexml_start ("initializer", 1); + acexml_end ("dynamic"); + $stream = "streamdef"; + print "stream dynamic $name $type * $init:$path \"$param\" $state\n" if ($verbose); + } + + if (s/^\s*stream\s+static\s+(\w+)(\s+("(.+)"))?//) { + $name = $1; + $param = $4; + acexml_start ("streamdef", 0); + if ($param ne "") { + push @attnames, ("params"); + push @attvalues, ("$param"); + } + push @attnames, ("id"); + push @attvalues, ("$name"); + acexml_start ("static", 1); + $stream = "streamdef"; + print "static $name \"$param\"\n" if ($verbose); + } + + if (s/^\s*stream\s+(\w+)//) { + $name = $1; + push @attnames, ("id"); + push @attvalues, ("$name"); + acexml_start ("stream", 0); + $stream = "stream"; + print "stream $name\n" if ($verbose); + } + + if (s/^\s*dynamic\s+(\w+)\s+(\w+)\s*\*\s*(\S+):(\S+)\s*\(\s*\)(\s+"([^"]+)")?(\s+(active|inactive))?//) { + $name = $1; + $type = $2; + $init = $3; + $path = $4; + $param = $6; + $state = $8; + if ($status ne "") { + push @attnames, ("status"); + push @attvalues, ("$state"); + } + push @attnames, ("type"); + push @attvalues, ("$type"); + push @attnames, ("id"); + push @attvalues, ("$name"); + acexml_start ("dynamic", 0); + if ($param ne "") { + push @attnames, ("params"); + push @attvalues, ("$param"); + } + push @attnames, ("init"); + push @attvalues, ("$init"); + push @attnames, ("path"); + push @attvalues, ("$path"); + acexml_start ("initializer", 1); + acexml_end ("dynamic"); + print "dynamic $name $type * $init:$path \"$param\" $state\n" if ($verbose); + } + + if (s/^\s*static\s+(\w+)(\s+("(.+)"))?//) { + $name = $1; + $param = $4; + if ($param ne "") { + push @attnames, ("params"); + push @attvalues, ("$param"); + } + push @attnames, ("id"); + push @attvalues, ("$name"); + acexml_start ("static", 1); + print "static $name \"$param\"\n" if ($verbose); + } + + if ( s/^\s*resume\s+(\w+)//) { + $name = $1; + push @attnames, ("id"); + push @attvalues, ("$name"); + acexml_start ("resume", 1); + print "resume $name\n" if ($verbose); + } + + if ( s/^\s*remove\s+(\w+)//) { + $name = $1; + push @attnames, ("id"); + push @attvalues, ("$name"); + acexml_start ("remove", 1); + print "remove $name\n" if ($verbose); + } + + if ( s/^\s*suspend\s+(\w+)//) { + $name = $1; + push @attnames, ("id"); + push @attvalues, ("$name"); + acexml_start ("suspend", 1); + print "suspend $name\n" if ($verbose); + } + + $nothing = 1; + } +} + +acexml_end ("ACE_Svc_Conf"); |