[uicb] Use bool instead of int for returning status

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-04-30 12:02:37 +02:00
parent 6f409e39d0
commit 3f23635a33
2 changed files with 22 additions and 21 deletions

39
uicb.c
View File

@ -138,9 +138,9 @@ uicb_spawn(int screen, char *arg)
/** Run the uicb.
* \param cmd The uicb command to parse.
* \return 0 on succes, -1 on failure.
* \return true on succes, false on failure.
*/
static int
static bool
__uicb_run(char *cmd)
{
char *p, *argcpy;
@ -154,27 +154,27 @@ __uicb_run(char *cmd)
if (!p)
{
warn("ignoring malformed command\n");
return -1;
return false;
}
screen = atoi(cmd);
if(screen >= globalconf.screens_info->nscreen || screen < 0)
{
warn("invalid screen specified: %i\n", screen);
return -1;
return false;
}
p = strtok(NULL, " ");
if (!p)
{
warn("ignoring malformed command.\n");
return -1;
return false;
}
uicb = name_func_lookup(p, UicbList);
if (!uicb)
{
warn("unknown uicb function: %s.\n", p);
return -1;
return false;
}
if (p + a_strlen(p) < cmd + len)
@ -190,29 +190,28 @@ __uicb_run(char *cmd)
else
uicb(screen, NULL);
return 0;
return true;
}
/** Parse a command.
* \param cmd the buffer
* \return 0 on succes, -1 on failure
* \param cmd The buffer to parse.
* \return true on succes, false on failure.
*/
int
bool
__uicb_parsecmd(char *cmd)
{
char *p, *curcmd = cmd;
bool ret = false;
if(!a_strlen(cmd))
return -1;
if(a_strlen(cmd))
while((p = strchr(curcmd, '\n')))
{
*p = '\0';
ret = __uicb_run(curcmd);
curcmd = p + 1;
}
while((p = strchr(curcmd, '\n')))
{
*p = '\0';
__uicb_run(curcmd);
curcmd = p + 1;
}
return 0;
return ret;
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

4
uicb.h
View File

@ -22,9 +22,11 @@
#ifndef AWESOME_UICB_H
#define AWESOME_UICB_H
#include <stdbool.h>
typedef void (uicb_t)(int, char *);
int __uicb_parsecmd(char *);
bool __uicb_parsecmd(char *);
uicb_t uicb_restart;
uicb_t uicb_exec;