plugins/xmsg/xmsg.c File Reference

#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <ekg/debug.h>
#include <ekg/dynstuff.h>
#include <ekg/plugins.h>
#include <ekg/protocol.h>
#include <ekg/queries.h>
#include <ekg/stuff.h>
#include <ekg/userlist.h>
#include <ekg/vars.h>
#include <ekg/xmalloc.h>
#include "compat/strlcpy.h"

Defines

#define _GNU_SOURCE
#define _XOPEN_SOURCE   600
#define __BSD_VISIBLE   1
#define NAME_MAX   255
#define __func__   itoa(__LINE__)
#define XMSG_UID_DIROFFSET   5
#define XMSG_NAMESEP_DEF   "."
#define XMSG_MAXFS_DEF   "16384"
#define XMSG_MAXFC_DEF   "25"
#define XMSG_MAXFC_TIMER   "3"
#define XMSG_TMPFILE_PATH   "/tmp/xmsg.XXXXXX"
#define XMSG_TIMER_DEF   "300"
#define xerr(txt,...)   do { debug_error("[xmsg:%s] " txt "\n", __func__, ##__VA_ARGS__); return -1; } while (0)
#define xerrn(txt,...)   do { debug_error("[xmsg:%s] " txt ": %s\n", __func__, ##__VA_ARGS__, strerror(errno)); return -1; } while (0)
#define xdebug(txt,...)   debug("[xmsg:%s] " txt "\n", __func__, ##__VA_ARGS__)
#define xdebug2(lvl, txt,...)   debug_ext(lvl, "[xmsg:%s] " txt "\n", __func__, ##__VA_ARGS__)
#define X(x, y)   (x ? x : y)
#define XMSG_CMDFLAGS   SESSION_MUSTBELONG
#define XMSG_CMDFLAGS_TARGET   SESSION_MUSTBELONG|COMMAND_ENABLEREQPARAMS|COMMAND_PARAMASTARGET|SESSION_MUSTBECONNECTED

Functions

static int xmsg_theme_init (void)
 PLUGIN_DEFINE (xmsg, PLUGIN_PROTOCOL, xmsg_theme_init)
static int xmsg_checkoutfile (const char *file, char **data, int *len, time_t *ts, const int maxlen)
static const char * xmsg_dirfix (const char *path)
static int xmsg_handle_file (session_t *s, const char *fn)
static int xmsg_iterate_dir (int type, session_t *s)
static void xmsg_timer_change (session_t *s, const char *varname)
static int xmsg_disconnect (const char *name, const char **params, session_t *session, const char *target, int quiet)
static int xmsg_handle_sigusr (void *data, va_list ap)
static int xmsg_validate_uid (void *data, va_list ap)
static int xmsg_add_watch (session_t *s, const char *f)
static int xmsg_connect (const char *name, const char **params, session_t *session, const char *target, int quiet)
static int xmsg_reconnect (const char *name, const char **params, session_t *session, const char *target, int quiet)
static void xmsg_unlink_dotfiles (session_t *s, const char *varname)
static int xmsg_msg (const char *name, const char **params, session_t *session, const char *target, int quiet)
static int xmsg_inline_msg (const char *name, const char **params, session_t *session, const char *target, int quiet)
int xmsg_plugin_init (int prio)
static int xmsg_plugin_destroy (void)

Variables

static int in_fd = 0
static struct inotify_event * ev = NULL
static plugins_params_t xmsg_plugin_vars []
static const char * xmsg_protocols [] = { "xmsg:", NULL }
static struct protocol_plugin_priv xmsg_priv

Define Documentation

#define __BSD_VISIBLE   1

#define __func__   itoa(__LINE__)

#define _GNU_SOURCE

#define _XOPEN_SOURCE   600

#define NAME_MAX   255

#define X ( x,
 )     (x ? x : y)

