paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros
blob.c File Reference

Macros and functions for blob handling. More...

#include <regex.h>
#include <fnmatch.h>
#include <osl.h>
#include <lopsub.h>
#include "server_cmd.lsg.h"
#include "para.h"
#include "error.h"
#include "crypt.h"
#include "string.h"
#include "afh.h"
#include "afs.h"
#include "ipc.h"
#include "portable_io.h"
#include "sideband.h"
#include "command.h"

Macros

#define DEFINE_BLOB_TABLE_DESC(table_name)
 Define an osl table description for a blob table. More...
 
#define DEFINE_BLOB_TABLE_PTR(table_name)   struct osl_table *table_name ## _table;
 Define a pointer to an osl blob table with a canonical name. More...
 
#define INIT_BLOB_TABLE(table_name)
 Define a blob table. More...
 
#define DEFINE_BLOB_COMMAND(cmd_name, c_cmd_name, table_name, short_name, c_short_name)
 
#define DEFINE_GET_NAME_BY_ID(table_name, cmd_prefix)
 Define the get_name_by_id function for this blob type. More...
 
#define DEFINE_GET_DEF_BY_NAME(table_name, cmd_prefix)
 Define the get_def_by_id function for this blob type. More...
 
#define DEFINE_GET_DEF_BY_ID(table_name, cmd_prefix)
 Define the get_def_by_id function for this blob type. More...
 
#define DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, cmd_prefix)
 Define the get_name_and_def_by_row function for this blob type. More...
 
#define DEFINE_BLOB_CLOSE(table_name)
 Define the close function for this blob type. More...
 
#define DEFINE_BLOB_CREATE(table_name)
 Define the create function for this blob type. More...
 
#define DEFINE_BLOB_OPEN(table_name)
 
#define DEFINE_BLOB_AFS_TABLE_OPS(table_name)
 Blob tables map integers to blobs. More...
 
#define DEFINE_BLOB_FUNCTIONS(table_name, short_name, c_short_name)
 Define all functions for this blob type. More...
 

Detailed Description

Macros and functions for blob handling.

Macro Definition Documentation

◆ DEFINE_BLOB_TABLE_DESC

#define DEFINE_BLOB_TABLE_DESC (   table_name)
Value:
static struct osl_table_description table_name ## _table_desc = { \
.name = #table_name, \
.num_columns = NUM_BLOB_COLUMNS, \
.flags = OSL_LARGE_TABLE, \
.column_descriptions = blob_cols \
};

Define an osl table description for a blob table.

◆ DEFINE_BLOB_TABLE_PTR

#define DEFINE_BLOB_TABLE_PTR (   table_name)    struct osl_table *table_name ## _table;

Define a pointer to an osl blob table with a canonical name.

◆ INIT_BLOB_TABLE

#define INIT_BLOB_TABLE (   table_name)
Value:
DEFINE_BLOB_TABLE_DESC(table_name); \
DEFINE_BLOB_TABLE_PTR(table_name);

Define a blob table.

◆ DEFINE_BLOB_COMMAND

