Project

General

Profile

relpath.diff

Yoann VANDOORSELAERE, 10/03/2008 03:28 PM

Download (8.23 KB)

View differences:

src/prelude-client-profile.c
82 82
extern char *_prelude_prefix;
83 83
static char *user_prefix = NULL;
84 84
static const char *relocated_prefix;
85

  
85 86
static const char *relative_spool_dir;
87
static prelude_bool_t spool_is_relative = FALSE;
88

  
86 89
static const char *relative_config_default_dir;
90
static prelude_bool_t config_default_is_relative = FALSE;
91

  
87 92
static const char *relative_profile_dir;
93
static prelude_bool_t profile_is_relative = FALSE;
88 94

  
89 95

  
90 96
gl_lock_t lock = gl_lock_initializer;
91 97
gl_once_define(static, relocate_once);
92 98

  
93 99

  
100

  
101
static const char *get_relpath(const char *path, prelude_bool_t *is_relative)
102
{
103
        if ( strstr(path, INSTALLPREFIX) ) {
104
                *is_relative = TRUE;
105
                return path + sizeof(INSTALLPREFIX);
106
        } else {
107
                *is_relative = FALSE;
108
                return path;
109
        }
110
}
111

  
112

  
113

  
94 114
static void _get_dir_once(void)
95 115
{
96 116
        relocated_prefix = (_prelude_prefix) ? _prelude_prefix : relocate(INSTALLPREFIX);
97
        relative_spool_dir = PRELUDE_SPOOL_DIR + sizeof(INSTALLPREFIX);
98
        relative_profile_dir = PRELUDE_PROFILE_DIR + sizeof(INSTALLPREFIX);
99
        relative_config_default_dir = PRELUDE_CONFIG_DEFAULT_DIR + sizeof(INSTALLPREFIX);
117

  
118
        relative_spool_dir = get_relpath(PRELUDE_SPOOL_DIR, &spool_is_relative);
119
        relative_profile_dir = get_relpath(PRELUDE_PROFILE_DIR, &profile_is_relative);
120
        relative_config_default_dir = get_relpath(PRELUDE_CONFIG_DEFAULT_DIR, &config_default_is_relative);
100 121

  
101 122
        prelude_log_debug(2, "install   prefix=%s", INSTALLPREFIX);
102 123
        prelude_log_debug(2, "relocated prefix=%s\n", relocated_prefix);
......
218 239

  
219 240
        gl_lock_lock(lock);
220 241

  
221
        prefix = get_prefix();
222
        snprintf(buf, size, "%s/%s", prefix, relative_config_default_dir);
242
        if ( ! config_default_is_relative )
243
                snprintf(buf, size, "%s", PRELUDE_CONFIG_DEFAULT_DIR);
244
        else {
245
                prefix = get_prefix();
246
                snprintf(buf, size, "%s/%s", prefix, relative_config_default_dir);
247
        }
223 248

  
224 249
        gl_lock_unlock(lock);
225 250
}
......
243 268

  
244 269
        gl_lock_lock(lock);
245 270

  
246
        prefix = get_prefix();
247
        snprintf(buf, size, "%s/%s/%s/analyzerid", prefix, relative_profile_dir, cp->name);
271
        if ( ! profile_is_relative )
272
                snprintf(buf, size, "%s/%s/analyzerid", PRELUDE_PROFILE_DIR, cp->name);
273
        else {
274
                prefix = get_prefix();
275
                snprintf(buf, size, "%s/%s/%s/analyzerid", prefix, relative_profile_dir, cp->name);
276
        }
248 277

  
249 278
        gl_lock_unlock(lock);
250 279
}
......
268 297

  
269 298
        gl_lock_lock(lock);
270 299

  
271
        prefix = get_prefix();
272
        snprintf(buf, size, "%s/%s/%s/config", prefix, relative_profile_dir, cp->name);
300
        if ( ! profile_is_relative )
301
                snprintf(buf, size, "%s/%s/config", PRELUDE_PROFILE_DIR, cp->name);
302
        else {
303
                prefix = get_prefix();
304
                snprintf(buf, size, "%s/%s/%s/config", prefix, relative_profile_dir, cp->name);
305
        }
273 306

  
274 307
        gl_lock_unlock(lock);
275 308
}
......
293 326

  
294 327
        gl_lock_lock(lock);
295 328

  
296
        prefix = get_prefix();
297
        snprintf(buf, size, "%s/%s/%s/key", prefix, relative_profile_dir, cp->name);
329
        if ( ! profile_is_relative )
330
                snprintf(buf, size, "%s/%s/key", PRELUDE_PROFILE_DIR, cp->name);
331
        else {
332
                prefix = get_prefix();
333
                snprintf(buf, size, "%s/%s/%s/key", prefix, relative_profile_dir, cp->name);
334
        }
298 335

  
299 336
        gl_lock_unlock(lock);
