Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

tuple.h File Reference

Go to the source code of this file.

Data Structures

struct  context
 The information we need to keep track of a client-server connection. More...

struct  element
 The representation of a tuple element in C code, in both the server and a C client. More...

struct  tuple
 An ordered sequence of data values: integers, floats, strings. If this is a template (used during GET and READ operations to match existing tuples), an element can also be a wildcard. More...

struct  tuple_list
 Convenience struct, for when somebody needs to make a quick list of tuples. More...


Defines

#define va_list   __gnuc_va_list
#define _DBG_(x)
#define ASSERT(cond)
#define DBGPRINTF(fmt, a...)
#define TELL(x)   DBGPRINTF(#x " = %d\n", x)
#define MALLOC   malloc
#define FREE   free
#define EXIT()   exit(1)
#define TIMEVAL_DIFF(before, after)
#define SERVERNAME_ENVVAR   "LINUXTUPLES_HOST"
#define PORTNUMBER_ENVVAR   "LINUXTUPLES_PORT"
#define I_AM_A_TUPLE   0x31415926

Enumerations

enum  message_op {
  PUT = 0, GET = 1, READ = 2, GET_NB = 3,
  READ_NB = 4, DUMP = 5, LOG = 6
}

Functions

int get_server_portnumber (struct context *ctx)
void print_element (struct element *e)
void print_tuple (struct tuple *s)
tuplemake_tuple (char *fmt,...)
void destroy_tuple (struct tuple *t)
int tuples_match (struct tuple *s, struct tuple *t)
unsigned int random_int (void)
int send_chunk (struct context *ctx, char *buf, int bytes_to_send)
int send_tuple (struct context *ctx, struct tuple *t)
int recv_chunk (struct context *ctx, char *buf, int size)
tuplerecv_tuple (struct context *ctx)
int put_tuple (struct tuple *s, struct context *ctx)
tupleget_tuple (struct tuple *s, struct context *ctx)
tupleread_tuple (struct tuple *s, struct context *ctx)
tupleget_nb_tuple (struct tuple *s, struct context *ctx)
tupleread_nb_tuple (struct tuple *s, struct context *ctx)
tuple_listdump_tuple_space (struct tuple_list *templates, struct context *ctx)
int tuple_server_log (FILE *stream, struct context *ctx)
int tuple_int_field (struct tuple *s, int n)
double tuple_double_field (struct tuple *s, int n)
char * tuple_string_field (struct tuple *s, int *len, int n)

Variables

int i_am_server
char logbuf [8192]
int logptr


Define Documentation

#define _DBG_  
 

Definition at line 45 of file tuple.h.

#define ASSERT cond   
 

Value:

