Changeset 482 for branches/samba-3.3.x/source
- Timestamp:
- Aug 16, 2010, 1:06:28 PM (15 years ago)
- Location:
- branches/samba-3.3.x/source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/dynconfig.c
r372 r482 41 41 **/ 42 42 43 #ifndef __OS2__ 43 44 #define DEFINE_DYN_CONFIG_PARAM(name) \ 44 45 static char *dyn_##name; \ … … 65 66 return (dyn_##name == NULL);\ 66 67 } 67 68 #ifndef __OS2__ 68 #else 69 #define DEFINE_DYN_CONFIG_PARAM(name) \ 70 static char *dyn_##name; \ 71 \ 72 const char *set_dyn_##name(const char *newpath) \ 73 {\ 74 if (dyn_##name) {\ 75 SAFE_FREE(dyn_##name);\ 76 }\ 77 dyn_##name = SMB_STRDUP(newpath);\ 78 return dyn_##name;\ 79 }\ 80 \ 81 bool is_default_dyn_##name(void) \ 82 {\ 83 return (dyn_##name == NULL);\ 84 } 85 #endif 86 69 87 DEFINE_DYN_CONFIG_PARAM(SBINDIR) 70 88 DEFINE_DYN_CONFIG_PARAM(BINDIR) … … 76 94 DEFINE_DYN_CONFIG_PARAM(LIBDIR) 77 95 DEFINE_DYN_CONFIG_PARAM(MODULESDIR) 78 #endif79 96 DEFINE_DYN_CONFIG_PARAM(SHLIBEXT) 80 #ifndef __OS2__81 97 DEFINE_DYN_CONFIG_PARAM(LOCKDIR) 82 98 DEFINE_DYN_CONFIG_PARAM(PIDDIR) 83 99 DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE) 84 100 DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR) 85 #endif 101 86 102 87 103 #ifdef __OS2__ 88 104 89 105 /* Directory the binary was called from, same as getbindir() */ 90 static char *dyn_SBINDIR;91 92 106 const char *get_dyn_SBINDIR(void) 93 107 { … … 110 124 } 111 125 112 const char *set_dyn_SBINDIR(const char *newpath)113 {114 if (dyn_SBINDIR) {115 SAFE_FREE(dyn_SBINDIR);116 }117 dyn_SBINDIR = SMB_STRDUP(newpath);118 return dyn_SBINDIR;119 }120 121 126 /* Directory the binary was called from, same as getsbindir() */ 122 static char *dyn_BINDIR;123 124 127 const char *get_dyn_BINDIR(void) 125 128 { … … 142 145 } 143 146 144 const char *set_dyn_BINDIR(const char *newpath)145 {146 if (dyn_BINDIR) {147 SAFE_FREE(dyn_BINDIR);148 }149 dyn_BINDIR = SMB_STRDUP(newpath);150 return dyn_BINDIR;151 }152 153 147 /* Directory holding the SWAT files */ 154 static char *dyn_SWATDIR;155 156 148 const char *get_dyn_SWATDIR(void) 157 149 { … … 174 166 } 175 167 176 const char *set_dyn_SWATDIR(const char *newpath)177 {178 if (dyn_SWATDIR) {179 SAFE_FREE(dyn_SWATDIR);180 }181 dyn_SWATDIR = SMB_STRDUP(newpath);182 return dyn_SWATDIR;183 }184 185 186 168 /* Location of smb.conf file. */ 187 static char *dyn_CONFIGFILE;188 189 169 const char *get_dyn_CONFIGFILE(void) 190 170 { … … 218 198 } 219 199 220 const char *set_dyn_CONFIGFILE(const char *newpath)221 {222 if (dyn_CONFIGFILE) {223 SAFE_FREE(dyn_CONFIGFILE);224 }225 dyn_CONFIGFILE = SMB_STRDUP(newpath);226 return dyn_CONFIGFILE;227 }228 229 bool is_default_dyn_CONFIGFILE(void) \230 {\231 return (dyn_CONFIGFILE == NULL);\232 }233 234 200 /** Log file directory. **/ 235 static char *dyn_LOGFILEBASE;236 237 201 const char *get_dyn_LOGFILEBASE(void) 238 202 { … … 248 212 } 249 213 250 const char *set_dyn_LOGFILEBASE(const char *newpath)251 {252 if (dyn_LOGFILEBASE) {253 SAFE_FREE(dyn_LOGFILEBASE);254 }255 dyn_LOGFILEBASE = SMB_STRDUP(newpath);256 return dyn_LOGFILEBASE;257 }258 259 214 /** Statically configured LanMan hosts. **/ 260 static char *dyn_LMHOSTSFILE;261 262 215 const char *get_dyn_LMHOSTSFILE(void) 263 216 { … … 273 226 } 274 227 275 const char *set_dyn_LMHOSTSFILE(const char *newpath)276 {277 if (dyn_LMHOSTSFILE) {278 SAFE_FREE(dyn_LMHOSTSFILE);279 }280 dyn_LMHOSTSFILE = SMB_STRDUP(newpath);281 return dyn_LMHOSTSFILE;282 }283 284 228 /* Directory holding the codepages */ 285 static char *dyn_CODEPAGEDIR;286 287 229 const char *get_dyn_CODEPAGEDIR(void) 288 230 { … … 305 247 } 306 248 307 const char *set_dyn_CODEPAGEDIR(const char *newpath)308 {309 if (dyn_CODEPAGEDIR) {310 SAFE_FREE(dyn_CODEPAGEDIR);311 }312 dyn_CODEPAGEDIR = SMB_STRDUP(newpath);313 return dyn_CODEPAGEDIR;314 }315 316 249 /* Directory holding the libs */ 317 static char *dyn_LIBDIR;318 319 250 const char *get_dyn_LIBDIR(void) 320 251 { … … 337 268 } 338 269 339 const char *set_dyn_LIBDIR(const char *newpath)340 {341 if (dyn_LIBDIR) {342 SAFE_FREE(dyn_LIBDIR);343 }344 dyn_LIBDIR = SMB_STRDUP(newpath);345 return dyn_LIBDIR;346 }347 348 270 /* Directory holding the modules */ 349 static char *dyn_MODULESDIR;350 351 271 const char *get_dyn_MODULESDIR(void) 352 272 { … … 369 289 } 370 290 371 const char *set_dyn_MODULESDIR(const char *newpath) 372 { 373 if (dyn_MODULESDIR) { 374 SAFE_FREE(dyn_MODULESDIR); 375 } 376 dyn_MODULESDIR = SMB_STRDUP(newpath); 377 return dyn_MODULESDIR; 378 } 379 380 /** 381 * @brief Directory holding lock files. 382 * 383 * Not writable, but used to set a default in the parameter table. 384 **/ 385 386 static char *dyn_LOCKDIR; 387 291 /* Directory holding lock files */ 388 292 const char *get_dyn_LOCKDIR(void) 389 293 { … … 391 295 if (!*buffer) 392 296 { 393 snprintf(buffer, 260, "%s/samba/lock", getenv("ETC")); 297 if (os2_isClient()) 298 { 299 snprintf(buffer, 260, "%s/samba/lock/client", getenv("ETC")); 300 } else { 301 snprintf(buffer, 260, "%s/samba/lock", getenv("ETC")); 302 } 394 303 } 395 304 if (dyn_LOCKDIR == NULL) { … … 399 308 } 400 309 401 const char *set_dyn_LOCKDIR(const char *newpath)402 {403 if (dyn_LOCKDIR) {404 SAFE_FREE(dyn_LOCKDIR);405 }406 dyn_LOCKDIR = SMB_STRDUP(newpath);407 return dyn_LOCKDIR;408 }409 410 310 /* Directory holding the pid files */ 411 static char *dyn_PIDDIR;412 413 311 const char *get_dyn_PIDDIR(void) 414 312 { … … 424 322 } 425 323 426 const char *set_dyn_PIDDIR(const char *newpath)427 {428 if (dyn_PIDDIR) {429 SAFE_FREE(dyn_PIDDIR);430 }431 dyn_PIDDIR = SMB_STRDUP(newpath);432 return dyn_PIDDIR;433 }434 435 324 /* Location of smbpasswd */ 436 static char *dyn_SMB_PASSWD_FILE;437 438 325 const char *get_dyn_SMB_PASSWD_FILE(void) 439 326 { … … 449 336 } 450 337 451 const char *set_dyn_SMB_PASSWD_FILE(const char *newpath)452 {453 if (dyn_SMB_PASSWD_FILE) {454 SAFE_FREE(dyn_SMB_PASSWD_FILE);455 }456 dyn_SMB_PASSWD_FILE = SMB_STRDUP(newpath);457 return dyn_SMB_PASSWD_FILE;458 }459 460 338 /* Directory holding the private files */ 461 static char *dyn_PRIVATE_DIR;462 463 339 const char *get_dyn_PRIVATE_DIR(void) 464 340 { … … 474 350 } 475 351 476 const char *set_dyn_PRIVATE_DIR(const char *newpath) 477 { 478 if (dyn_PRIVATE_DIR) { 479 SAFE_FREE(dyn_PRIVATE_DIR); 480 } 481 dyn_PRIVATE_DIR = SMB_STRDUP(newpath); 482 return dyn_PRIVATE_DIR; 483 } 352 /* Directory holding the shared libs (same as libdir) */ 353 const char *get_dyn_SHLIBEXT(void) 354 { 355 static char buffer[1024] = ""; 356 if (!*buffer) 357 { 358 char exedir[1024] = ""; 359 if (os2_GetExePath(exedir) != 0) 360 { 361 snprintf(buffer, 260, "%s", LIBDIR); 362 } else { 363 snprintf(buffer, 260, "%s/%s", exedir, "lib"); 364 } 365 } 366 367 if (dyn_SHLIBEXT == NULL) { 368 return buffer; 369 } 370 return dyn_SHLIBEXT; 371 } 372 484 373 #endif /* __OS2__ */ 485 374 -
branches/samba-3.3.x/source/lib/os2helper.c
r470 r482 95 95 } 96 96 97 // we search the path of the .exe and return it98 int os2_GetExePath(char *buff)97 // get the exe name (including path) 98 bool os2_GetExeName(char *sExeName) 99 99 { 100 100 APIRET rc = NO_ERROR; 101 PPIB ppib = NULL; 102 char sExePath [_MAX_PATH]; 103 char sDrive [_MAX_PATH], sDir [_MAX_DIR]; 101 PPIB ppib = NULL; 104 102 105 103 // we search for the infoblock to get the module name … … 107 105 if (rc != NO_ERROR) 108 106 { 109 return -1;107 return false; 110 108 } 111 109 112 110 // with the module name we get the path (including the exe name) 113 rc = DosQueryModuleName(ppib->pib_hmte, sizeof(sExe Path), sExePath);111 rc = DosQueryModuleName(ppib->pib_hmte, sizeof(sExeName), sExeName); 114 112 if (rc != NO_ERROR) 115 113 { 116 return -1; 117 } 114 return false; 115 } 116 return true; 117 } 118 119 // we search the path of the .exe and return it 120 int os2_GetExePath(char *buff) 121 { 122 char sExeName [_MAX_PATH]; 123 char sDrive [_MAX_PATH], sDir [_MAX_DIR]; 124 125 if (!os2_GetExeName(sExeName)) 126 return false; 118 127 119 128 // we split to the different values 120 _splitpath(sExe Path, sDrive, sDir, NULL, NULL);129 _splitpath(sExeName, sDrive, sDir, NULL, NULL); 121 130 // strcat(sDrive, sDir); 122 131 strncat(sDrive, sDir, strlen(sDir) -1); … … 124 133 125 134 return 0; 135 } 136 137 // we search with the exe name if we are in client mode 138 bool os2_isClient() 139 { 140 char sExeName [_MAX_PATH]; 141 char sDrive [_MAX_PATH], sDir [_MAX_DIR], sName[_MAX_PATH]; 142 143 if (!os2_GetExeName(sExeName)) 144 return false; 145 146 // we split to the different values 147 _splitpath(sExeName, sDrive, sDir, sName, NULL); 148 if ( (stricmp(sName, "NDCTL") == 0) || (stricmp(sName, "EVFSCTL") == 0) ) 149 { 150 return true; 151 } else { 152 return false; 153 } 126 154 } 127 155
Note:
See TracChangeset
for help on using the changeset viewer.