summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dransfeld <sd@tango.flipp.net>2012-10-18 11:19:14 +0000
committerSebastian Dransfeld <sd@tango.flipp.net>2012-10-18 11:19:14 +0000
commite327361844a2e352040a5e8a4905c08d2f92d054 (patch)
tree0bb52e4ddaa21cb04ffb995d8898ca296600cbab
parent652125a269592b1ef170f1ee2dfa30afdcbf4edc (diff)
efreet: formatting
SVN revision: 78178
-rw-r--r--legacy/efreet/src/lib/efreet_base.c172
1 files changed, 86 insertions, 86 deletions
diff --git a/legacy/efreet/src/lib/efreet_base.c b/legacy/efreet/src/lib/efreet_base.c
index 3d9f75ded2..6acf42fc4b 100644
--- a/legacy/efreet/src/lib/efreet_base.c
+++ b/legacy/efreet/src/lib/efreet_base.c
@@ -63,7 +63,7 @@ static const char *hostname = NULL;
63 63
64static const char *efreet_dir_get(const char *key, const char *fallback); 64static const char *efreet_dir_get(const char *key, const char *fallback);
65static Eina_List *efreet_dirs_get(const char *key, 65static Eina_List *efreet_dirs_get(const char *key,
66 const char *fallback); 66 const char *fallback);
67static const char *efreet_user_dir_get(const char *key, const char *fallback); 67static const char *efreet_user_dir_get(const char *key, const char *fallback);
68 68
69/** 69/**
@@ -75,7 +75,7 @@ int
75efreet_base_init(void) 75efreet_base_init(void)
76{ 76{
77 _efreet_base_log_dom = eina_log_domain_register 77 _efreet_base_log_dom = eina_log_domain_register
78 ("efreet_base", EFREET_DEFAULT_LOG_COLOR); 78 ("efreet_base", EFREET_DEFAULT_LOG_COLOR);
79 if (_efreet_base_log_dom < 0) 79 if (_efreet_base_log_dom < 0)
80 { 80 {
81 EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_base.\n"); 81 EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_base.\n");
@@ -228,7 +228,7 @@ efreet_data_dirs_get(void)
228 xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS", buf); 228 xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS", buf);
229#else 229#else
230 xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS", 230 xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS",
231 PACKAGE_DATA_DIR ":/usr/share:/usr/local/share"); 231 PACKAGE_DATA_DIR ":/usr/share:/usr/local/share");
232#endif 232#endif
233 return xdg_data_dirs; 233 return xdg_data_dirs;
234} 234}
@@ -264,33 +264,33 @@ efreet_runtime_dir_get(void)
264 if (xdg_runtime_dir) return xdg_runtime_dir; 264 if (xdg_runtime_dir) return xdg_runtime_dir;
265 xdg_runtime_dir = efreet_dir_get("XDG_RUNTIME_DIR", "/tmp"); 265 xdg_runtime_dir = efreet_dir_get("XDG_RUNTIME_DIR", "/tmp");
266 if (stat(xdg_runtime_dir, &st) == -1) 266 if (stat(xdg_runtime_dir, &st) == -1)
267 { 267 {
268 ERR("$XDG_RUNTIME_DIR did not exist, creating '%s' (breaks spec)", 268 ERR("$XDG_RUNTIME_DIR did not exist, creating '%s' (breaks spec)",
269 xdg_runtime_dir); 269 xdg_runtime_dir);
270 if (ecore_file_mkpath(xdg_runtime_dir)) 270 if (ecore_file_mkpath(xdg_runtime_dir))
271 chmod(xdg_runtime_dir, 0700); 271 chmod(xdg_runtime_dir, 0700);
272 else 272 else
273 { 273 {
274 CRITICAL("Failed to create XDG_RUNTIME_DIR=%s", xdg_runtime_dir); 274 CRITICAL("Failed to create XDG_RUNTIME_DIR=%s", xdg_runtime_dir);
275 eina_stringshare_replace(&xdg_runtime_dir, NULL); 275 eina_stringshare_replace(&xdg_runtime_dir, NULL);
276 } 276 }
277 } 277 }
278 else if (!S_ISDIR(st.st_mode)) 278 else if (!S_ISDIR(st.st_mode))
279 { 279 {
280 CRITICAL("XDG_RUNTIME_DIR=%s is not a directory!", xdg_runtime_dir); 280 CRITICAL("XDG_RUNTIME_DIR=%s is not a directory!", xdg_runtime_dir);
281 eina_stringshare_replace(&xdg_runtime_dir, NULL); 281 eina_stringshare_replace(&xdg_runtime_dir, NULL);
282 } 282 }
283 else if ((st.st_mode & 0777) != 0700) 283 else if ((st.st_mode & 0777) != 0700)
284 { 284 {
285 ERR("XDG_RUNTIME_DIR=%s is mode %o, changing to 0700", 285 ERR("XDG_RUNTIME_DIR=%s is mode %o, changing to 0700",
286 xdg_runtime_dir, st.st_mode & 0777); 286 xdg_runtime_dir, st.st_mode & 0777);
287 if (chmod(xdg_runtime_dir, 0700) != 0) 287 if (chmod(xdg_runtime_dir, 0700) != 0)
288 { 288 {
289 CRITICAL("Cannot fix XDG_RUNTIME_DIR=%s incorrect mode %o: %s", 289 CRITICAL("Cannot fix XDG_RUNTIME_DIR=%s incorrect mode %o: %s",
290 xdg_runtime_dir, st.st_mode & 0777, strerror(errno)); 290 xdg_runtime_dir, st.st_mode & 0777, strerror(errno));
291 eina_stringshare_replace(&xdg_runtime_dir, NULL); 291 eina_stringshare_replace(&xdg_runtime_dir, NULL);
292 } 292 }
293 } 293 }
294 294
295 return xdg_runtime_dir; 295 return xdg_runtime_dir;
296} 296}
@@ -411,46 +411,46 @@ efreet_dirs_get(const char *key, const char *fallback)
411static const char * 411static const char *
412efreet_env_expand(const char *in) 412efreet_env_expand(const char *in)
413{ 413{
414 Eina_Strbuf *sb; 414 Eina_Strbuf *sb;
415 const char *ret, *p, *e1 = NULL, *e2 = NULL, *val; 415 const char *ret, *p, *e1 = NULL, *e2 = NULL, *val;
416 char *env; 416 char *env;
417 417
418 if (!in) return NULL; 418 if (!in) return NULL;
419 sb = eina_strbuf_new(); 419 sb = eina_strbuf_new();
420 if (!sb) return NULL; 420 if (!sb) return NULL;
421 421
422 /* maximum length of any env var is the input string */ 422 /* maximum length of any env var is the input string */
423 env = alloca(strlen(in) + 1); 423 env = alloca(strlen(in) + 1);
424 for (p = in; *p; p++) 424 for (p = in; *p; p++)
425 { 425 {
426 if (!e1) 426 if (!e1)
427 { 427 {
428 if (*p == '$') e1 = p + 1; 428 if (*p == '$') e1 = p + 1;
429 else eina_strbuf_append_char(sb, *p); 429 else eina_strbuf_append_char(sb, *p);
430 } 430 }
431 else if (!(((*p >= 'a') && (*p <= 'z')) || 431 else if (!(((*p >= 'a') && (*p <= 'z')) ||
432 ((*p >= 'A') && (*p <= 'Z')) || 432 ((*p >= 'A') && (*p <= 'Z')) ||
433 ((*p >= '0') && (*p <= '9')) || 433 ((*p >= '0') && (*p <= '9')) ||
434 (*p == '_'))) 434 (*p == '_')))
435 { 435 {
436 size_t len; 436 size_t len;
437 437
438 e2 = p; 438 e2 = p;
439 len = (size_t)(e2 - e1); 439 len = (size_t)(e2 - e1);
440 if (len > 0) 440 if (len > 0)
441 { 441 {
442 memcpy(env, e1, len); 442 memcpy(env, e1, len);
443 env[len] = 0; 443 env[len] = 0;
444 val = getenv(env); 444 val = getenv(env);
445 if (val) eina_strbuf_append(sb, val); 445 if (val) eina_strbuf_append(sb, val);
446 } 446 }
447 e1 = NULL; 447 e1 = NULL;
448 eina_strbuf_append_char(sb, *p); 448 eina_strbuf_append_char(sb, *p);
449 } 449 }
450 } 450 }
451 ret = eina_stringshare_add(eina_strbuf_string_get(sb)); 451 ret = eina_stringshare_add(eina_strbuf_string_get(sb));
452 eina_strbuf_free(sb); 452 eina_strbuf_free(sb);
453 return ret; 453 return ret;
454} 454}
455 455
456/** 456/**
@@ -464,22 +464,22 @@ efreet_env_expand(const char *in)
464static const char * 464static const char *
465efreet_user_dir_get(const char *key, const char *fallback) 465efreet_user_dir_get(const char *key, const char *fallback)
466{ 466{
467 Eina_File *file = NULL; 467 Eina_File *file = NULL;
468 Eina_File_Line *line; 468 Eina_File_Line *line;
469 Eina_Iterator *it = NULL; 469 Eina_Iterator *it = NULL;
470 const char *config_home; 470 const char *config_home;
471 char path[PATH_MAX]; 471 char path[PATH_MAX];
472 char *ret = NULL; 472 char *ret = NULL;
473 473
474 config_home = efreet_config_home_get(); 474 config_home = efreet_config_home_get();
475 snprintf(path, sizeof(path), "%s/user-dirs.dirs", config_home); 475 snprintf(path, sizeof(path), "%s/user-dirs.dirs", config_home);
476 476
477 file = eina_file_open(path, EINA_FALSE); 477 file = eina_file_open(path, EINA_FALSE);
478 if (!file) goto fallback; 478 if (!file) goto fallback;
479 it = eina_file_map_lines(file); 479 it = eina_file_map_lines(file);
480 if (!it) goto fallback; 480 if (!it) goto fallback;
481 EINA_ITERATOR_FOREACH(it, line) 481 EINA_ITERATOR_FOREACH(it, line)
482 { 482 {
483 const char *eq, *end; 483 const char *eq, *end;
484 484
485 if (line->length < 3) continue; 485 if (line->length < 3) continue;
@@ -497,16 +497,16 @@ efreet_user_dir_get(const char *key, const char *fallback)
497 memcpy(ret, eq, end - eq); 497 memcpy(ret, eq, end - eq);
498 ret[end - eq] = '\0'; 498 ret[end - eq] = '\0';
499 break; 499 break;
500 } 500 }
501fallback: 501fallback:
502 if (it) eina_iterator_free(it); 502 if (it) eina_iterator_free(it);
503 if (file) eina_file_close(file); 503 if (file) eina_file_close(file);
504 if (!ret) 504 if (!ret)
505 { 505 {
506 const char *home; 506 const char *home;
507 home = efreet_home_dir_get(); 507 home = efreet_home_dir_get();
508 ret = alloca(strlen(home) + strlen(fallback) + 2); 508 ret = alloca(strlen(home) + strlen(fallback) + 2);
509 sprintf(ret, "%s/%s", home, fallback); 509 sprintf(ret, "%s/%s", home, fallback);
510 } 510 }
511 return efreet_env_expand(ret); 511 return efreet_env_expand(ret);
512} 512}