Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

tuple.c File Reference

#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sched.h>
#include "tuple.h"

Go to the source code of this file.

Defines

#define PERROR(x)   fprintf(stderr, __FILE__":%d ", __LINE__); perror(x)

Functions

int get_server_portnumber (struct context *ctx)
void print_element (struct element *e)
void print_tuple (struct tuple *s)
tuplemake_tuple_internal (char *fmt, va_list ap)
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 open_client_socket (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)
elementtuple_field (struct tuple *s, int n)
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 = 0
char logbuf [8192]
int logptr = 0


Define Documentation

#define PERROR      fprintf(stderr, __FILE__":%d ", __LINE__); perror(x)
 

Definition at line 71 of file tuple.c.

Referenced by dump_tuple_space, get_nb_tuple, get_tuple, make_tuple_internal, open_client_socket, put_tuple, read_nb_tuple, read_tuple, recv_chunk, recv_tuple, send_chunk, send_tuple, and tuple_server_log.


Function Documentation

void destroy_tuple struct tuple   t
 

Deallocate all the storage for a tuple.

Definition at line 261 of file tuple.c.

References tuple::elements, and tuple::string_space.

struct tuple_list* dump_tuple_space struct tuple_list   templates,
struct context   ctx
 

Definition at line 753 of file tuple.c.

References DBGPRINTF, DUMP, tuple_list::next, open_client_socket, PERROR, recv_chunk, recv_tuple, send_chunk, send_tuple, and tuple_list::tup.

struct tuple* get_nb_tuple struct tuple   s,
struct context   ctx
 

Definition at line 681 of file tuple.c.

References GET_NB, open_client_socket, PERROR, recv_tuple, send_chunk, and send_tuple.

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.

References context::portnumber, PORTNUMBER_ENVVAR, context::servername, and SERVERNAME_ENVVAR.

struct tuple* get_tuple struct tuple   s,
struct context   ctx
 

Definition at line 611 of file tuple.c.

References DBGPRINTF, GET, open_client_socket, PERROR, recv_tuple, send_chunk, and send_tuple.

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.

References make_tuple_internal.

struct tuple* make_tuple_internal char *    fmt,
va_list    ap
[static]
 

Definition at line 182 of file tuple.c.

References element::data, tuple::elements, EXIT, I_AM_A_TUPLE, tuple::num_elts, PERROR, tuple::string_space, element::tag, and tuple::tag.

Referenced by make_tuple.

int open_client_socket struct context   ctx [static]
 

Definition at line 545 of file tuple.c.

References PERROR, context::portnumber, context::servername, and context::sock.

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

void print_element struct element   e
 

Definition at line 101 of file tuple.c.

References element::data, logbuf, logptr, and element::tag.

void print_tuple struct tuple   s
 

Definition at line 151 of file tuple.c.

References tuple::elements, logbuf, logptr, tuple::num_elts, and print_element.

int put_tuple struct tuple   s,
struct context   ctx
 

Definition at line 583 of file tuple.c.

References open_client_socket, PERROR, PUT, recv_chunk, send_chunk, send_tuple, and context::sock.

unsigned int random_int void   
 

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

Definition at line 326 of file tuple.c.

Referenced by main, and py_random_int.

struct tuple* read_nb_tuple struct tuple   s,
struct context   ctx
 

Definition at line 714 of file tuple.c.

References DBGPRINTF, open_client_socket, PERROR, READ_NB, recv_tuple, send_chunk, and send_tuple.

struct tuple* read_tuple struct tuple   s,
struct context   ctx
 

Definition at line 646 of file tuple.c.

References DBGPRINTF, open_client_socket, PERROR, READ, recv_tuple, send_chunk, and send_tuple.

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

Definition at line 437 of file tuple.c.

References i_am_server, PERROR, and context::sock.

struct tuple* recv_tuple struct context   ctx
 

Definition at line 471 of file tuple.c.

References element::data, tuple::elements, EXIT, I_AM_A_TUPLE, tuple::num_elts, PERROR, recv_chunk, tuple::string_length, tuple::string_space, element::tag, and tuple::tag.

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

Definition at line 342 of file tuple.c.

References PERROR, and context::sock.

int send_tuple struct context   ctx,
struct tuple   t
 

Definition at line 371 of file tuple.c.

References element::data, tuple::elements, tuple::num_elts, PERROR, send_chunk, and element::tag.

double tuple_double_field struct tuple   s,
int    n
 

Definition at line 899 of file tuple.c.

References element::data, EXIT, logbuf, logptr, print_tuple, element::tag, and tuple_field.

struct element* tuple_field struct tuple   s,
int    n
[static]
 

Definition at line 864 of file tuple.c.

References EXIT.

Referenced by tuple_double_field, tuple_int_field, and tuple_string_field.

int tuple_int_field struct tuple   s,
int    n
 

Definition at line 879 of file tuple.c.

References element::data, EXIT, logbuf, logptr, print_tuple, element::tag, and tuple_field.

int tuple_server_log FILE *    stream,
struct context   ctx
 

Definition at line 829 of file tuple.c.

References LOG, open_client_socket, PERROR, send_chunk, and context::sock.

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

Definition at line 919 of file tuple.c.

References element::data, EXIT, logbuf, logptr, print_tuple, element::tag, and tuple_field.

int tuples_match struct tuple   s,
struct tuple   t
 

Definition at line 276 of file tuple.c.

References element::data, tuple::elements, tuple::num_elts, and element::tag.


Variable Documentation

int i_am_server = 0
 

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 55 of file tuple.c.

Referenced by recv_chunk.

char logbuf[8192]
 

Buffer for logging tuple activity.

See also:
tuple_server_log

Definition at line 65 of file tuple.c.

Referenced by print_element, print_tuple, tuple_double_field, tuple_int_field, and tuple_string_field.

int logptr = 0
 

Pointer into logbuf.

Definition at line 69 of file tuple.c.

Referenced by print_element, print_tuple, tuple_double_field, tuple_int_field, and tuple_string_field.


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