Add a warn utility function, and use it to improve error reporting in run_uicb.
This commit is contained in:
parent
f5372a7252
commit
64117935c8
16
uicb.c
16
uicb.c
|
@ -106,18 +106,26 @@ run_uicb(char *cmd, awesome_config *awesomeconf)
|
||||||
|
|
||||||
len = strlen(cmd);
|
len = strlen(cmd);
|
||||||
p = strtok(cmd, " ");
|
p = strtok(cmd, " ");
|
||||||
if (!p)
|
if (!p){
|
||||||
|
warn("Ignoring malformed command\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
screen = atoi(cmd);
|
screen = atoi(cmd);
|
||||||
if(screen >= get_screen_count(awesomeconf->display) || screen < 0)
|
if(screen >= get_screen_count(awesomeconf->display) || screen < 0){
|
||||||
|
warn("Invalid screen specified: %i\n", screen);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
p = strtok(NULL, " ");
|
p = strtok(NULL, " ");
|
||||||
if (!p)
|
if (!p){
|
||||||
|
warn("Ignoring malformed command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
uicb = name_func_lookup(p, UicbList);
|
uicb = name_func_lookup(p, UicbList);
|
||||||
if (!uicb)
|
if (!uicb){
|
||||||
|
warn("Unknown UICB function: %s.\n", p);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (p+strlen(p) < cmd+len)
|
if (p+strlen(p) < cmd+len)
|
||||||
arg = p + strlen(p) + 1;
|
arg = p + strlen(p) + 1;
|
||||||
|
|
10
util.c
10
util.c
|
@ -50,6 +50,16 @@ eprint(const char *fmt, ...)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
warn(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
fprintf(stderr, "awesome: ");
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
compute_new_value_from_arg(const char *arg, double current_value)
|
compute_new_value_from_arg(const char *arg, double current_value)
|
||||||
{
|
{
|
||||||
|
|
1
util.h
1
util.h
|
@ -201,6 +201,7 @@ static inline ssize_t a_strcat(char *dst, ssize_t n, const char *src)
|
||||||
void die(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
void die(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
||||||
void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
||||||
double compute_new_value_from_arg(const char *, double);
|
double compute_new_value_from_arg(const char *, double);
|
||||||
|
void warn(const char *, ...) __attribute__ ((format(printf, 1, 2)));
|
||||||
void *name_func_lookup(const char *, const NameFuncLink *);
|
void *name_func_lookup(const char *, const NameFuncLink *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue