/[meteor]/trunk/Meteor/Config.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/Meteor/Config.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 42 by knops.gerd, Sun Feb 3 23:10:24 2008 UTC revision 48 by knops.gerd, Mon Feb 4 22:23:52 2008 UTC
# Line 63  package Meteor::Config; Line 63  package Meteor::Config;
63  'Header template, ~server~, ~servertime~ and ~status~ will be replaced by the appropriate values.  **NOTE**: It is possible to define more than one HeaderTemplate by appending a number at the end, for example *HeaderTemplate42*. Clients can request a specific header to be used by adding the parameter template=<number> to their GET request. If *HeaderTemplate<number>* is not found, the system will use the default HeaderTemplate (no number)',  'Header template, ~server~, ~servertime~ and ~status~ will be replaced by the appropriate values.  **NOTE**: It is possible to define more than one HeaderTemplate by appending a number at the end, for example *HeaderTemplate42*. Clients can request a specific header to be used by adding the parameter template=<number> to their GET request. If *HeaderTemplate<number>* is not found, the system will use the default HeaderTemplate (no number)',
64          HeaderTemplate                  => 'HTTP/1.1 ~status~\r\nServer: ~server~\r\nContent-Type: text/html; charset=utf-8\r\nPragma: no-cache\r\nCache-Control: no-cache, no-store, must-revalidate\r\nExpires: Thu, 1 Jan 1970 00:00:00 GMT\r\n\r\n<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n<meta http-equiv="Cache-Control" content="no-store">\r\n<meta http-equiv="Cache-Control" content="no-cache">\r\n<meta http-equiv="Pragma" content="no-cache">\r\n<meta http-equiv="Expires" content="Thu, 1 Jan 1970 00:00:00 GMT">\r\n<script type="text/javascript">\r\nwindow.onError = null;\r\nvar domainparts = document.domain.split(".");\r\ndocument.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];\r\nparent.Meteor.register(this);\r\n</script>\r\n</head>\r\n<body onload="try { parent.Meteor.reset(this) } catch (e) {}">\r\n',          HeaderTemplate                  => 'HTTP/1.1 ~status~\r\nServer: ~server~\r\nContent-Type: text/html; charset=utf-8\r\nPragma: no-cache\r\nCache-Control: no-cache, no-store, must-revalidate\r\nExpires: Thu, 1 Jan 1970 00:00:00 GMT\r\n\r\n<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n<meta http-equiv="Cache-Control" content="no-store">\r\n<meta http-equiv="Cache-Control" content="no-cache">\r\n<meta http-equiv="Pragma" content="no-cache">\r\n<meta http-equiv="Expires" content="Thu, 1 Jan 1970 00:00:00 GMT">\r\n<script type="text/javascript">\r\nwindow.onError = null;\r\nvar domainparts = document.domain.split(".");\r\ndocument.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];\r\nparent.Meteor.register(this);\r\n</script>\r\n</head>\r\n<body onload="try { parent.Meteor.reset(this) } catch (e) {}">\r\n',
65    
66    'Template for each line in channelinfo',
67    
68            ChannelInfoTemplate             => '~name~ ~messageCount~ ~lastMsgID~\r\n',
69    
70  'Print out this help message',  'Print out this help message',
71          Help                                    => '',          Help                                    => '',
72    
# Line 84  package Meteor::Config; Line 88  package Meteor::Config;
88  'Interval at which PingMessage is sent to all persistent and identified subscriber connections (ie those including id=someuniqueidentifier in their request, and not specifying persist=0). Must be at least 3 if set higher than zero. Set to zero to disable.',  'Interval at which PingMessage is sent to all persistent and identified subscriber connections (ie those including id=someuniqueidentifier in their request, and not specifying persist=0). Must be at least 3 if set higher than zero. Set to zero to disable.',
89          PingInterval                    => 5,          PingInterval                    => 5,
90    
91    'Persistence of a connection. Note: some modes have this hardcoded!',
92    
93            Persist                                 => 0,
94    
95  'Message to be sent to all persistent and identified subscriber connections (see above) every PingInterval seconds',  'Message to be sent to all persistent and identified subscriber connections (see above) every PingInterval seconds',
96          PingMessage                             => '<script>p(-1,"");</script>\r\n',          PingMessage                             => '<script>p(-1,"");</script>\r\n',
97    
# Line 104  package Meteor::Config; Line 112  package Meteor::Config;
112    
113  'The syslog facility to use',  'The syslog facility to use',
114          SyslogFacility                  => 'daemon',          SyslogFacility                  => 'daemon',
115            
116    'IP address for udp server (leave empty for all local addresses)',
117            UDPIP                                   => '',
118            
119    'Port number for udp connections, set to 0 to disable',
120            UDPPort                                 => 0,
121    
122          );          );
123                    
124          our %ConfigFileData=();          our %ConfigFileData=();
125          our %CommandLine=();          our %CommandLine=();
126          our %Defaults=();          our %Defaults=();
127          our %ExtraKeys=();          our %ExtraKeys=();
128            our %Modes=();
129                    
130          for(my $i=0;$i<scalar(@DEFAULTS);$i+=3)          for(my $i=0;$i<scalar(@DEFAULTS);$i+=3)
131          {          {
# Line 137  sub updateConfig { Line 153  sub updateConfig {
153          }          }
154          push(@keys,keys %ExtraKeys);          push(@keys,keys %ExtraKeys);
155                    
156          foreach my $key (@keys)          
157          {                        foreach my $mode ('',keys %Modes)
158                  if(exists($CommandLine{$key}))          {
159                  {                  foreach my $baseKey (@keys)
                         print STDERR "CmdLine" if($debug);  
                         $::CONF{$key}=$CommandLine{$key};  
                 }  
                 elsif(exists($ConfigFileData{$key}))  
                 {  
                         print STDERR "CnfFile" if($debug);  
                         $::CONF{$key}=$ConfigFileData{$key};  
                 }  
                 elsif(exists($Defaults{$key}))  
160                  {                  {
161                          print STDERR "Default" if($debug);                          my $foundValue=0;
162                          $::CONF{$key}=$Defaults{$key};                          my $key=$baseKey.$mode;
163                  }                          
164                                            if(exists($CommandLine{$key}))
                 print STDERR "\t$key\t$::CONF{$key}\n" if($debug);  
                   
                 # Take care of escapes  
                 $::CONF{$key}=~s/\\(.)/  
                         if($1 eq 'r')  
                         {  
                                 "\r";  
                         }  
                         elsif($1 eq 'n')  
                         {  
                                 "\n";  
                         }  
                         elsif($1 eq 's')  
165                          {                          {
166                                  ' ';                                  print STDERR "CmdLine" if($debug);
167                                    $::CONF{$key}=$CommandLine{$key};
168                                    $foundValue=1;
169                          }                          }
170                          elsif($1 eq 't')                          elsif(exists($ConfigFileData{$key}))
171                          {                          {
172                                  "\t";                                  print STDERR "CnfFile" if($debug);
173                                    $::CONF{$key}=$ConfigFileData{$key};
174                                    $foundValue=1;
175                          }                          }
176                          else                          elsif(exists($Defaults{$key}))
177                          {                          {
178                                  $1;                                  print STDERR "Default" if($debug);
179                                    $::CONF{$key}=$Defaults{$key};
180                                    $foundValue=1;
181                          }                          }
182                  /gex;                          
183                            next unless($foundValue);
184                            
185                            print STDERR "\t$key\t$::CONF{$key}\n" if($debug);
186                            
187                            # Take care of escapes
188                            $::CONF{$key}=~s/\\(.)/
189                                    if($1 eq 'r')
190                                    {
191                                            "\r";
192                                    }
193                                    elsif($1 eq 'n')
194                                    {
195                                            "\n";
196                                    }
197                                    elsif($1 eq 's')
198                                    {
199                                            ' ';
200                                    }
201                                    elsif($1 eq 't')
202                                    {
203                                            "\t";
204                                    }
205                                    else
206                                    {
207                                            $1;
208                                    }
209                            /gex;
210                    }
211          }          }
           
