wmifs: Use consistent formatting style.

Format to minimize warnings and errors from checkpatch.pl in the Window Maker
source tree.
This commit is contained in:
Doug Torrance 2014-10-22 16:34:43 -05:00 committed by Carlos R. Mafra
parent 6083e3f774
commit c37f6eda98
5 changed files with 323 additions and 304 deletions

View file

@ -38,8 +38,7 @@ Boston, MA 02111-1307, USA. */
/* Return a cons cell produced from (head . tail) */
INLINE LinkedList*
list_cons(void* head, LinkedList* tail)
INLINE LinkedList *list_cons(void *head, LinkedList *tail)
{
LinkedList *cell;
@ -51,12 +50,10 @@ list_cons(void* head, LinkedList* tail)
/* Return the length of a list, list_length(NULL) returns zero */
INLINE int
list_length(LinkedList* list)
INLINE int list_length(LinkedList *list)
{
int i = 0;
while(list)
{
while (list) {
i += 1;
list = list->tail;
}
@ -66,11 +63,9 @@ list_length(LinkedList* list)
/* Return the Nth element of LIST, where N count from zero. If N
larger than the list length, NULL is returned */
INLINE void*
list_nth(int index, LinkedList* list)
{
while(index-- != 0)
INLINE void *list_nth(int index, LinkedList *list)
{
while (index-- != 0) {
if (list->tail)
list = list->tail;
else
@ -81,18 +76,15 @@ list_nth(int index, LinkedList* list)
/* Remove the element at the head by replacing it by its successor */
INLINE void
list_remove_head(LinkedList** list)
{
if (!*list) return;
if ((*list)->tail)
INLINE void list_remove_head(LinkedList **list)
{
if (!*list)
return;
if ((*list)->tail) {
LinkedList *tail = (*list)->tail; /* fetch next */
*(*list) = *tail; /* copy next to list head */
free(tail); /* free next */
}
else /* only one element in list */
{
} else { /* only one element in list */
free(*list);
(*list) = 0;
}
@ -112,8 +104,7 @@ list_remove_elem(LinkedList** list, void* elem)
}
}*/
INLINE LinkedList *
list_remove_elem(LinkedList* list, void* elem)
INLINE LinkedList *list_remove_elem(LinkedList *list, void *elem)
{
LinkedList *tmp;
@ -132,11 +123,9 @@ list_remove_elem(LinkedList* list, void* elem)
/* Return element that has ELEM as car */
INLINE LinkedList*
list_find(LinkedList* list, void* elem)
{
while(list)
INLINE LinkedList *list_find(LinkedList *list, void *elem)
{
while (list) {
if (list->head == elem)
return list;
list = list->tail;
@ -146,11 +135,9 @@ list_find(LinkedList* list, void* elem)
/* Free list (backwards recursive) */
INLINE void
list_free(LinkedList* list)
{
if(list)
INLINE void list_free(LinkedList *list)
{
if (list) {
list_free(list->tail);
free(list);
}
@ -158,11 +145,9 @@ list_free(LinkedList* list)
/* Map FUNCTION over all elements in LIST */
INLINE void
list_mapcar(LinkedList* list, void(*function)(void*))
{
while(list)
INLINE void list_mapcar(LinkedList *list, void(*function)(void *))
{
while (list) {
(*function)(list->head);
list = list->tail;
}

View file

@ -52,7 +52,7 @@ static DFA mtable[9][6] = {
{{-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* final state */
{{6, 1}, {6, 1}, {7, 0}, {6, 1}, {5, 0}, {3, 0} },
{{6, 1}, {6, 1}, {6, 1}, {6, 1}, {5, 0}, {6, 1} },
{{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
{{-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } /* final state */
};
char*
@ -87,10 +87,9 @@ next_token(char *word, char **next)
}
state = mtable[state][ctype].nstate;
ptr++;
if (mtable[state][0].output<0) {
if (mtable[state][0].output < 0)
break;
}
}
if (*ret == 0)
t = NULL;
@ -118,9 +117,8 @@ parse_command(char *command, char ***argv, int *argc)
line = command;
do {
token = next_token(line, &line);
if (token) {
if (token)
list = list_cons(token, list);
}
} while (token != NULL && line != NULL);
count = list_length(list);
@ -142,20 +140,19 @@ execCommand(char *command)
parse_command(command, &argv, &argc);
if (argv==NULL) {
if (argv == NULL)
return 0;
}
if ((pid=fork())==0) {
pid = fork();
if (pid == 0) {
char **args;
int i;
args = malloc(sizeof(char *)*(argc+1));
if (!args)
exit(10);
for (i=0; i<argc; i++) {
for (i = 0; i < argc; i++)
args[i] = argv[i];
}
args[argc] = NULL;
execvp(argv[0], args);
exit(10);

View file

@ -80,7 +80,8 @@ int CheckMouseRegion(int, int);
|* read_rc_file *|
\*******************************************************************************/
void parse_rcfile(const char *filename, rckeys *keys) {
void parse_rcfile(const char *filename, rckeys *keys)
{
char *p;
char temp[128];
@ -93,14 +94,18 @@ void parse_rcfile(const char *filename, rckeys *keys) {
while (fgets(temp, 128, fp)) {
key = 0;
while (key >= 0 && keys[key].label) {
if ((p = strstr(temp, keys[key].label))) {
p = strstr(temp, keys[key].label);
if (p) {
p += strlen(keys[key].label);
p += strspn(p, tokens);
if ((i = strcspn(p, "#\n"))) p[i] = 0;
i = strcspn(p, "#\n");
if (i)
p[i] = 0;
free(*keys[key].var);
*keys[key].var = strdup(p);
key = -1;
} else key++;
} else
key++;
}
}
fclose(fp);
@ -112,7 +117,8 @@ void parse_rcfile(const char *filename, rckeys *keys) {
|* GetXPM *|
\*******************************************************************************/
static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[])
{
XWindowAttributes attributes;
int err;
@ -135,7 +141,8 @@ static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
|* GetColor *|
\*******************************************************************************/
static Pixel GetColor(char *name) {
static Pixel GetColor(char *name)
{
XColor color;
XWindowAttributes attributes;
@ -143,11 +150,10 @@ static Pixel GetColor(char *name) {
XGetWindowAttributes(display, Root, &attributes);
color.pixel = 0;
if (!XParseColor(display, attributes.colormap, name, &color)) {
if (!XParseColor(display, attributes.colormap, name, &color))
fprintf(stderr, "wm.app: can't parse %s.\n", name);
} else if (!XAllocColor(display, attributes.colormap, &color)) {
else if (!XAllocColor(display, attributes.colormap, &color))
fprintf(stderr, "wm.app: can't allocate %s.\n", name);
}
return color.pixel;
}
@ -155,7 +161,8 @@ static Pixel GetColor(char *name) {
|* flush_expose *|
\*******************************************************************************/
static int flush_expose(Window w) {
static int flush_expose(Window w)
{
XEvent dummy;
int i = 0;
@ -170,7 +177,8 @@ static int flush_expose(Window w) {
|* RedrawWindow *|
\*******************************************************************************/
void RedrawWindow(void) {
void RedrawWindow(void)
{
flush_expose(iconwin);
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
@ -184,7 +192,8 @@ void RedrawWindow(void) {
|* RedrawWindowXY *|
\*******************************************************************************/
void RedrawWindowXY(int x, int y) {
void RedrawWindowXY(int x, int y)
{
flush_expose(iconwin);
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
@ -198,7 +207,8 @@ void RedrawWindowXY(int x, int y) {
|* AddMouseRegion *|
\*******************************************************************************/
void AddMouseRegion(int index, int left, int top, int right, int bottom) {
void AddMouseRegion(int index, int left, int top, int right, int bottom)
{
if (index < MAX_MOUSE_REGION) {
mouse_region[index].enable = 1;
@ -213,7 +223,8 @@ void AddMouseRegion(int index, int left, int top, int right, int bottom) {
|* CheckMouseRegion *|
\*******************************************************************************/
int CheckMouseRegion(int x, int y) {
int CheckMouseRegion(int x, int y)
{
int i;
int found;
@ -228,7 +239,8 @@ int CheckMouseRegion(int x, int y) {
y >= mouse_region[i].top)
found = 1;
}
if (!found) return -1;
if (!found)
return -1;
return (i-1);
}
@ -236,7 +248,8 @@ int CheckMouseRegion(int x, int y) {
|* copyXPMArea *|
\*******************************************************************************/
void copyXPMArea(int x, int y, int sx, int sy, int dx, int dy) {
void copyXPMArea(int x, int y, int sx, int sy, int dx, int dy)
{
XCopyArea(display, wmgen.pixmap, wmgen.pixmap, NormalGC, x, y, sx, sy, dx, dy);
@ -246,7 +259,8 @@ void copyXPMArea(int x, int y, int sx, int sy, int dx, int dy) {
|* copyXBMArea *|
\*******************************************************************************/
void copyXBMArea(int x, int y, int sx, int sy, int dx, int dy) {
void copyXBMArea(int x, int y, int sx, int sy, int dx, int dy)
{
XCopyArea(display, wmgen.mask, wmgen.pixmap, NormalGC, x, y, sx, sy, dx, dy);
}
@ -256,7 +270,8 @@ void copyXBMArea(int x, int y, int sx, int sy, int dx, int dy) {
|* setMaskXY *|
\*******************************************************************************/
void setMaskXY(int x, int y) {
void setMaskXY(int x, int y)
{
XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, ShapeSet);
XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, ShapeSet);
@ -265,7 +280,9 @@ void setMaskXY(int x, int y) {
/*******************************************************************************\
|* openXwindow *|
\*******************************************************************************/
void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
void openXwindow(int argc, char *argv[], char *pixmap_bytes[],
char *pixmask_bits, int pixmask_width, int pixmask_height)
{
unsigned int borderwidth = 1;
XClassHint classHint;
@ -285,7 +302,8 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
display_name = argv[i+1];
}
if (!(display = XOpenDisplay(display_name))) {
display = XOpenDisplay(display_name);
if (!display) {
fprintf(stderr, "%s: can't open display %s\n",
wname, XDisplayName(display_name));
exit(1);
@ -324,8 +342,10 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
classHint.res_class = wname;
XSetClassHint(display, win, &classHint);
XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
XSelectInput(display, win,
ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
XSelectInput(display, iconwin,
ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
if (XStringListToTextProperty(&wname, 1, &name) == 0) {
fprintf(stderr, "%s: can't allocate window name\n", wname);

View file

@ -290,7 +290,8 @@ void get_ppp_stats(struct ppp_stats *cur);
/* Main */
/********/
int main(int argc, char *argv[]) {
int main(int argc, char *argv[])
{
int i;
@ -368,7 +369,8 @@ int get_statistics(char *, long *, long *, long *, long *);
int stillonline(char *);
void DrawActiveIFS(char *);
void wmifs_routine(int argc, char **argv) {
void wmifs_routine(int argc, char **argv)
{
rckeys wmifs_keys[] = {
{ "left", &left_action },
@ -416,9 +418,12 @@ void wmifs_routine(int argc, char **argv) {
}
}
if (LEFT_ACTION) left_action = strdup(LEFT_ACTION);
if (MIDDLE_ACTION) middle_action = strdup(MIDDLE_ACTION);
if (RIGHT_ACTION) right_action = strdup(RIGHT_ACTION);
if (LEFT_ACTION)
left_action = strdup(LEFT_ACTION);
if (MIDDLE_ACTION)
middle_action = strdup(MIDDLE_ACTION);
if (RIGHT_ACTION)
right_action = strdup(RIGHT_ACTION);
/* Scan throught the .rc files */
parse_rcfile("/etc/wmifsrc", wmifs_keys);
@ -459,11 +464,10 @@ void wmifs_routine(int argc, char **argv) {
if (i == stat_current) {
if (!stillonline(stat_devices[i].name)) {
if (!stillonline(stat_devices[i].name))
SetErrLED(LED_NET_POWER);
} else {
else
SetOnLED(LED_NET_POWER);
}
if (stat_devices[i].istatlast == istat)
SetOffLED(LED_NET_RX);
@ -522,13 +526,13 @@ void wmifs_routine(int argc, char **argv) {
stat_online = checknetdevs();
stat_current = 0;
for (i = 0; i < stat_online; i++) {
if (!strcmp(temp, stat_devices[i].name)) {
if (!strcmp(temp, stat_devices[i].name))
stat_current = i;
}
}
stat_current++;
if (stat_current == stat_online) stat_current = 0;
if (stat_current == stat_online)
stat_current = 0;
DrawActiveIFS(stat_devices[stat_current].name);
@ -567,7 +571,8 @@ void wmifs_routine(int argc, char **argv) {
|* void DrawActiveIFS(char *) *|
\*******************************************************************************/
void DrawActiveIFS(char *real_name) {
void DrawActiveIFS(char *real_name)
{
/* Cijfers op: 0,65
Letters op: 0,75
@ -588,16 +593,17 @@ void DrawActiveIFS(char *real_name) {
strcpy(name, real_name);
len = strlen(name);
if (len > 5)
{
for (i=len-5; i<len && !(name[i]>='0' && name[i]<='9'); i++) ;
if (len > 5) {
for (i = len-5; i < len && !(name[i] >= '0' && name[i] <= '9'); i++)
;
for (; i <= len; i++) /* '=' to get the '\0' character moved too \*/
name[i-(len-5)] = name[i];
}
k = 5;
for (i = 0; name[i]; i++) {
if (i == strlen(name)-1 && strlen(name) <= 4 && name[strlen(name)-1] >= '0' && name[strlen(name)-1] <= '9') {
if (i == strlen(name)-1 && strlen(name) <= 4 && name[strlen(name)-1] >= '0' &&
name[strlen(name)-1] <= '9') {
copyXPMArea(61, 64, 4, 9, k, 5);
k += 4;
}
@ -619,7 +625,8 @@ void DrawActiveIFS(char *real_name) {
|* get_statistics *|
\*******************************************************************************/
int get_statistics(char *devname, long *ip, long *op, long *is, long *os) {
int get_statistics(char *devname, long *ip, long *op, long *is, long *os)
{
FILE *fp;
char temp[BUFFER_SIZE];
@ -629,14 +636,15 @@ int get_statistics(char *devname, long *ip, long *op, long *is, long *os) {
int i;
int found;
struct ppp_stats ppp_cur, ppp_old;
static int ppp_opened = 0;
static int ppp_opened;
if (!strncmp(devname, "ppp", 3)) {
if (!ppp_opened) {
/* Open the ppp device. */
memset(&ppp_cur, 0, sizeof(ppp_cur));
if ((ppp_h = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
ppp_h = socket(AF_INET, SOCK_DGRAM, 0);
if (ppp_h < 0)
return -1;
get_ppp_stats(&ppp_cur);
ppp_old = ppp_cur;
@ -667,8 +675,10 @@ int get_statistics(char *devname, long *ip, long *op, long *is, long *os) {
p = strtok(temp, tokens);
do {
if (!(strcmp(p, "packets"))) {
if (input == -1) input = i;
else output = i;
if (input == -1)
input = i;
else
output = i;
}
i++;
p = strtok(NULL, tokens);
@ -702,7 +712,8 @@ int get_statistics(char *devname, long *ip, long *op, long *is, long *os) {
|* stillonline *|
\*******************************************************************************/
int stillonline(char *ifs) {
int stillonline(char *ifs)
{
FILE *fp;
char temp[BUFFER_SIZE];
@ -726,7 +737,8 @@ int stillonline(char *ifs) {
|* checknetdevs *|
\*******************************************************************************/
int checknetdevs(void) {
int checknetdevs(void)
{
FILE *fd;
char temp[BUFFER_SIZE];
@ -737,9 +749,8 @@ int checknetdevs(void) {
char *tokens = " :\t\n";
char foundbuffer[MAX_STAT_DEVICES][8];
for (i=0; i<MAX_STAT_DEVICES; i++) {
for (i = 0; i < MAX_STAT_DEVICES; i++)
foundbuffer[i][0] = 0;
}
/* foundbuffer vullen met info uit /proc/net/dev */
@ -785,7 +796,8 @@ int checknetdevs(void) {
foundbuffer[j][0] = 0;
}
}
if (!k) stat_devices[i].name[0] = 0;
if (!k)
stat_devices[i].name[0] = 0;
}
}
@ -794,10 +806,9 @@ int checknetdevs(void) {
while (!stat_devices[j].name[0] && j < MAX_STAT_DEVICES)
j++;
if (j < MAX_STAT_DEVICES && i != j) {
if (j < MAX_STAT_DEVICES && i != j)
stat_devices[i] = stat_devices[j];
}
}
i--;
for (j = 0; j < MAX_STAT_DEVICES; j++) {
@ -837,7 +848,8 @@ int checknetdevs(void) {
|* DrawStats *|
\*******************************************************************************/
void DrawStats(int *his, int num, int size, int x_left, int y_bottom) {
void DrawStats(int *his, int num, int size, int x_left, int y_bottom)
{
int pixels_per_byte;
int j, k;
@ -894,7 +906,8 @@ void DrawStats(int *his, int num, int size, int x_left, int y_bottom) {
|* usage *|
\*******************************************************************************/
void usage(void) {
void usage(void)
{
fprintf(stderr, "\nwmifs - programming: tijno, (de)bugging & design: warpstah, webhosting: bobby\n\n");
fprintf(stderr, "usage:\n");
@ -913,7 +926,8 @@ void usage(void) {
|* printversion *|
\*******************************************************************************/
void printversion(void) {
void printversion(void)
{
fprintf(stderr, "%s\n", WMIFS_VERSION);
}
@ -922,7 +936,8 @@ void printversion(void) {
|* get_ppp_stats *|
\*******************************************************************************/
void get_ppp_stats(struct ppp_stats *cur) {
void get_ppp_stats(struct ppp_stats *cur)
{
struct ifpppstatsreq req;
@ -932,9 +947,8 @@ void get_ppp_stats(struct ppp_stats *cur) {
sprintf(req.ifr__name, "ppp%d", PPP_UNIT);
if (ioctl(ppp_h, SIOCGPPPSTATS, &req) < 0) {
/* fprintf(stderr, "heyho!\n"); */
}
if (ioctl(ppp_h, SIOCGPPPSTATS, &req) < 0)
/* fprintf(stderr, "heyho!\n") */;
*cur = req.stats;
}
@ -965,7 +979,8 @@ void get_ppp_stats(struct ppp_stats *cur) {
/*******************************************************************************\
|* SetOnLED *|
\*******************************************************************************/
void SetOnLED(int led) {
void SetOnLED(int led)
{
switch (led) {
@ -984,7 +999,8 @@ void SetOnLED(int led) {
/*******************************************************************************\
|* SetOffLED *|
\*******************************************************************************/
void SetOffLED(int led) {
void SetOffLED(int led)
{
switch (led) {
@ -1003,7 +1019,8 @@ void SetOffLED(int led) {
/*******************************************************************************\
|* SetErrLED *|
\*******************************************************************************/
void SetErrLED(int led) {
void SetErrLED(int led)
{
switch (led) {
case LED_NET_POWER: