aboutsummaryrefslogtreecommitdiff
path: root/trayfreq_set/trayfreq_set.c
diff options
context:
space:
mode:
Diffstat (limited to 'trayfreq_set/trayfreq_set.c')
-rw-r--r--trayfreq_set/trayfreq_set.c48
1 files changed, 16 insertions, 32 deletions
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;
}