Add source code module name to stdout/stderr messages to improve readability.

pull/1/head
Darrell Anderson 12 years ago
parent d4e7aaa421
commit 6d38a39e6d

@ -54,20 +54,20 @@ if ((result == -1) && (errno == ENOENT))
result = mkdir(tmp_dir, 0700); result = mkdir(tmp_dir, 0700);
if (result == -1) if (result == -1)
{ {
arts_warning("Error: Cannot create directory \"%s\".\n", tmp_dir); arts_warning("[mcoputils] Error: Cannot create directory \"%s\".\n", tmp_dir);
return 1; return 1;
} }
result = stat(tmp_dir, &stat_buf); result = stat(tmp_dir, &stat_buf);
} }
if ((result == -1) || (!S_ISDIR(stat_buf.st_mode))) if ((result == -1) || (!S_ISDIR(stat_buf.st_mode)))
{ {
arts_warning("Error: \"%s\" is not a directory.\n", tmp_dir); arts_warning("[mcoputils] Error: \"%s\" is not a directory.\n", tmp_dir);
return 1; return 1;
} }
if (stat_buf.st_uid != getuid()) if (stat_buf.st_uid != getuid())
{ {
arts_warning("Error: \"%s\" is owned by uid %d instead of uid %d.\n", tmp_dir, stat_buf.st_uid, getuid()); arts_warning("[mcoputils] Error: \"%s\" is owned by uid %d instead of uid %d.\n", tmp_dir, stat_buf.st_uid, getuid());
return 1; return 1;
} }
return 0; return 0;
@ -101,7 +101,7 @@ static char *locate_mcop_dir()
pw_ent = getpwuid(uid); pw_ent = getpwuid(uid);
if (!pw_ent) if (!pw_ent)
{ {
arts_warning("Error: Can not find password entry for uid %d.\n", getuid()); arts_warning("[mcoputils] Error: Can not find password entry for uid %d.\n", getuid());
return 0; return 0;
} }
@ -163,7 +163,7 @@ static char *locate_mcop_dir()
} }
if ((result == -1) || (!S_ISLNK(stat_buf.st_mode))) if ((result == -1) || (!S_ISLNK(stat_buf.st_mode)))
{ {
arts_warning("Error: \"%s\" is not a link or a directory.\n", kde_tmp_dir.c_str()); arts_warning("[mcoputils] Error: \"%s\" is not a link or a directory.\n", kde_tmp_dir.c_str());
return 0; return 0;
} }
@ -178,17 +178,17 @@ static char *locate_mcop_dir()
result = readlink(kde_tmp_dir.c_str(), tmp_buf, size - 1); result = readlink(kde_tmp_dir.c_str(), tmp_buf, size - 1);
if (result == -1) if (result == -1)
{ {
arts_warning("Error: \"%s\" could not be read.\n", kde_tmp_dir.c_str()); arts_warning("[mcoputils] Error: \"%s\" could not be read.\n", kde_tmp_dir.c_str());
free(tmp_buf); free(tmp_buf);
return 0; return 0;
} }
} while(result == size - 1); } while(result == size - 1);
tmp_buf[result] = '\0'; tmp_buf[result] = '\0';
// printf("Link points to \"%s\"\n", tmp_buf); // printf("[mcoputils] Link \"%s\" points to \"%s\"\n", kde_tmp_dir.c_str(), tmp_buf);
if (strncmp(tmp_buf, user_tmp_dir.c_str(), user_tmp_dir.length()) != 0) if (strncmp(tmp_buf, user_tmp_dir.c_str(), user_tmp_dir.length()) != 0)
{ {
arts_warning("Error: \"%s\" points to \"%s\" instead of \"%s\".\n", kde_tmp_dir.c_str(), tmp_buf, user_tmp_dir.c_str()); arts_warning("[mcoputils] Error: \"%s\" points to \"%s\" instead of \"%s\".\n", kde_tmp_dir.c_str(), tmp_buf, user_tmp_dir.c_str());
free(tmp_buf); free(tmp_buf);
return 0; return 0;
} }
@ -214,10 +214,10 @@ int create_link(const char *file, const char *tmp_dir)
result = symlink(tmp_dir, file); result = symlink(tmp_dir, file);
if (result == -1) if (result == -1)
{ {
fprintf(stderr, "Error: Can not create link from \"%s\" to \"%s\"\n", file, tmp_dir); fprintf(stderr, "[mcoputils] Error: Can not create link from \"%s\" to \"%s\"\n", file, tmp_dir);
return 1; return 1;
} }
printf("Created link from \"%s\" to \"%s\"\n", file, tmp_dir); printf("[mcoputils] Created link from \"%s\" to \"%s\"\n", file, tmp_dir);
return 0; return 0;
} }
@ -240,7 +240,7 @@ int build_link(string tmp_prefix, const char *kde_prefix)
pw_ent = getpwuid(uid); pw_ent = getpwuid(uid);
if (!pw_ent) if (!pw_ent)
{ {
fprintf(stderr, "Error: Can not find password entry for uid %d.\n", getuid()); fprintf(stderr, "[mcoputils] Error: Can not find password entry for uid %d.\n", getuid());
return 1; return 1;
} }
@ -259,7 +259,7 @@ int build_link(string tmp_prefix, const char *kde_prefix)
} }
if (!home_dir || !home_dir[0]) if (!home_dir || !home_dir[0])
{ {
fprintf(stderr, "Aborting. $HOME not set!"); fprintf(stderr, "[mcoputils] Aborting. $HOME not set!");
exit(255); exit(255);
} }
kde_home++; kde_home++;
@ -296,12 +296,12 @@ int build_link(string tmp_prefix, const char *kde_prefix)
if ((result == 0) && (S_ISDIR(stat_buf.st_mode))) if ((result == 0) && (S_ISDIR(stat_buf.st_mode)))
{ {
/* $TDEHOME/tmp is a normal directory. Do nothing. */ /* $TDEHOME/tmp is a normal directory. Do nothing. */
printf("Directory \"%s\" already exists.\n", kde_tmp_dir.c_str()); printf("[mcoputils] Directory \"%s\" already exists.\n", kde_tmp_dir.c_str());
return 0; return 0;
} }
if ((result == -1) && (errno == ENOENT)) if ((result == -1) && (errno == ENOENT))
{ {
printf("Creating link %s.\n", kde_tmp_dir.c_str()); printf("[mcoputils] Creating link %s.\n", kde_tmp_dir.c_str());
result = create_link(kde_tmp_dir.c_str(), user_tmp_dir.c_str()); result = create_link(kde_tmp_dir.c_str(), user_tmp_dir.c_str());
if (result == 0) return 0; /* Success */ if (result == 0) return 0; /* Success */
unlink(kde_tmp_dir.c_str()); unlink(kde_tmp_dir.c_str());
@ -314,7 +314,7 @@ int build_link(string tmp_prefix, const char *kde_prefix)
} }
if ((result == -1) || (!S_ISLNK(stat_buf.st_mode))) if ((result == -1) || (!S_ISLNK(stat_buf.st_mode)))
{ {
fprintf(stderr, "Error: \"%s\" is not a link or a directory.\n", kde_tmp_dir.c_str()); fprintf(stderr, "[mcoputils] Error: \"%s\" is not a link or a directory.\n", kde_tmp_dir.c_str());
return 1; return 1;
} }
/* kde_tmp_dir is a link. Check whether it points to a valid directory. */ /* kde_tmp_dir is a link. Check whether it points to a valid directory. */
@ -328,20 +328,20 @@ int build_link(string tmp_prefix, const char *kde_prefix)
result = readlink(kde_tmp_dir.c_str(), tmp_buf, size - 1); result = readlink(kde_tmp_dir.c_str(), tmp_buf, size - 1);
if (result == -1) if (result == -1)
{ {
arts_warning("Error: \"%s\" could not be read.\n", kde_tmp_dir.c_str()); arts_warning("[mcoputils] Error: \"%s\" could not be read.\n", kde_tmp_dir.c_str());
free(tmp_buf); free(tmp_buf);
return 0; return 0;
} }
} while(result == size - 1); } while(result == size - 1);
tmp_buf[result] = '\0'; tmp_buf[result] = '\0';
printf("Link points to \"%s\"\n", tmp_buf); printf("[mcoputils] Link \"%s\" points to \"%s\"\n", kde_tmp_dir.c_str(), tmp_buf);
if (strncmp(tmp_buf, user_tmp_dir.c_str(), user_tmp_dir.length()) != 0) if (strncmp(tmp_buf, user_tmp_dir.c_str(), user_tmp_dir.length()) != 0)
{ {
fprintf(stderr, "Error: \"%s\" points to \"%s\" instead of \"%s\".\n", kde_tmp_dir.c_str(), tmp_buf, user_tmp_dir.c_str()); fprintf(stderr, "[mcoputils] Error: \"%s\" points to \"%s\" instead of \"%s\".\n", kde_tmp_dir.c_str(), tmp_buf, user_tmp_dir.c_str());
free(tmp_buf); free(tmp_buf);
unlink(kde_tmp_dir.c_str()); unlink(kde_tmp_dir.c_str());
printf("Creating link %s.\n", kde_tmp_dir.c_str()); printf("[mcoputils] Creating link %s.\n", kde_tmp_dir.c_str());
result = create_link(kde_tmp_dir.c_str(), user_tmp_dir.c_str()); result = create_link(kde_tmp_dir.c_str(), user_tmp_dir.c_str());
if (result == 0) return 0; /* Success */ if (result == 0) return 0; /* Success */
unlink(kde_tmp_dir.c_str()); unlink(kde_tmp_dir.c_str());
@ -516,7 +516,7 @@ string MCOPUtils::mcopDirectory()
stat(mcopDirectory.c_str(),&st); stat(mcopDirectory.c_str(),&st);
if(!S_ISDIR(st.st_mode)) if(!S_ISDIR(st.st_mode))
{ {
arts_warning("can't create directory %s (%s)", arts_warning("[mcoputils] can't create directory %s (%s)",
mcopDirectory.c_str(), why.c_str()); mcopDirectory.c_str(), why.c_str());
mcopDirectory = ""; mcopDirectory = "";

Loading…
Cancel
Save