_DBG_(if (!(cond)) { DBGPRINTF("assert failed: %s\n", \
                                  #cond); exit(1); })

Definition at line 48 of file tuple.h.

#define DBGPRINTF fmt,
a...   
 

Value:

_DBG_(fprintf(stderr, "%d " __FILE__ ":%d " fmt, \
                 debug_counter++, __LINE__, ##a))

Definition at line 52 of file tuple.h.

Referenced by dump_tuple_space, get_tuple, handle_get_read, read_nb_tuple, and read_tuple.

 
#define EXIT      exit(1)
 

Definition at line 85 of file tuple.h.

Referenced by main, make_tuple_internal, recv_tuple, tuple_double_field, tuple_field, tuple_int_field, and tuple_string_field.

#define FREE   free
 

Definition at line 78 of file tuple.h.

#define I_AM_A_TUPLE   0x31415926
 

The only valid value for tuple::tag.

Definition at line 174 of file tuple.h.

Referenced by make_tuple_internal, PyTuple_to_LinuxTuple, and recv_tuple.

#define MALLOC   malloc
 

Definition at line 77 of file tuple.h.

#define PORTNUMBER_ENVVAR   "LINUXTUPLES_PORT"
 

Definition at line 98 of file tuple.h.

Referenced by get_server_portnumber.

#define SERVERNAME_ENVVAR   "LINUXTUPLES_HOST"
 

Definition at line 97 of file tuple.h.

Referenced by get_server_portnumber.

#define TELL      DBGPRINTF(#x " = %d\n", x)
 

Definition at line 56 of file tuple.h.

#define TIMEVAL_DIFF before,
after   
 

Value:

((after.tv_sec - before.tv_sec) + \
        1.0e-6 * (after.tv_usec - before.tv_usec))

Definition at line 90 of file tuple.h.

Referenced by main.

#define va_list   __gnuc_va_list
 

Definition at line 39 of file tuple.h.


Enumeration Type Documentation

enum message_op
 

Enumeration values:
PUT 
GET 
READ 
GET_NB 
READ_NB 
DUMP 
LOG 

Definition at line 100 of file tuple.h.


Function Documentation

void destroy_tuple struct tuple   t
 

Deallocate all the storage for a tuple.

Definition at line 261 of file tuple.c.

Referenced by ctx_get_read, ctx_put_tuple, handle_get_read, and main.

struct tuple_list* dump_tuple_space struct tuple_list   templates,
struct context   ctx
 

Definition at line 753 of file tuple.c.

Referenced by ctx_dump_tuple_space.

struct tuple* get_nb_tuple struct tuple   s,
struct context   ctx
 

Definition at line 681 of file tuple.c.

int get_server_portnumber struct context   ctx
 

Attempt to get the server name and port number from environment variables.

Returns:
0 if successful, 1 otherwise.

Definition at line 81 of file tuple.c.

Referenced by main, and new_ctx.

struct tuple* get_tuple struct tuple   s,
struct context   ctx
 

Definition at line 611 of file tuple.c.

Referenced by main.

struct tuple* make_tuple char *    fmt,
...   
 

Create a tuple or template, starting from a printf-style variable argument list.

Definition at line 246 of file tuple.c.

Referenced by main.

void print_element struct element   e
 

Definition at line 101 of file tuple.c.

References DUMP, GET, GET_NB, LOG, PUT, READ, and READ_NB.

Referenced by print_tuple.

void print_tuple struct tuple   s
 

Definition at line 151 of file tuple.c.

Referenced by tuple_double_field, tuple_int_field, and tuple_string_field.

int put_tuple struct tuple   s,
struct context   ctx
 

Definition at line 583 of file tuple.c.

Referenced by ctx_put_tuple, and main.

unsigned int random_int void   
 

Return a 32-bit random unsigned integer, gotten from /dev/urandom.

Definition at line 326 of file tuple.c.

struct tuple* read_nb_tuple struct tuple   s,
struct context   ctx
 

Definition at line 714 of file tuple.c.

struct tuple* read_tuple struct tuple   s,
struct context   ctx
 

Definition at line 646 of file tuple.c.

int recv_chunk struct context   ctx,
char *    buf,
int    size
 

Definition at line 437 of file tuple.c.

Referenced by client_thread_func, dump_tuple_space, handle_dump_space, put_tuple, and recv_tuple.

struct tuple* recv_tuple struct context   ctx
 

Definition at line 471 of file tuple.c.

Referenced by client_thread_func, dump_tuple_space, get_nb_tuple, get_tuple, handle_dump_space, read_nb_tuple, and read_tuple.

int send_chunk struct context   ctx,
char *    buf,
int    bytes_to_send
 

Definition at line 342 of file tuple.c.

Referenced by dump_tuple_space, get_nb_tuple, get_tuple, handle_dump_space, handle_get_read, put_tuple, read_nb_tuple, read_tuple, send_tuple, and tuple_server_log.

int send_tuple struct context   ctx,
struct tuple   t
 

Definition at line 371 of file tuple.c.

Referenced by dump_tuple_space, get_nb_tuple, get_tuple, handle_dump_space, handle_get_read, put_tuple, read_nb_tuple, and read_tuple.

double tuple_double_field struct tuple   s,
int    n
 

Definition at line 899 of file tuple.c.

int tuple_int_field struct tuple   s,
int    n
 

Definition at line 879 of file tuple.c.

int tuple_server_log FILE *    stream,
struct context   ctx
 

Definition at line 829 of file tuple.c.

Referenced by ctx_tuple_server_log.

char* tuple_string_field struct tuple   s,
int *    len,
int    n
 

Definition at line 919 of file tuple.c.

Referenced by main.

int tuples_match struct tuple   s,
struct tuple   t
 

Definition at line 276 of file tuple.c.

Referenced by handle_dump_space, and handle_get_read.


Variable Documentation

int i_am_server  
 

This flag tells whether or not the current executable is the tuple server. If it is, then broken pipes on sockets should not crash the executable.

Definition at line 267 of file tuple.h.

char logbuf[8192]  
 

Buffer for logging tuple activity.

See also:
tuple_server_log

Definition at line 268 of file tuple.h.

int logptr  
 

Pointer into logbuf.

Definition at line 269 of file tuple.h.


Generated on Sun Mar 30 23:46:51 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002