Skip to content

Commit

Permalink
replace ERROR_OUT macro with ERR_REPORT, which is a little less ugly.…
Browse files Browse the repository at this point in the history
… also, add error reporting to detect_disk on OS X
  • Loading branch information
woodruffw committed Dec 28, 2014
1 parent 74e2788 commit 468fbae
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ void main_ascii_output(char *data[], char *data_names[])
}
else
{
ERROR_OUT("Error: ", "Could not find a logo for the distro.");
ERR_REPORT("Could not find a logo for the distro.");
}

return;
Expand Down
2 changes: 1 addition & 1 deletion src/disp.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void output_logo_only(char *distro);
void main_ascii_output(char *data[], char *data_names[]);
void main_text_output(char *data[], char *data_names[]);

#define ERROR_OUT(str1, str2) (fprintf(stderr, TWHT "[[ " TLRD "!" TWHT " ]] " TNRM "%s%s\n", str1, str2))
#define ERR_REPORT(str) (fprintf(stderr, TWHT "[[ " TLRD "!" TWHT " ]] " TNRM "Error: %s\n", str))
#define VERBOSE_OUT(str1, str2) (fprintf(stdout, TLRD ":: " TNRM "%s%s\n", str1, str2))

#endif /* SCREENFETCH_C_DISP_H */
8 changes: 4 additions & 4 deletions src/plat/bsd/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void detect_pkgs(char *str, const char *distro_str)
safe_strncpy(str, "Not Found", MAX_STRLEN);

if (error)
ERROR_OUT("Error: ", "Could not find packages on current OS.");
ERR_REPORT("Could not find packages on current OS.");
#endif

snprintf(str, MAX_STRLEN, "%d", packages);
Expand Down Expand Up @@ -233,7 +233,7 @@ void detect_disk(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "Could not stat $HOME for filesystem statistics.");
ERR_REPORT("Could not stat $HOME for filesystem statistics.");
}

return;
Expand Down Expand Up @@ -279,7 +279,7 @@ void detect_shell(char *str)
if (shell_name == NULL)
{
if (error)
ERROR_OUT("Error: ", "Could not detect a shell.");
ERR_REPORT("Could not detect a shell.");

return;
}
Expand Down Expand Up @@ -382,7 +382,7 @@ void detect_de(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "No desktop environment found.");
ERR_REPORT("No desktop environment found.");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/plat/darwin/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void detect_pkgs(char *str, const char *distro_str)
}
else if (error)
{
ERROR_OUT("Error: ", "Failure while globbing packages.");
ERR_REPORT("Failure while globbing packages.");
}

globfree(&gl);
Expand Down Expand Up @@ -231,7 +231,7 @@ void detect_disk(char *str)
}
else if (error)
{

ERR_REPORT("Could not stat $HOME for filesystem statistics.");
}

return;
Expand Down Expand Up @@ -288,7 +288,7 @@ void detect_shell(char *str)
if (shell_name == NULL)
{
if (error)
ERROR_OUT("Error: ", "Could not detect a shell.");
ERR_REPORT("Could not detect a shell.");

return;
}
Expand Down
34 changes: 17 additions & 17 deletions src/plat/linux/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ void detect_distro(char *str)
Until then, spit out an error message.
*/
if (error)
ERROR_OUT("Error: ", "Failed to detect a Linux distro.");
ERR_REPORT("Failed to detect a Linux distro.");
}
else
{
safe_strncpy(str, "Linux", MAX_STRLEN);

if (error)
{
ERROR_OUT("Error: ", "Failed to detect a Linux distro.");
ERR_REPORT("Failed to detect a Linux distro.");
}
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ void detect_host(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "Could not detetct username.");
ERR_REPORT("Could not detetct username.");
}

uname(&host_info);
Expand Down Expand Up @@ -247,7 +247,7 @@ void detect_pkgs(char *str, const char *distro_str)
}
else if (error)
{
ERROR_OUT("Error: ", "Failure while globbing packages.");
ERR_REPORT("Failure while globbing packages.");
}

globfree(&gl);
Expand Down Expand Up @@ -283,7 +283,7 @@ void detect_pkgs(char *str, const char *distro_str)
}
else if (error)
{
ERROR_OUT("Error: ", "Failure while globbing packages.");
ERR_REPORT("Failure while globbing packages.");
}

globfree(&gl);
Expand Down Expand Up @@ -321,8 +321,8 @@ void detect_pkgs(char *str, const char *distro_str)
safe_strncpy(str, "Not Found", MAX_STRLEN);

if (error)
ERROR_OUT("Error: ", "Packages cannot be detected on an unknown "
"Linux distro.");
ERR_REPORT("Packages cannot be detected on an unknown "
"Linux distro.");
}