#define xdebug ( txt,
...   )     debug("[xmsg:%s] " txt "\n", __func__, ##__VA_ARGS__)

#define xdebug2 ( lvl,
txt,
...   )     debug_ext(lvl, "[xmsg:%s] " txt "\n", __func__, ##__VA_ARGS__)

#define xerr ( txt,
...   )     do { debug_error("[xmsg:%s] " txt "\n", __func__, ##__VA_ARGS__); return -1; } while (0)

#define xerrn ( txt,
...   )     do { debug_error("[xmsg:%s] " txt ": %s\n", __func__, ##__VA_ARGS__, strerror(errno)); return -1; } while (0)

#define XMSG_CMDFLAGS   SESSION_MUSTBELONG

#define XMSG_CMDFLAGS_TARGET   SESSION_MUSTBELONG|COMMAND_ENABLEREQPARAMS|COMMAND_PARAMASTARGET|SESSION_MUSTBECONNECTED

#define XMSG_MAXFC_DEF   "25"

#define XMSG_MAXFC_TIMER   "3"

#define XMSG_MAXFS_DEF   "16384"

#define XMSG_NAMESEP_DEF   "."

#define XMSG_TIMER_DEF   "300"

#define XMSG_TMPFILE_PATH   "/tmp/xmsg.XXXXXX"

#define XMSG_UID_DIROFFSET   5


Function Documentation

PLUGIN_DEFINE ( xmsg  ,
PLUGIN_PROTOCOL  ,
xmsg_theme_init   
)

static int xmsg_add_watch ( session_t s,
const char *  f 
) [inline, static]

static int xmsg_checkoutfile ( const char *  file,
char **  data,
int *  len,
time_t *  ts,
const int  maxlen 
) [static]

static int xmsg_connect ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
) [static]

static const char* xmsg_dirfix ( const char *  path  )  [static]

static int xmsg_disconnect ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
) [static]

static int xmsg_handle_file ( session_t s,
const char *  fn 
) [static]

static int xmsg_handle_sigusr ( void *  data,
va_list  ap 
) [static]

static int xmsg_inline_msg ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
) [static]

static int xmsg_iterate_dir ( int  type,
session_t s 
) [static]

static int xmsg_msg ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
) [static]

static int xmsg_plugin_destroy ( void   )  [static]

int xmsg_plugin_init ( int  prio  ) 

static int xmsg_reconnect ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
) [static]

static int xmsg_theme_init ( void   )  [static]

static void xmsg_timer_change ( session_t s,
const char *  varname 
) [static]

static void xmsg_unlink_dotfiles ( session_t s,
const char *  varname 
) [static]

static int xmsg_validate_uid ( void *  data,
va_list  ap 
) [static]


Variable Documentation

struct inotify_event* ev = NULL [static]

int in_fd = 0 [static]

plugins_params_t xmsg_plugin_vars[] [static]

Initial value:

 {
        PLUGIN_VAR_ADD("auto_connect",          VAR_BOOL, "1", 0, NULL),
        PLUGIN_VAR_ADD("charset",               VAR_STR, "", 0, NULL),
        PLUGIN_VAR_ADD("dotfile_suffix",        VAR_STR, "", 0, NULL),
        PLUGIN_VAR_ADD("log_formats",           VAR_STR, "simple", 0, NULL),
        PLUGIN_VAR_ADD("max_filesize",          VAR_INT, XMSG_MAXFS_DEF, 0, NULL),
        PLUGIN_VAR_ADD("max_oneshot_files",     VAR_INT, XMSG_MAXFC_DEF, 0, NULL),
        PLUGIN_VAR_ADD("name_separator",        VAR_STR, XMSG_NAMESEP_DEF, 0, NULL),
        PLUGIN_VAR_ADD("oneshot_resume_timer",  VAR_INT, XMSG_MAXFC_TIMER, 0, NULL),
        PLUGIN_VAR_ADD("send_cmd",              VAR_STR, NULL, 0, NULL),
        PLUGIN_VAR_ADD("rescan_timer",          VAR_INT, XMSG_TIMER_DEF, 0, xmsg_timer_change),
        PLUGIN_VAR_ADD("unlink_sent",           VAR_BOOL, "1", 0, xmsg_unlink_dotfiles),
        PLUGIN_VAR_ADD("unlink_toobig",         VAR_BOOL, "0", 0, xmsg_unlink_dotfiles),


}

struct protocol_plugin_priv xmsg_priv [static]

Initial value:

 {
        .protocols      = xmsg_protocols
}

const char* xmsg_protocols[] = { "xmsg:", NULL } [static]


Generated on Mon Jan 5 22:30:55 2009 for ekg2 by  doxygen 1.5.1