#define DEFINE_BLOB_COMMAND (   cmd_name,
  c_cmd_name,
  table_name,
  short_name,
  c_short_name 
)
Value:
static int com_ ## cmd_name ## short_name ## _callback(struct afs_callback_arg *aca) \
{ \
const struct lls_command *cmd = SERVER_CMD_CMD_PTR(c_cmd_name ## c_short_name); \
return com_ ## cmd_name ## blob_callback(cmd, table_name ## _table, aca); \
} \
static int com_ ## cmd_name ## short_name(struct command_context *cc, struct lls_parse_result *lpr) \
{ \
const struct lls_command *cmd = SERVER_CMD_CMD_PTR(c_cmd_name ## c_short_name); \
return com_ ## cmd_name ## blob(com_ ## cmd_name ## short_name ## _callback, cmd, cc, lpr); \
} \
EXPORT_SERVER_CMD_HANDLER(cmd_name ## short_name);

◆ DEFINE_GET_NAME_BY_ID

#define DEFINE_GET_NAME_BY_ID (   table_name,
  cmd_prefix 
)
Value:
int cmd_prefix ## _get_name_by_id(uint32_t id, char **name) \
{ \
return blob_get_name_by_id(table_name ## _table, id, name); \
}

Define the get_name_by_id function for this blob type.

◆ DEFINE_GET_DEF_BY_NAME

#define DEFINE_GET_DEF_BY_NAME (   table_name,
  cmd_prefix 
)
Value:
int cmd_prefix ## _get_def_by_name(const char *name, struct osl_object *def) \
{ \
return blob_get_def_by_name(table_name ## _table, name, def); \
}

Define the get_def_by_id function for this blob type.

◆ DEFINE_GET_DEF_BY_ID

#define DEFINE_GET_DEF_BY_ID (   table_name,
  cmd_prefix 
)
Value:
int cmd_prefix ## _get_def_by_id(uint32_t id, struct osl_object *def) \
{ \
return blob_get_def_by_id(table_name ## _table, id, def); \
}

Define the get_def_by_id function for this blob type.

◆ DEFINE_GET_NAME_AND_DEF_BY_ROW

#define DEFINE_GET_NAME_AND_DEF_BY_ROW (   table_name,
  cmd_prefix 
)
Value:
int cmd_prefix ## _get_name_and_def_by_row(const struct osl_row *row, \
char **name, struct osl_object *def) \
{ \
return blob_get_name_and_def_by_row(table_name ## _table, \
row, name, def); \
}

Define the get_name_and_def_by_row function for this blob type.

◆ DEFINE_BLOB_CLOSE

#define DEFINE_BLOB_CLOSE (   table_name)
Value:
static void table_name ## _close(void) \
{ \
osl_close_table(table_name ## _table, OSL_MARK_CLEAN); \
table_name ## _table = NULL; \
}

Define the close function for this blob type.

◆ DEFINE_BLOB_CREATE

#define DEFINE_BLOB_CREATE (   table_name)
Value:
static int table_name ## _create(const char *dir) \
{ \
table_name ## _table_desc.dir = dir; \
return osl(osl_create_table(&table_name ## _table_desc)); \
}

Define the create function for this blob type.

◆ DEFINE_BLOB_OPEN

#define DEFINE_BLOB_OPEN (   table_name)
Value:
static int table_name ## _open(const char *dir) \
{ \
return blob_open(&table_name ## _table, \
&table_name ## _table_desc, dir); \
}

◆ DEFINE_BLOB_AFS_TABLE_OPS

#define DEFINE_BLOB_AFS_TABLE_OPS (   table_name)
Value:
const struct afs_table_operations table_name ## _ops = { \
.open = table_name ## _open, \
.close = table_name ## _close, \
.create = table_name ## _create, \
.event_handler = table_name ##_event_handler, \
};

Blob tables map integers to blobs.

◆ DEFINE_BLOB_FUNCTIONS

#define DEFINE_BLOB_FUNCTIONS (   table_name,
  short_name,
  c_short_name 
)
Value:
DEFINE_BLOB_OPEN(table_name) \
DEFINE_BLOB_CLOSE(table_name) \
DEFINE_BLOB_CREATE(table_name) \
DEFINE_BLOB_AFS_TABLE_OPS(table_name) \
DEFINE_BLOB_COMMAND(ls, LS, table_name, short_name, c_short_name) \
DEFINE_BLOB_COMMAND(cat, CAT, table_name, short_name, c_short_name) \
DEFINE_BLOB_COMMAND(add, ADD, table_name, short_name, c_short_name) \
DEFINE_BLOB_COMMAND(rm, RM, table_name, short_name, c_short_name) \
DEFINE_BLOB_COMMAND(mv, MV, table_name, short_name, c_short_name) \
DEFINE_GET_NAME_BY_ID(table_name, short_name); \
DEFINE_GET_DEF_BY_ID(table_name, short_name); \
DEFINE_GET_DEF_BY_NAME(table_name, short_name); \
DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, short_name); \

Define all functions for this blob type.

NUM_BLOB_COLUMNS
@ NUM_BLOB_COLUMNS
A blob table has that many columns.
Definition: afs.h:318
osl
_static_inline_ int osl(int ret)
Wrapper for osl library calls.
Definition: error.h:320
DEFINE_BLOB_TABLE_DESC
#define DEFINE_BLOB_TABLE_DESC(table_name)
Define an osl table description for a blob table.
Definition: blob.c:64
afs_callback_arg
Arguments passed to each afs callback.
Definition: afs.h:153
command_context
Per connection data available to command handlers.
Definition: command.h:4
afs_table_operations::open
int(* open)(const char *base_dir)
Gets called on startup and on SIGHUP.
Definition: afs.h:79
SERVER_CMD_CMD_PTR
#define SERVER_CMD_CMD_PTR(_cmd)
Get the lopsub command pointer by command name.
Definition: command.h:35
afs_table_operations
Methods for table startup/shutdown and event handling.
Definition: afs.h:77
DEFINE_BLOB_OPEN
#define DEFINE_BLOB_OPEN(table_name)
Definition: blob.c:620