212          print STDERR '-'x79 ."\n" if($debug);          print STDERR '-'x79 ."\n" if($debug);
213  }  }
214    
# Line 218  sub setCommandLineParameters { Line 245  sub setCommandLineParameters {
245                                    
246                  $k='Debug' if($k eq 'd');                  $k='Debug' if($k eq 'd');
247                                    
248                    my $mode='';
249                    
250                    if($k=~s/(\..+)$//)
251                    {
252                            $mode=$1;
253                            $Modes{$mode}=1;
254                    }
255                    
256                  my $key=undef;                  my $key=undef;
257                  my $kl=length($k);                  my $kl=length($k);
258                  my $kOrig=$k;                  my $kOrig=$k;
# Line 262  sub setCommandLineParameters { Line 297  sub setCommandLineParameters {
297                                    
298                  #print "$kOrig: $key\n";                  #print "$kOrig: $key\n";
299                                    
300                  $CommandLine{$key}=1;                  $CommandLine{"$key$mode"}=1;
301                                    
302                  if($cnt>1 && $_[0]!~/^\-(?!\-)/)                  if($cnt>1 && $_[0]!~/^\-(?!\-)/)
303                  {                  {
304                          my $param=shift;                          my $param=shift;
305                          $param=~s/^\-\-/\-/;                          $param=~s/^\-\-/\-/;
306                          $CommandLine{$key}=$param;                          $CommandLine{"$key$mode"}=$param;
307                  }                  }
308          }          }
309                    
# Line 285  sub readConfig { Line 320  sub readConfig {
320          my $path=$class->valueForKey('ConfigFileLocation');          my $path=$class->valueForKey('ConfigFileLocation');
321          return unless(defined($path) && -f $path);          return unless(defined($path) && -f $path);
322                    
323            my $mode='';
324            
325          open(CONFIG,"$path") or &usage("Config file '$path' for read: $!\n");          open(CONFIG,"$path") or &usage("Config file '$path' for read: $!\n");
326          while(<CONFIG>)          while(<CONFIG>)
327          {          {
# Line 293  sub readConfig { Line 330  sub readConfig {
330                                    
331                  s/[\r\n]*$//;                  s/[\r\n]*$//;
332                                    
333                    if(/^\s*\[\s*([^\]\s]+)\s*\]\s*$/)
334                    {
335                            $Modes{".$1"}=1;
336                            next;
337                    }
338                    
339                  unless(/^(\S+)\s*(.*)/)                  unless(/^(\S+)\s*(.*)/)
340                  {                  {
341                          &usage("Invalid configuration file parameter line '$_'");                          &usage("Invalid configuration file parameter line '$_'");
# Line 310  sub readConfig { Line 353  sub readConfig {
353                  {                  {
354                          unless(exists($Defaults{$key}))                          unless(exists($Defaults{$key}))
355                          {                          {
356                                  &usage("Unknown configuration file parameter name '$key'");                                  &usage("Unknown configuration file parameter name '$key$mode'");
357                          }                          }
358                          if($key eq 'ConfigFileLocation')                          if($key eq 'ConfigFileLocation')
359                          {                          {
# Line 320  sub readConfig { Line 363  sub readConfig {
363                                    
364                  $val=~s/^--/-/;                  $val=~s/^--/-/;
365                                    
366                  $ConfigFileData{$key}=$val;                  $ConfigFileData{"$key$mode"}=$val;
367          }          }
368          close(CONFIG);          close(CONFIG);
369  }  }
# Line 340  EOT Line 383  EOT
383                    
384                  print STDERR <<"EOT";                  print STDERR <<"EOT";
385    
386  Meteor server v1.0 (release date: 1 Dec 2006)  Meteor server v$::VERSION (release date: $::RELEASE_DATE)
387  Licensed under the terms of the GNU General Public Licence (2.0)  Licensed under the terms of the GNU General Public Licence (2.0)
388    
389  Usage:  Usage:

Legend:
Removed from v.42  
changed lines
  Added in v.48

  ViewVC Help
Powered by ViewVC 1.1.26