samba是个开源的文件服务器软件,可以在多个平台上运行.如果你使用过,那么一定设置过它的配置文件.
如果你想写一个类似读这样的配置文件的代码,那么下面的从samba提取出来的代码讲对你很有用.它采用 【程序编程相关:MFC程序带参数运行】 【推荐阅读:由2个和尚打水想到的---如何学习VB编】 回调的机制,获取配置信息. 【扩展信息:如何量化用户体验】 smb.conf 如下 # this is the main samba configuration file. you should read the # smb.conf(5) manual page in order to understand the options listed # here. samba has a huge number of configurable options (perhaps too # many!) most of which are not shown in this example # # any line which starts with a ; (semi-colon) or a # (hash) # is a comment and is ignored. in this example we will use a # # for commentry and a ; for parts of the config file that you # may wish to enable # # note: whenever you modify this file you should run the command "testparm" # to check that you have not made any basic syntactic errors. # #======================= global settings ===================================== [global]# workgroup = nt-domain-name or workgroup-name
workgroup = gdcattsoft# server string is the equivalent of the nt description field
server string = samba server# this option is important for security. it allows you to restrict
# connections to machines which are on your local network. the # following example restricts access to two c class networks and # the "loopback" interface. for more examples of the syntax see # the smb.conf man page ; hosts allow = 192.168.1. 192.168.2. 127.# if you want to automatically load your printer list rather
# than setting them up individually then you´ll need this printcap name = /etc/printcap load printers = yes# it should not be necessary to spell out the print system type unless
# yours is non-standard. currently supported print systems include: # bsd, sysv, plp, lprng, aix, hpux, qnx, cups printing = cups# uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used ; guest account = pcguest# this tells samba to use a separate log file for each machine
# that connects log file = /var/log/samba/%m.log# put a capping on the size of the log files (in kb).
max log size = 0# security mode. most people will want user level security. see
# security_level.txt for details.# use password server option only with security = server
# the argument list may include: # password server = my_pdc_name [my_bdc_name] [my_next_bdc_name] # or to auto-locate the domain controller/s # password server = * ; password server = <nt-server-name># password level allows matching of _n_ characters of the password for
# all combinations of upper and lower case. ; password level = 8 ; username level = 8# you may wish to use password encryption. please read
# encryption.txt, win95.txt and winnt.txt in the samba documentation. # do not enable this option unless you have read those documents encrypt passwords = yes smb passwd file = /etc/samba/smbpasswd# the following is needed to keep smbclient from spouting spurious errors
# when samba is built with support for ssl. ; ssl ca certfile = /usr/share/ssl/certs/ca-bundle.crt ..... /* -------------------------------------------------------------------------- ** * * module name: params * * -------------------------------------------------------------------------- ** * * this module performs lexical analysis and initial parsing of a * windows-like parameter file. it recognizes and handles four token * types: section-name, parameter-name, parameter-value, and * end-of-file. comments and line continuation are handled * internally. * * the entry point to the module is function pm_process(). this * function opens the source file, calls the parse() function to parse * the input, and then closes the file when either the eof is reached * or a fatal error is encountered. * * a sample parameter file might look like this: * * [section one] * parameter one = value string * parameter two = another value * [section two] * new parameter = some value or t´other * * the parameter file is divided into sections by section headers: * section names enclosed in square brackets (eg. [section one]). * each section contains parameter lines, each of which consist of a * parameter name and value delimited by an equal sign. roughly, the * syntax is: * * <file> :== { <section> } eof * * <section> :== <section header> { <parameter line> } * * <section header> :== ´[´ name ´]´ * * <parameter line> :== name ´=´ value ´\n´ * * blank lines and comment lines are ignored. comment lines are lines * beginning with either a semicolon (´;´) or a pound sign (´#´). * ... 下一页