[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Need library for parsing configuration files

dblack

11/29/2003 12:15:00 AM

1 Answer

Josef 'Jupp' Schugt

11/29/2003 10:03:00 PM

0

Hi!

* David A. Black; 2003-11-29, 12:30 UTC:
> I'm also wondering about just putting
>
> @stars = true
> @host = 'localhost'
>
> in your config file. Are you avoiding that because you use Conf
> later? Or is there a security issue?

The initialization routine that maps Conf to several variables is
only a small part of the program. Well perhaps things become clearer
if I quote the comments that are in that config file (see below). In
addition to what they describe all options but the password can be
provided as commandline arguments, too.

The parser for the command line arguments and for the config file are
derived from a common base class that holds the internal
representation of the external data. The third class derived from
that base class is the effective settings. It takes the information
provided by means of config file and commandline and merges them
thereby taking into account interdependencies of the data - if the
command line option overwrites the user name it is assumed that this
requires a different password. Finally the user is asked to provide
missing informations. In most cases this will be the password,
sometimes it may be user name and password.

When parsing the config file the assignment is mainly used for
clarity. Some options are not necessarily present in the config file
and in those cases the asignment results in 'nil' - that special
value is used lateron to stand for 'insert commandline option or
interacive input here'.

# This file has been automatically generated by popclient.rb
#
# This file is pure Ruby code so that you can easily change options by editing
# them - provided of course you have some basic knowledge of Ruby :-)
#
# When a configuration entry is not present it is either replaced by a
# reasonable default (stars: yes, host: localhost, port: 110 (standard port
# used for POP), apop: false, filter: value of Default_filter, logfile:
# Default_logfile) or the user is prompted to provide the value to be used
# (user, pass). Details:
#
# - Conf['stars'] is a boolean value that controls password feedback.
# - when set to true every character of the password is echoed as a '*'
# - when set to false there is no feedback when a password is entered.
# - Conf['host'] is a string that contains the host to connect to. You can use
# host names as well as IPs.
# - Conf['port'] is an integer that is the port to connect to. It must be in
# the acceptable range of 1 through 65535. Otherwise the value is ignored
# and replaced by the default POP port which is 110.
# - Conf['user'] is a string that contains the user to log in.
# - Conf['pass'] is a string that contains the password to use for login.
# - Conf['apop'] is a boolean value that controls the protocol to be used.
# - when set to true APOP is used
# - when set to false POP version 3 (POP3) is used.
# - Conf['filter'] is the name of the filter file to be used.
# - Conf['charset'] is the character set used by the terminal
# - Conf['statistics'] is a boolean value that controls statistics output
# - when set to true statistics is printed
# - when set to false statistics is suppressed
# - Conf['confirmation'] is a boolean value that controls confirmation before
# deleting messages
# - when set to true confirmation is required
# - when set to false no confirmation is needed
# - Conf['deliver'] is a boolean value that controls wether messages are
# delivered
# - when set to true messages are delivered
# - when set to false messages are kept on server
# - Conf['filerules'] is the name of a file with rules for sorting mails into
# different mailboxes.
# - Conf['logfile'] is the name of the log file to be used. To switch off
# logging set value to '/dev/null'

BTW: The program that uses this config file is available at

http://dwd.da.ru/linux/soft/popclient/...

It works flawlessly for me but I want to do some before providing it
as rubyforge :-)

Josef 'Jupp' Schugt
--
begin SPAM-POLICY.txt.vbs
if msg.size > 100 kB or msg.sender.is_spammer or msg.text.is_spam
discard message
end