snprintf(str, MAX_STRLEN, "%d", packages);
Expand Down Expand Up @@ -380,22 +380,22 @@ void detect_gpu(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "Failed to create OpenGL context.");
ERR_REPORT("Failed to create OpenGL context.");
}

XFree((void *) visual_info);
}
else if (error)
{
ERROR_OUT("Error: ", "Failed to select a proper X visual.");
ERR_REPORT("Failed to select a proper X visual.");
}

XCloseDisplay(disp);
}
else if (error)
{
safe_strncpy(str, "No X Server", MAX_STRLEN);
ERROR_OUT("Error: ", "Could not open an X display.");
ERR_REPORT("Could not open an X display.");
}

return;
Expand All @@ -419,7 +419,7 @@ void detect_disk(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "Could not stat $HOME for filesystem statistics.");
ERR_REPORT("Could not stat $HOME for filesystem statistics.");
}

return;
Expand Down Expand Up @@ -470,7 +470,7 @@ void detect_shell(char *str)
if (shell_name == NULL)
{
if (error)
ERROR_OUT("Error: ", "Could not detect a shell.");
ERR_REPORT("Could not detect a shell.");

return;
}
Expand Down Expand Up @@ -543,7 +543,7 @@ void detect_res(char *str)
safe_strncpy(str, "No X Server", MAX_STRLEN);

if (error)
ERROR_OUT("Error: ", "Problem detecting X display resolution.");
ERR_REPORT("Problem detecting X display resolution.");
}

return;
Expand Down Expand Up @@ -580,7 +580,7 @@ void detect_de(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "No desktop environment found.");
ERR_REPORT("No desktop environment found.");
}
}

Expand Down Expand Up @@ -618,21 +618,21 @@ void detect_wm(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "No _NET_WM_NAME property found.");
ERR_REPORT("No _NET_WM_NAME property found.");
}

XFree(wm_check_window);
}
else if (error)
{
ERROR_OUT("Error: ", "No WM detected (non-EWMH compliant?)");
ERR_REPORT("No WM detected (non-EWMH compliant?)");
}

XCloseDisplay(disp);
}
else if (error)
{
ERROR_OUT("Error: ", "Could not open an X display.");
ERR_REPORT("Could not open an X display.");
}

return;
Expand Down
14 changes: 7 additions & 7 deletions src/plat/sun/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void detect_disk(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "Could not stat $HOME for filesystem statistics.");
ERR_REPORT("Could not stat $HOME for filesystem statistics.");
}

return;
Expand Down Expand Up @@ -236,7 +236,7 @@ void detect_shell(char *str)
if (shell_name == NULL)
{
if (error)
ERROR_OUT("Error: ", "Could not detect a shell.");
ERR_REPORT("Could not detect a shell.");

return;
}
Expand Down Expand Up @@ -306,7 +306,7 @@ void detect_res(char *str)
safe_strncpy(str, "No X Server", MAX_STRLEN);

if (error)
ERROR_OUT("Error: ", "Problem detecting X display resolution.");
ERR_REPORT("Problem detecting X display resolution.");
}

XCloseDisplay(disp);
Expand Down Expand Up @@ -345,7 +345,7 @@ void detect_de(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "No desktop environment found.");
ERR_REPORT("No desktop environment found.");
}
}

Expand Down Expand Up @@ -387,21 +387,21 @@ void detect_wm(char *str)
}
else if (error)
{
ERROR_OUT("Error: ", "No _NET_WM_NAME property found.");
ERR_REPORT("No _NET_WM_NAME property found.");
}

XFree(wm_check_window);
}
else if (error)
{
ERROR_OUT("Error: ", "WM cannot be detected without EWMH compliance.");
ERR_REPORT("WM cannot be detected without EWMH compliance.");
}

XCloseDisplay(disp);
}
else if (error)
{
ERROR_OUT("Error: ", "Could not open an X display.");
ERR_REPORT("Could not open an X display.");
}

return;
Expand Down
4 changes: 2 additions & 2 deletions src/plat/win32/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void detect_host(char *str)
given_user = malloc(sizeof(char) * MAX_STRLEN);
if (!given_user)
{
ERROR_OUT("Error: ", "Memory allocation failed in detect_host.");
ERR_REPORT("Memory allocation failed in detect_host.");
exit(1);
}

Expand Down Expand Up @@ -297,7 +297,7 @@ void detect_shell(char *str)
if (shell_name == NULL)
{
if (error)
ERROR_OUT("Error: ", "Could not detect a shell.");
ERR_REPORT("Could not detect a shell.");

return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void take_screenshot(bool verbose)
}
else if (call_status && error)
{
ERROR_OUT("Error: ", "Problem saving screenshot.");
ERR_REPORT("Problem saving screenshot.");
}
#endif

Expand Down

0 comments on commit 468fbae

Please sign in to comment.