"Fossies" - the Fresh Open Source Software Archive

Member "netbiff-0.9.18/action.c" (21 Sep 2003, 998 Bytes) of package /linux/privat/old/netbiff-0.9.18.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include "action.h"
    2 #include "xlib.h"
    3 #include "gui.h"
    4 #include "connection.h"
    5 
    6 #include <stdlib.h>
    7 #include <string.h>
    8 
    9 #define MAX_ACTIONS 128
   10 static Action actions[MAX_ACTIONS] = {
   11   { ActionBeep, "beep", NULL },
   12   { ActionImage, "image", NULL },
   13   { ActionImageReset, "image-reset", NULL }
   14 };
   15 int nactions = 3;
   16 
   17 void action_add(ActionType type, const char *tag, const char *cmd) {
   18   actions[nactions].type = type;
   19   actions[nactions].tag = xstrdup(tag);
   20   actions[nactions].cmd = xstrdup(cmd);
   21   nactions++;
   22 }
   23 
   24 const Action *action_find(const char *s) {
   25   int i;
   26   for(i = 0; i < nactions; i++) 
   27     if(!strcasecmp(s, actions[i].tag))
   28       return actions + i;
   29   return NULL;
   30 }
   31 
   32 void action_perform(const Action *a, const Connection *c) {
   33   switch(a->type) {
   34     case ActionBeep:
   35       gui.beep();
   36       break;
   37     case ActionImage:
   38       gui.flagup(c);
   39       break;
   40     case ActionImageReset:
   41       gui.flagdown(c);
   42       break;
   43     case ActionShell:
   44       xsystem(a->cmd);
   45       break;
   46   }
   47 }