hash_add(columns, vec[0], &c, HASH_INSERT_OR_REPLACE);
}
+/** @brief Definition of an option command */
static struct option {
+ /** @brief Command name */
const char *name;
- int minargs, maxargs;
+ /** @brief Minimum number of arguments */
+ int minargs;
+ /** @brief Maximum number of arguments */
+ int maxargs;
+ /** @brief Command handler */
void (*handler)(int nvec, char **vec);
} options[] = {
{ "columns", 1, INT_MAX, option__columns },
exit(EXIT_FAILURE);
}
-static const struct command {
+/** @brief Command-line client's definition of a command */
+static const struct client_command {
+ /** @brief Command name */
const char *name;
- int min, max;
+
+ /** @brief Minimum number of argument */
+ int min;
+
+ /** @brief Maximum number of argument */
+ int max;
+
+ /** @brief Pointer to function implementing command */
void (*fn)(char **);
+
+ /** @brief Function to recognize a valid argument, or NULL */
int (*isarg)(const char *);
- const char *argstr, *desc;
+
+ /** @brief Summary of arguments */
+ const char *argstr;
+
+ /** @brief Description */
+ const char *desc;
} commands[] = {
{ "adduser", 2, 3, cf_adduser, isarg_rights, "USERNAME PASSWORD [RIGHTS]",
"Create a new user" },
/* Count of errors */
static long errors;
-/* Included/excluded filename patterns */
+/** @brief Included/excluded filename pattern */
static struct pattern {
struct pattern *next;
const char *pattern;
#include "disobedience.h"
#include "table.h"
+/** @brief Embedded image */
struct image {
+ /** @brief Image name */
const char *name;
+ /** @brief Image data in GDK pixbuf inline format */
const guint8 *data;
};
struct collection *s;
};
+/** @brief A track name part */
struct namepart {
char *part; /* part */
pcre *re; /* compiled regexp */
unsigned reflags; /* regexp flags */
};
+/** @brief A list of track name parts */
struct namepartlist {
int n;
struct namepart *s;
};
+/** @brief A track name transform */
struct transform {
char *type; /* track or dir */
char *context; /* sort or choose */
unsigned flags; /* regexp flags */
};
+/** @brief A list of track name transforms */
struct transformlist {
int n;
struct transform *t;
#include "eventdist.h"
#include "hash.h"
+/** @brief Event data
+ *
+ * @c event_data structures form linked lists; one list per event and one node
+ * per handler.
+ */
struct event_data {
+ /** @brief Next handler */
struct event_data *next;
+
+ /** @brief Name of event */
const char *event;
+
+ /** @brief Handler callback */
event_handler *callback;
+
+ /** @brief Passed to @ref callback */
void *callbackdata;
};
#include "eventlog.h"
#include "split.h"
+/** @brief Linked list of event logs */
static struct eventlog_output *outputs;
void eventlog_add(struct eventlog_output *lo) {
*pp = lo->next;
}
+/** @brief Write to the event log
+ * @param keyword Distinguishing keyword for event
+ * @param raw Unformatted data
+ * @param ap Extra data, terminated by (char *)0
+ */
static void veventlog(const char *keyword, const char *raw, va_list ap) {
struct eventlog_output *p, *pnext;
struct dynstr d;
#ifndef EVENTLOG_H
#define EVENTLOG_H
-/* definition of an event log output. The caller must allocate these
- * (since log.c isn't allowed to perform memory allocation). */
+/** @brief An output for the event log
+ *
+ * The caller must allocate these (since log.c isn't allowed to perform memory
+ * allocation). They form a linked list, using eventlog_add() and
+ * eventlog_remove().
+ */
struct eventlog_output {
+ /** @brief Next output */
struct eventlog_output *next;
+
+ /** @brief Handler for this output */
void (*fn)(const char *msg, void *user);
+
+ /** @brief Passed to @ref fn */
void *user;
};
+/** @brief Add an event log output
+ * @param lo Pointer to output to add
+ */
void eventlog_add(struct eventlog_output *lo);
-/* add a log output */
+/** @brief Remove an event log output
+ * @param lo Pointer to output to remove
+ */
void eventlog_remove(struct eventlog_output *lo);
-/* remove a log output */
+/** @brief Send a message to the event log
+ * @param keyword Distinguishing keyword for event
+ * @param ... Extra data, terminated by (char *)0
+ */
void eventlog(const char *keyword, ...);
+
+/** @brief Send a message to the event log
+ * @param keyword Distinguishing keyword for event
+ * @param raw Unformatted data
+ * @param ... Extra data, terminated by (char *)0
+ */
void eventlog_raw(const char *keyword, const char *raw, ...);
-/* send a message to the event log */
#endif /* EVENTLOG_H */
#include "log.h"
#include "kvp.h"
+/** @brief One entry in a hash table */
struct entry {
struct entry *next; /* next entry same key */
size_t h; /* hash of KEY */
void *value; /* value of this entry */
};
+/** @brief A hash table */
struct hash {
size_t nslots; /* number of slots */
size_t nitems; /* total number of entries */
#define F(n, h) { #n, offsetof(struct queue_entry, n), marshall_##h, unmarshall_##h, free_##h }
-static const struct field {
+/** @brief A field in a @ref queue_entry */
+static const struct queue_field {
+ /** @brief Field name */
const char *name;
+
+ /** @brief Offset of value in @ref queue_entry structure */
size_t offset;
+
+ /** @brief Marshaling function */
const char *(*marshall)(const struct queue_entry *q, size_t offset);
+
+ /** @brief Unmarshaling function */
int (*unmarshall)(char *data, struct queue_entry *q, size_t offset,
void (*error_handler)(const char *, void *),
void *u);
+
+ /** @brief Destructor */
void (*free)(struct queue_entry *q, size_t offset);
} fields[] = {
/* Keep this table sorted. */
#include "printf.h"
#include "sink.h"
+/** @brief A @ref sink that stores to a fixed buffer
+ *
+ * If there is too much output, it is truncated.
+ */
struct fixedstr_sink {
+ /** @brief Base */
struct sink s;
+
+ /** @brief Output buffer */
char *buffer;
+
+ /** @brief Bytes written so far */
int nbytes;
+
+ /** @brief Size of buffer */
size_t size;
};
#include <langinfo.h>
#include "strptime.h"
+/** @brief Lookup table entry for locale-specific strings */
struct locale_item_match {
+ /** @brief Locale key to try */
nl_item key;
+
+ /** @brief Value to return if value of @ref key matches subject string */
int value;
};
/* libFLAC's "simplified" interface is rather heavyweight... */
+/** @brief State used when computing FLAC file length */
struct flac_state {
+ /** @brief Duration or -1 */
long duration;
+
+ /** @brief File being analyzed */
const char *path;
};
return 1;
}
-static const struct command {
+/** @brief Server's definition of a command */
+static const struct server_command {
/** @brief Command name */
const char *name;