300 337
}
......
319 356

  
320 357
        gl_lock_lock(lock);
321 358

  
322
        prefix = get_prefix();
323
        snprintf(buf, size, "%s/%s/%s/server.ca", prefix, relative_profile_dir, cp->name);
359
        if ( ! profile_is_relative )
360
                snprintf(buf, size, "%s/%s/server.ca", PRELUDE_PROFILE_DIR, cp->name);
361
        else {
362
                prefix = get_prefix();
363
                snprintf(buf, size, "%s/%s/%s/server.ca", prefix, relative_profile_dir, cp->name);
364
        }
324 365

  
325 366
        gl_lock_unlock(lock);
326 367
}
......
345 386

  
346 387
        gl_lock_lock(lock);
347 388

  
348
        prefix = get_prefix();
349
        snprintf(buf, size, "%s/%s/%s/server.keycrt", prefix, relative_profile_dir, cp->name);
389
        if ( ! profile_is_relative )
390
                snprintf(buf, size, "%s/%s/server.keycrt", PRELUDE_PROFILE_DIR, cp->name);
391
        else {
392
                prefix = get_prefix();
393
                snprintf(buf, size, "%s/%s/%s/server.keycrt", prefix, relative_profile_dir, cp->name);
394
        }
350 395

  
351 396
        gl_lock_unlock(lock);
352 397
}
......
371 416

  
372 417
        gl_lock_lock(lock);
373 418

  
374
        prefix = get_prefix();
375
        snprintf(buf, size, "%s/%s/%s/server.crl", prefix, relative_profile_dir, cp->name);
419
        if ( ! profile_is_relative )
420
                snprintf(buf, size, "%s/%s/server.crl", PRELUDE_PROFILE_DIR, cp->name);
421
        else {
422
                prefix = get_prefix();
423
                snprintf(buf, size, "%s/%s/%s/server.crl", prefix, relative_profile_dir, cp->name);
424
        }
376 425

  
377 426
        gl_lock_unlock(lock);
378 427
}
......
397 446

  
398 447
        gl_lock_lock(lock);
399 448

  
400
        prefix = get_prefix();
401
        snprintf(buf, size, "%s/%s/%s/client.trusted", prefix, relative_profile_dir, cp->name);
449
        if ( ! profile_is_relative )
450
                snprintf(buf, size, "%s/%s/client.trusted", PRELUDE_PROFILE_DIR, cp->name);
451
        else {
452
                prefix = get_prefix();
453
                snprintf(buf, size, "%s/%s/%s/client.trusted", prefix, relative_profile_dir, cp->name);
454
        }
402 455

  
403 456
        gl_lock_unlock(lock);
404 457
}
......
424 477

  
425 478
        gl_lock_lock(lock);
426 479

  
427
        prefix = get_prefix();
428
        snprintf(buf, size, "%s/%s/%s/client.keycrt", prefix, relative_profile_dir, cp->name);
480
        if ( ! profile_is_relative )
481
                snprintf(buf, size, "%s/%s/client.keycrt", PRELUDE_PROFILE_DIR, cp->name);
482
        else {
483
                prefix = get_prefix();
484
                snprintf(buf, size, "%s/%s/%s/client.keycrt", prefix, relative_profile_dir, cp->name);
485
        }
429 486

  
430 487
        gl_lock_unlock(lock);
431 488
}
......
450 507

  
451 508
        gl_lock_lock(lock);
452 509

  
453
        prefix = get_prefix();
454
        snprintf(buf, size, "%s/%s/%s", prefix, relative_spool_dir, cp->name);
510

  
511
        if ( ! spool_is_relative )
512
                snprintf(buf, size, "%s/%s", PRELUDE_SPOOL_DIR, cp->name);
513
        else {
514
                prefix = get_prefix();
515
                snprintf(buf, size, "%s/%s/%s", prefix, relative_spool_dir, cp->name);
516
        }
455 517

  
456 518
        gl_lock_unlock(lock);
457 519
}
......
476 538
        gl_lock_lock(lock);
477 539
        prefix = get_prefix();
478 540

  
479
        if ( cp && cp->name )
480
                snprintf(buf, size, "%s/%s/%s", prefix, relative_profile_dir, cp->name);
481
        else
482
                snprintf(buf, size, "%s/%s", prefix, relative_profile_dir);
541
        if ( ! profile_is_relative )
542
                snprintf(buf, size, "%s/%s%s", PRELUDE_PROFILE_DIR, (cp->name) ? "/" : "", (cp->name) ? cp->name : "");
543
        else {
544
                prefix = get_prefix();
545
                snprintf(buf, size, "%s/%s%s%s", prefix, relative_profile_dir, (cp->name) ? "/" : "", (cp->name) ? cp->name : "");
546
        }
483 547

  
484 548
        gl_lock_unlock(lock);
485 549
}