From f3d42738f667dd09a4da9cc0a863c44e9cdb3666 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 1 May 2014 12:33:34 +1200 Subject: Debug messages --- trayfreq_set/trayfreq_set.c | 48 +++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'trayfreq_set/trayfreq_set.c') diff --git a/trayfreq_set/trayfreq_set.c b/trayfreq_set/trayfreq_set.c index cb5b2c3..0d65138 100644 --- a/trayfreq_set/trayfreq_set.c +++ b/trayfreq_set/trayfreq_set.c @@ -27,6 +27,7 @@ #include "../freq_tray/getfreq.h" #include "../freq_tray/getcore.h" +#include "../debug.h" #define FILE_PATH_STRING_SIZE 100 @@ -54,9 +55,7 @@ char write_str_to_file(const char *file, const char *data, const char *core) // Try to open file and write data to it if ( (fd = fopen(file_path, "w")) != NULL ) { -#ifdef DEBUG - printf("Writing '%s' to '%s'\n",data,file_path); -#endif + debug("Writing '%s' to '%s'\n",data,file_path); fprintf(fd, data); fclose(fd); return 1; @@ -85,10 +84,8 @@ void get_argument_summary(int argc, char **argv, argument_summary *argsum) { if ( strcmp(argv[arg], "-c") == 0 ) { -#ifdef DEBUG - printf("Found -c with arg '%s'\n",argv[arg+1]); -#endif // Found -c with an arg + debug("Found -c with arg '%s'\n",argv[arg+1]); argsum->present |= ARG_CORE; argsum->core = (char*)(argv[arg+1]); continue; @@ -96,11 +93,8 @@ void get_argument_summary(int argc, char **argv, argument_summary *argsum) if ( strcmp(argv[arg], "-f") == 0 ) { -#ifdef DEBUG - printf("Found -f with arg '%s'\n",argv[arg+1]); -#endif - // Found -f with an arg + debug("Found -f with arg '%s'\n",argv[arg+1]); argsum->present |= ARG_FREQ; argsum->frequency = (char*)(argv[arg+1]); continue; @@ -108,10 +102,8 @@ void get_argument_summary(int argc, char **argv, argument_summary *argsum) if ( strcmp(argv[arg], "-g") == 0 ) { -#ifdef DEBUG - printf("Found -g with arg '%s'\n",argv[arg+1]); -#endif // Found -g with an arg + debug("Found -g with arg '%s'\n",argv[arg+1]); argsum->present |= ARG_GOV; argsum->governor = (char*)(argv[arg+1]); //continue; @@ -131,9 +123,7 @@ int main(int argc, char *argv[]) // TO DO: Needs to be #defined textdomain("trayfreq"); -#ifdef DEBUG - printf("Set gettext up\n"); -#endif + debug("Set gettext up\n"); gc_init(); gf_init(); @@ -146,34 +136,28 @@ int main(int argc, char *argv[]) { get_argument_summary(argc, argv, &args); -#ifdef DEBUG - printf("Correct number of command line arguments\n"); - printf("-c: %s -g: %s -f: %s\n", (args.present | ARG_CORE )? "Yes":"No", - (args.present | ARG_GOV )? "Yes":"No", - (args.present | ARG_FREQ )? "Yes":"No" ); - printf("Core: %s\nGov : %s\nFreq: %s\n",args.core,args.governor,args.frequency); -#endif + debug("Correct number of command line arguments\n"); + debug("-c: %s -g: %s -f: %s\n", (args.present | ARG_CORE )? "Yes":"No", + (args.present | ARG_GOV )? "Yes":"No", + (args.present | ARG_FREQ )? "Yes":"No" ); + debug("Core: %s\n",args.core); + debug("Gov : %s\n",args.governor); + debug("Freq: %s\n",args.frequency); if ( args.present == ( ARG_CORE | ARG_GOV ) ) { -#ifdef DEBUG - printf("Changing governor\n"); -#endif + debug("Changing governor\n"); return set_gov(args.governor , args.core); } if ( args.present == ( ARG_CORE | ARG_FREQ ) ) { -#ifdef DEBUG - printf("Changing frequency\n"); -#endif + debug("Changing frequency\n"); return set_gov("userspace", args.core) | set_speed(args.frequency, args.core); } } -#ifdef DEBUG - printf("Fell through, showing command usage\n"); -#endif // Fall through to here if no valid argument combination + debug("Fell through, showing command usage\n"); fprintf(stderr, _("%s {-f frequency|-g governor} -c core\n"), argv[0] ); return 1; } -- cgit v1.1