diff options
author | Andrew Tridgell <tridge@samba.org> | 1997-11-22 07:09:12 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1997-11-22 07:09:12 +0000 |
commit | 51f20adc6b964bad6e5bfbf69da68e1e6f45b13e (patch) | |
tree | 9b46032c223e234f7ee94ba68385472fbfe0c4e6 /source3/param | |
parent | 5a1c907d3cb6446b5158028582bf9e8a70ff0b02 (diff) | |
download | samba-51f20adc6b964bad6e5bfbf69da68e1e6f45b13e.tar.gz samba-51f20adc6b964bad6e5bfbf69da68e1e6f45b13e.tar.bz2 samba-51f20adc6b964bad6e5bfbf69da68e1e6f45b13e.zip |
added true enumerated types in loadparm.c. Now we don't need all those
"interpret_security" and similar functions. This also means that
testparm produces string values for these enumerated types rather than
an integer. This was done to make the web interface much cleaner.
While I was doing this I found a couple of very nasty bugs in the
parm_table code. Someone had added a handle_character_set() function
that treated the char** pointer for a P_STRING as an integer! This
would have caused memory corruption for anyone using the "character
set" option. The loadparm code is delicate - please be careful about
using it's more esoteric features!
I've also removed the "coding system" global and made it a
P_STRING. The integer value was never used anywhere in Samba.
(This used to be commit bac6b0daa288e879330e3d585582122bb93a1ffb)
Diffstat (limited to 'source3/param')
-rw-r--r-- | source3/param/loadparm.c | 707 |
1 files changed, 339 insertions, 368 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 43f0fe9208..8858455f6a 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -90,7 +90,7 @@ extern pstring myname; typedef enum { P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL, - P_STRING,P_USTRING,P_GSTRING,P_UGSTRING + P_STRING,P_USTRING,P_GSTRING,P_UGSTRING,P_ENUM } parm_type; typedef enum @@ -102,7 +102,6 @@ int keepalive=0; extern BOOL use_getwd_cache; extern int extra_time_offset; -extern int coding_system; /* * This structure describes global (ie., server-wide) parameters. @@ -139,6 +138,7 @@ typedef struct char *szLogonHome; char *szSmbrun; char *szWINSserver; + char *szCodingSystem; char *szInterfaces; char *szRemoteAnnounce; char *szRemoteBrowseSync; @@ -386,222 +386,241 @@ static int default_server_announce; static BOOL handle_valid_chars(char *pszParmValue, char **ptr); static BOOL handle_include(char *pszParmValue, char **ptr); static BOOL handle_copy(char *pszParmValue, char **ptr); -static BOOL handle_protocol(char *pszParmValue,int *val); -static BOOL handle_security(char *pszParmValue,int *val); -static BOOL handle_case(char *pszParmValue,int *val); -static BOOL handle_printing(char *pszParmValue,int *val); -static BOOL handle_character_set(char *pszParmValue,int *val); -static BOOL handle_announce_as(char *pszParmValue, int *val); -static BOOL handle_coding_system(char *pszParmValue,int *val); +static BOOL handle_character_set(char *pszParmValue,char **ptr); +static BOOL handle_coding_system(char *pszParmValue,char **ptr); static void set_default_server_announce_type(void); -struct parm_struct +struct enum_list { + int value; + char *name; +}; + +static struct enum_list enum_protocol[] = {{PROTOCOL_NT1, "NT1"}, {PROTOCOL_LANMAN2, "LANMAN2"}, + {PROTOCOL_LANMAN1, "LANMAN1"}, {PROTOCOL_CORE,"CORE"}, + {PROTOCOL_COREPLUS, "COREPLUS"}, + {PROTOCOL_COREPLUS, "CORE+"}, {-1, NULL}}; + +static struct enum_list enum_security[] = {{SEC_SHARE, "SHARE"}, {SEC_USER, "USER"}, + {SEC_SERVER, "SERVER"}, {-1, NULL}}; + +static struct enum_list enum_printing[] = {{PRINT_SYSV, "sysv"}, {PRINT_AIX, "aix"}, + {PRINT_HPUX, "hpux"}, {PRINT_BSD, "bsd"}, + {PRINT_QNX, "qnx"}, {PRINT_PLP, "plp"}, + {PRINT_LPRNG, "lprng"}, {-1, NULL}}; + +static struct enum_list enum_announce_as[] = {{ANNOUNCE_AS_NT, "NT"}, {ANNOUNCE_AS_WIN95, "win95"}, + {ANNOUNCE_AS_WFW, "WfW"}, {-1, NULL}}; + +static struct enum_list enum_case[] = {{CASE_LOWER, "lower"}, {CASE_UPPER, "upper"}, {-1, NULL}}; + +static struct parm_struct { - char *label; - parm_type type; - parm_class class; - void *ptr; - BOOL (*special)(); + char *label; + parm_type type; + parm_class class; + void *ptr; + BOOL (*special)(); + struct enum_list *enum_list; } parm_table[] = { - {"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL}, - {"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL}, - {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL}, - {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL}, - {"protocol", P_INTEGER, P_GLOBAL, &Globals.maxprotocol,handle_protocol}, - {"security", P_INTEGER, P_GLOBAL, &Globals.security,handle_security}, - {"printing", P_INTEGER, P_GLOBAL, &Globals.printing,handle_printing}, - {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL}, - {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL}, - {"announce as", P_INTEGER, P_GLOBAL, &Globals.announce_as, handle_announce_as}, - {"encrypt passwords",P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL}, - {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL}, - {"read prediction", P_BOOL, P_GLOBAL, &Globals.bReadPrediction, NULL}, - {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL}, - {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL}, - {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL}, - {"use rhosts", P_BOOL, P_GLOBAL, &Globals.bUseRhosts, NULL}, - {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL}, - {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL}, - {"strip dot", P_BOOL, P_GLOBAL, &Globals.bStripDot, NULL}, - {"interfaces", P_STRING, P_GLOBAL, &Globals.szInterfaces, NULL}, - {"bind interfaces only", P_BOOL,P_GLOBAL, &Globals.bBindInterfacesOnly,NULL}, - {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL}, - {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL}, - {"netbios name", P_UGSTRING,P_GLOBAL, myname, NULL}, - {"netbios aliases", P_STRING, P_GLOBAL, &Globals.szNetbiosAliases, NULL}, - {"smbrun", P_STRING, P_GLOBAL, &Globals.szSmbrun, NULL}, - {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL}, - {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL}, - {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL}, - {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL}, - {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL}, - {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL}, - {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL}, - {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL}, - {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL}, - {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL}, - {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL}, - {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL}, - {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL}, - {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL}, - {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL}, - {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL}, - {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL}, - {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL}, - {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL}, - {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL}, - {"valid chars", P_STRING, P_GLOBAL, &Globals.szValidChars, handle_valid_chars}, - {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL}, - {"domain sid", P_USTRING, P_GLOBAL, &Globals.szDomainSID, NULL}, - {"domain other sids",P_STRING, P_GLOBAL, &Globals.szDomainOtherSIDs, NULL}, - {"domain groups", P_STRING, P_GLOBAL, &Globals.szDomainGroups, NULL}, - {"domain controller",P_BOOL , P_GLOBAL, &Globals.bDomainController,NULL}, - {"domain admin users",P_STRING, P_GLOBAL, &Globals.szDomainAdminUsers, NULL}, - {"domain guest users",P_STRING, P_GLOBAL, &Globals.szDomainGuestUsers, NULL}, - {"domain hosts allow",P_STRING, P_GLOBAL, &Globals.szDomainHostsallow, NULL}, - {"domain allow hosts",P_STRING, P_GLOBAL, &Globals.szDomainHostsallow, NULL}, - {"domain hosts deny", P_STRING, P_GLOBAL, &Globals.szDomainHostsdeny, NULL}, - {"domain deny hosts", P_STRING, P_GLOBAL, &Globals.szDomainHostsdeny, NULL}, - {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL}, - {"character set", P_STRING, P_GLOBAL, &Globals.szCharacterSet, handle_character_set}, - {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL}, - {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL}, - {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL}, - {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL}, - {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL}, - {"remote browse sync", P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync, NULL}, - {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL}, - {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL}, - {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL}, - {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL}, - {"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL}, - {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL}, - {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL}, - {"max packet", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL}, - {"packet size", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL}, - {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL}, - {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL}, - {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL}, - {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL}, - {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL}, - {"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL}, - {"shared mem size", P_INTEGER, P_GLOBAL, &Globals.shmem_size, NULL}, - {"coding system", P_INTEGER, P_GLOBAL, &coding_system, handle_coding_system}, - {"client code page", P_INTEGER, P_GLOBAL, &Globals.client_code_page, NULL}, - {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL}, - {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL}, - {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL}, - {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL}, - {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL}, - {"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, NULL}, - {"preferred master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL}, - {"prefered master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL}, - {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL}, - {"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL}, - {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL}, - {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL}, - {"unix realname", P_BOOL, P_GLOBAL, &Globals.bUnixRealname, NULL}, - {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL}, - {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL}, - {"printer driver file", P_STRING, P_GLOBAL, &Globals.szDriverFile, NULL}, - {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL}, - {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL}, - {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy}, - {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include}, - {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL}, - {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL}, - {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL}, - {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL}, - {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL}, - {"alternate permissions",P_BOOL,P_LOCAL, &sDefault.bAlternatePerm, NULL}, - {"revalidate", P_BOOL, P_LOCAL, &sDefault.bRevalidate, NULL}, - {"default case", P_INTEGER, P_LOCAL, &sDefault.iDefaultCase, handle_case}, - {"case sensitive", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL}, - {"casesignames", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL}, - {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL}, - {"short preserve case",P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve,NULL}, - {"mangle case", P_BOOL, P_LOCAL, &sDefault.bCaseMangle, NULL}, - {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL}, - {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL}, - {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL}, - {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL}, - {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL}, - {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL}, - {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL}, - {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL}, - {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL}, - {"guest account", P_STRING, P_LOCAL, &sDefault.szGuestaccount, NULL}, - {"invalid users", P_STRING, P_LOCAL, &sDefault.szInvalidUsers, NULL}, - {"valid users", P_STRING, P_LOCAL, &sDefault.szValidUsers, NULL}, - {"admin users", P_STRING, P_LOCAL, &sDefault.szAdminUsers, NULL}, - {"read list", P_STRING, P_LOCAL, &sDefault.readlist, NULL}, - {"write list", P_STRING, P_LOCAL, &sDefault.writelist, NULL}, - {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL}, - {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL}, - {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL}, - {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL}, - {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL}, - {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL}, - {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL}, - {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL}, - {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL}, - {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL}, - {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL}, - {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL}, - {"force create mode",P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL}, - {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL}, - {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL}, - {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL}, - {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL}, - {"status", P_BOOL, P_LOCAL, &sDefault.status, NULL}, - {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL}, - {"delete veto files",P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL}, - {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL}, - {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL}, - {"veto oplock files",P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles,NULL}, - {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL}, - {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL}, - {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL}, - {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL}, - {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL}, - {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL}, - {"postscript", P_BOOL, P_LOCAL, &sDefault.bPostscript, NULL}, - {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL}, - {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL}, - {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL}, - {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL}, - {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL}, - {"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL}, - {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL}, - {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL}, - {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL}, - {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL}, - {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL}, - {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL}, - {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL}, - {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL}, - {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL}, - {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL}, - {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL}, - {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand,NULL}, - {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL}, - {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL}, - {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL}, - {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL}, - {"hosts allow", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL}, - {"allow hosts", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL}, - {"hosts deny", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL}, - {"deny hosts", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL}, - {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL}, - {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL}, - {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL}, - {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL}, - {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL}, - {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL}, - - {NULL, P_BOOL, P_NONE, NULL, NULL} + {"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL, NULL}, + {"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL, NULL}, + {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL}, + {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL}, + {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol}, + {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security}, + {"printing", P_ENUM, P_GLOBAL, &Globals.printing, NULL, enum_printing}, + {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL}, + {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL}, + {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as}, + {"encrypt passwords",P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL}, + {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL}, + {"read prediction", P_BOOL, P_GLOBAL, &Globals.bReadPrediction, NULL, NULL}, + {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL}, + {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL}, + {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL}, + {"use rhosts", P_BOOL, P_GLOBAL, &Globals.bUseRhosts, NULL, NULL}, + {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL}, + {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL}, + {"strip dot", P_BOOL, P_GLOBAL, &Globals.bStripDot, NULL, NULL}, + {"interfaces", P_STRING, P_GLOBAL, &Globals.szInterfaces, NULL, NULL}, + {"bind interfaces only", P_BOOL,P_GLOBAL, &Globals.bBindInterfacesOnly,NULL, NULL}, + {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL}, + {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL}, + {"netbios name", P_UGSTRING,P_GLOBAL, myname, NULL, NULL}, + {"netbios aliases", P_STRING, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL}, + {"smbrun", P_STRING, P_GLOBAL, &Globals.szSmbrun, NULL, NULL}, + {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL}, + {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL}, + {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL}, + {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL, NULL}, + {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL}, + {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL}, + {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL}, + {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL}, + {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL}, + {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL}, + {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL}, + {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL}, + {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL}, + {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL}, + {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL}, + {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL}, + {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL, NULL}, + {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL, NULL}, + {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL, NULL}, + {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL}, + {"valid chars", P_STRING, P_GLOBAL, &Globals.szValidChars, handle_valid_chars, NULL}, + {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL, NULL}, + {"domain sid", P_USTRING, P_GLOBAL, &Globals.szDomainSID, NULL, NULL}, + {"domain other sids",P_STRING, P_GLOBAL, &Globals.szDomainOtherSIDs, NULL, NULL}, + {"domain groups", P_STRING, P_GLOBAL, &Globals.szDomainGroups, NULL, NULL}, + {"domain controller",P_BOOL , P_GLOBAL, &Globals.bDomainController,NULL, NULL}, + {"domain admin users",P_STRING, P_GLOBAL, &Globals.szDomainAdminUsers, NULL, NULL}, + {"domain guest users",P_STRING, P_GLOBAL, &Globals.szDomainGuestUsers, NULL, NULL}, + {"domain hosts allow",P_STRING, P_GLOBAL, &Globals.szDomainHostsallow, NULL, NULL}, + {"domain allow hosts",P_STRING, P_GLOBAL, &Globals.szDomainHostsallow, NULL, NULL}, + {"domain hosts deny", P_STRING, P_GLOBAL, &Globals.szDomainHostsdeny, NULL, NULL}, + {"domain deny hosts", P_STRING, P_GLOBAL, &Globals.szDomainHostsdeny, NULL, NULL}, + {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL, NULL}, + {"character set", P_STRING, P_GLOBAL, &Globals.szCharacterSet, handle_character_set, NULL}, + {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL}, + {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL}, + {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL, NULL}, + {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL, NULL}, + {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL, NULL}, + {"remote browse sync",P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync,NULL, NULL}, + {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL}, + {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL}, + {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL}, + {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL}, + {"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL, NULL}, + {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL}, + {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL}, + {"max packet", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL}, + {"packet size", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL}, + {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL}, + {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL, NULL}, + {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL}, + {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL}, + {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL}, + {"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL, NULL}, + {"shared mem size", P_INTEGER, P_GLOBAL, &Globals.shmem_size, NULL, NULL}, + {"coding system", P_STRING, P_GLOBAL, &Globals.szCodingSystem, handle_coding_system, NULL}, + {"client code page", P_INTEGER, P_GLOBAL, &Globals.client_code_page, NULL, NULL}, + {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL}, + {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL}, + {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL}, + {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL}, + {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL}, + {"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, NULL, NULL}, + {"preferred master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL, NULL}, + {"prefered master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL, NULL}, + {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL}, + {"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL, NULL}, + {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL, NULL}, + {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL}, + {"unix realname", P_BOOL, P_GLOBAL, &Globals.bUnixRealname, NULL, NULL}, + {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL}, + {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL}, + {"printer driver file", P_STRING, P_GLOBAL, &Globals.szDriverFile, NULL, NULL}, + {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL}, + {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL}, + {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL}, + {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL}, + {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL}, + {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL}, + {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL, NULL}, + {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL, NULL}, + {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL}, + {"alternate permissions",P_BOOL,P_LOCAL, &sDefault.bAlternatePerm, NULL, NULL}, + {"revalidate", P_BOOL, P_LOCAL, &sDefault.bRevalidate, NULL, NULL}, + {"default case", P_ENUM, P_LOCAL, &sDefault.iDefaultCase, NULL, enum_case}, + {"case sensitive", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL}, + {"casesignames", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL}, + {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL, NULL}, + {"short preserve case",P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve,NULL, NULL}, + {"mangle case", P_BOOL, P_LOCAL, &sDefault.bCaseMangle, NULL, NULL}, + {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL, NULL}, + {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL}, + {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL}, + {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL}, + {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL}, + {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL}, + {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL}, + {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL}, + {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL}, + {"guest account", P_STRING, P_LOCAL, &sDefault.szGuestaccount, NULL, NULL}, + {"invalid users", P_STRING, P_LOCAL, &sDefault.szInvalidUsers, NULL, NULL}, + {"valid users", P_STRING, P_LOCAL, &sDefault.szValidUsers, NULL, NULL}, + {"admin users", P_STRING, P_LOCAL, &sDefault.szAdminUsers, NULL, NULL}, + {"read list", P_STRING, P_LOCAL, &sDefault.readlist, NULL, NULL}, + {"write list", P_STRING, P_LOCAL, &sDefault.writelist, NULL, NULL}, + {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL}, + {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL, NULL}, + {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL}, + {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL}, + {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL}, + {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL}, + {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL}, + {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL}, + {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL}, + {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL}, + {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL}, + {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL}, + {"force create mode",P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL}, + {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL}, + {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL}, + {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL}, + {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL}, + {"status", P_BOOL, P_LOCAL, &sDefault.status, NULL, NULL}, + {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL, NULL}, + {"delete veto files",P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL, NULL}, + {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL, NULL}, + {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL, NULL}, + {"veto oplock files",P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles,NULL, NULL}, + {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL}, + {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL}, + {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL}, + {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL}, + {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL}, + {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL}, + {"postscript", P_BOOL, P_LOCAL, &sDefault.bPostscript, NULL, NULL}, + {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL}, + {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL}, + {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL}, + {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL}, + {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL}, + {"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL, NULL}, + {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL}, + {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL, NULL}, + {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL}, + {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL, NULL}, + {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL}, + {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL}, + {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL}, + {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL, NULL}, + {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL, NULL}, + {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL, NULL}, + {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL, NULL}, + {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand,NULL, NULL}, + {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL}, + {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL}, + {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL, NULL}, + {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL, NULL}, + {"hosts allow", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL, NULL}, + {"allow hosts", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL, NULL}, + {"hosts deny", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL}, + {"deny hosts", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL}, + {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL}, + {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL}, + {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL}, + {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL}, + {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL}, + {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL}, + + {NULL, P_BOOL, P_NONE, NULL, NULL, NULL} }; @@ -689,7 +708,7 @@ static void init_globals(void) Globals.bNISHomeMap = False; string_set(&Globals.szNISHomeMapName, "auto.home"); #endif - coding_system = interpret_coding_system (KANJI, SJIS_CODE); + interpret_coding_system(KANJI); Globals.client_code_page = DEFAULT_CLIENT_CODE_PAGE; Globals.bTimeServer = False; Globals.bBindInterfacesOnly = False; @@ -714,17 +733,6 @@ static void init_globals(void) Globals.bWINSsupport = False; Globals.bWINSproxy = False; -/* this parameter is currently set to the default functionality - in samba. given that w95 and NT is starting to use DNS for - server resolution, i expect that at some point it would be - sensible to default this to False. - - this parameter is added because nmbd is a single process, and - gethostbyname is a blocking call, which can take out nmbd for - several seconds while a dns lookup is performed. - - */ - Globals.bDNSproxy = True; } @@ -1341,6 +1349,7 @@ static void copy_service(service *pserviceDest, break; case P_INTEGER: + case P_ENUM: case P_OCTAL: *(int *)dest_ptr = *(int *)src_ptr; break; @@ -1486,90 +1495,25 @@ BOOL lp_file_list_changed(void) /*************************************************************************** handle the interpretation of the coding system parameter *************************************************************************/ -static BOOL handle_coding_system(char *pszParmValue,int *val) +static BOOL handle_coding_system(char *pszParmValue,char **ptr) { - *val = interpret_coding_system(pszParmValue,*val); - return(True); + string_set(ptr,pszParmValue); + interpret_coding_system(pszParmValue); + return(True); } /*************************************************************************** handle the interpretation of the character set system parameter ***************************************************************************/ -static BOOL handle_character_set(char *pszParmValue,int *val) +static BOOL handle_character_set(char *pszParmValue,char **ptr) { - string_set(&Globals.szCharacterSet,pszParmValue); - *val = interpret_character_set(pszParmValue,*val); - return(True); + string_set(ptr,pszParmValue); + interpret_character_set(pszParmValue); + return(True); } /*************************************************************************** -handle the interpretation of the protocol parameter -***************************************************************************/ -static BOOL handle_protocol(char *pszParmValue,int *val) -{ - *val = interpret_protocol(pszParmValue,*val); - return(True); -} - -/*************************************************************************** -handle the interpretation of the security parameter -***************************************************************************/ -static BOOL handle_security(char *pszParmValue,int *val) -{ - *val = interpret_security(pszParmValue,*val); - return(True); -} - -/*************************************************************************** -handle the interpretation of the default case -***************************************************************************/ -static BOOL handle_case(char *pszParmValue,int *val) -{ - if (strnequal(pszParmValue,"LOWER", 5)) - *val = CASE_LOWER; - else if (strnequal(pszParmValue,"UPPER", 5)) - *val = CASE_UPPER; - return(True); -} - -/*************************************************************************** -handle the interpretation of the printing system -***************************************************************************/ -static BOOL handle_printing(char *pszParmValue,int *val) -{ - if (strnequal(pszParmValue,"sysv", 4)) - *val = PRINT_SYSV; - else if (strnequal(pszParmValue,"aix", 3)) - *val = PRINT_AIX; - else if (strnequal(pszParmValue,"hpux", 4)) - *val = PRINT_HPUX; - else if (strnequal(pszParmValue,"bsd", 3)) - *val = PRINT_BSD; - else if (strnequal(pszParmValue,"qnx",3)) - *val = PRINT_QNX; - else if (strnequal(pszParmValue,"plp", 3)) - *val = PRINT_PLP; - else if (strnequal(pszParmValue,"lprng", 5)) - *val = PRINT_LPRNG; - return(True); -} - -/*************************************************************************** -handle the announce as parameter -***************************************************************************/ -static BOOL handle_announce_as(char *pszParmValue,int *val) -{ - if (strnequal(pszParmValue,"NT", 2)) - *val = ANNOUNCE_AS_NT; - else if (strnequal(pszParmValue,"win95", 5)) - *val = ANNOUNCE_AS_WIN95; - else if (strnequal(pszParmValue,"WfW", 3)) - *val = ANNOUNCE_AS_WFW; - return True; -} - -/*************************************************************************** handle the valid chars lines ***************************************************************************/ static BOOL handle_valid_chars(char *pszParmValue,char **ptr) @@ -1676,7 +1620,7 @@ then assume we are in the globals ***************************************************************************/ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue) { - int parmnum; + int parmnum, i; void *parm_ptr=NULL; /* where we are going to store the result */ void *def_ptr=NULL; @@ -1702,7 +1646,6 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue) } if (snum >= 0) { - int i; if (!iSERVICE(snum).copymap) init_copymap(pSERVICE(snum)); @@ -1760,6 +1703,15 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue) strcpy((char *)parm_ptr,pszParmValue); strupper((char *)parm_ptr); break; + + case P_ENUM: + for (i=0;parm_table[parmnum].enum_list[i].name;i++) { + if (strequal(pszParmValue, parm_table[parmnum].enum_list[i].name)) { + *(int *)parm_ptr = parm_table[parmnum].enum_list[i].value; + break; + } + } + break; } return(True); @@ -1781,86 +1733,104 @@ static BOOL do_parameter(char *pszParmName, char *pszParmValue) /*************************************************************************** print a parameter of the specified type ***************************************************************************/ -static void print_parameter(parm_type type,void *ptr, FILE *f) -{ - switch (type) - { - case P_BOOL: - fprintf(f,"%s",BOOLSTR(*(BOOL *)ptr)); - break; +static void print_parameter(struct parm_struct *p,void *ptr, FILE *f) +{ + int i; + switch (p->type) { + case P_ENUM: + for (i=0;p->enum_list[i].name;i++) { + if (*(int *)ptr == p->enum_list[i].value) { + fprintf(f,"%s",p->enum_list[i].name); + break; + } + } + break; + + case P_BOOL: + fprintf(f,"%s",BOOLSTR(*(BOOL *)ptr)); + break; - case P_BOOLREV: - fprintf(f,"%s",BOOLSTR(! *(BOOL *)ptr)); - break; + case P_BOOLREV: + fprintf(f,"%s",BOOLSTR(! *(BOOL *)ptr)); + break; - case P_INTEGER: - fprintf(f,"%d",*(int *)ptr); - break; + case P_INTEGER: + fprintf(f,"%d",*(int *)ptr); + break; - case P_CHAR: - fprintf(f,"%c",*(char *)ptr); - break; + case P_CHAR: + fprintf(f,"%c",*(char *)ptr); + break; - case P_OCTAL: - fprintf(f,"0%o",*(int *)ptr); - break; + case P_OCTAL: + fprintf(f,"0%o",*(int *)ptr); + break; - case P_GSTRING: - case P_UGSTRING: - if ((char *)ptr) - fprintf(f,"%s",(char *)ptr); - break; - - case P_STRING: - case P_USTRING: - if (*(char **)ptr) - fprintf(f,"%s",*(char **)ptr); - break; - } + case P_GSTRING: + case P_UGSTRING: + if ((char *)ptr) + fprintf(f,"%s",(char *)ptr); + break; + + case P_STRING: + case P_USTRING: + if (*(char **)ptr) + fprintf(f,"%s",*(char **)ptr); + break; + } } /*************************************************************************** print a parameter of the specified type ***************************************************************************/ -static void parameter_string(parm_type type,void *ptr,char *s) +static void parameter_string(struct parm_struct *p,void *ptr,char *s) { + int i; s[0] = 0; - switch (type) - { - case P_BOOL: - sprintf(s, "%s",BOOLSTR(*(BOOL *)ptr)); - break; - - case P_BOOLREV: - sprintf(s, "%s",BOOLSTR(! *(BOOL *)ptr)); - break; - - case P_INTEGER: - sprintf(s, "%d",*(int *)ptr); - break; - - case P_CHAR: - sprintf(s, "%c",*(char *)ptr); - break; - - case P_OCTAL: - sprintf(s, "0%o",*(int *)ptr); - break; - - case P_GSTRING: - case P_UGSTRING: - if ((char *)ptr) - sprintf(s, "%s",(char *)ptr); - break; - - case P_STRING: - case P_USTRING: - if (*(char **)ptr) - sprintf(s, "%s",*(char **)ptr); - break; + switch (p->type) { + case P_ENUM: + for (i=0;p->enum_list[i].name;i++) { + if (*(int *)ptr == p->enum_list[i].value) { + sprintf(s,"%s",p->enum_list[i].name); + break; + } } + break; + + case P_BOOL: + sprintf(s, "%s",BOOLSTR(*(BOOL *)ptr)); + break; + + case P_BOOLREV: + sprintf(s, "%s",BOOLSTR(! *(BOOL *)ptr)); + break; + + case P_INTEGER: + sprintf(s, "%d",*(int *)ptr); + break; + + case P_CHAR: + sprintf(s, "%c",*(char *)ptr); + break; + + case P_OCTAL: + sprintf(s, "0%o",*(int *)ptr); + break; + + case P_GSTRING: + case P_UGSTRING: + if ((char *)ptr) + sprintf(s, "%s",(char *)ptr); + break; + + case P_STRING: + case P_USTRING: + if (*(char **)ptr) + sprintf(s, "%s",*(char **)ptr); + break; + } } @@ -1876,6 +1846,7 @@ static BOOL equal_parameter(parm_type type,void *ptr1,void *ptr2) return(*((BOOL *)ptr1) == *((BOOL *)ptr2)); case P_INTEGER: + case P_ENUM: case P_OCTAL: return(*((int *)ptr1) == *((int *)ptr2)); @@ -1967,7 +1938,7 @@ static void dump_globals(FILE *f) (i == 0 || (parm_table[i].ptr != parm_table[i-1].ptr))) { fprintf(f,"\t%s = ",parm_table[i].label); - print_parameter(parm_table[i].type,parm_table[i].ptr, f); + print_parameter(&parm_table[i],parm_table[i].ptr, f); fprintf(f,"\n"); } } @@ -1996,7 +1967,7 @@ static void dump_a_service(service *pService, FILE *f) ((char *)&sDefault) + pdiff)) { fprintf(f,"\t%s = ",parm_table[i].label); - print_parameter(parm_table[i].type, + print_parameter(&parm_table[i], ((char *)pService) + pdiff, f); fprintf(f,"\n"); } @@ -2022,7 +1993,7 @@ int lp_next_parameter(int snum, int *i, char *label, ((*i) == 0 || (parm_table[*i].ptr != parm_table[(*i)-1].ptr))) { strcpy(label, parm_table[*i].label); - parameter_string(parm_table[*i].type, + parameter_string(&parm_table[*i], parm_table[*i].ptr, value); (*i)++; @@ -2045,7 +2016,7 @@ int lp_next_parameter(int snum, int *i, char *label, ((char *)pService) + pdiff, ((char *)&sDefault) + pdiff)) { strcpy(label, parm_table[*i].label); - parameter_string(parm_table[*i].type, + parameter_string(&parm_table[*i], ((char *)pService) + pdiff, value); (*i)++; |