Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

common.h File Reference

Header for internal-only MACS functionality. Unless you're interested in libmacs' internal workings, you're probably looking for libmacs.h. More...

Go to the source code of this file.

Data Structures

struct  _macs_sock_struct
struct  _macs_cfgs_struct
struct  _macs_session_struct
 The structure of the macs internal session object. More...

struct  _macs_context_struct
 The structure of the macs context object. More...


Defines

#define _macs_free_reply(R, M)
 Releases the memory associated with a reply.

#define _macs_close_sock(S)   if (S) S->isup=S->in_use=0;
 Unlocks and closes a socket.

#define _macs_free_sock(S)   if (S) S->in_use=0;
 Unlocks a socket.


Typedefs

typedef enum _macs_conn_type_enum _macs_conn_type
typedef _macs_sock_struct _macs_sock
typedef _macs_cfgs_struct _macs_cfgs
typedef _macs_session_struct _macs_sess
 The structure of the macs internal session object.

typedef _macs_context_struct _macs_ctx
 The structure of the macs context object.


Enumerations

enum  _macs_conn_type_enum { MACS_UNDEF = 0, MACS_UNIX, MACS_TCP }

Functions

void _macs_clean_sess (macs_session *sess)
 Make existing sess as if it just came from macs_new_sess().

int _macs_parse_cf (macs_session *sess)
void _macs_free_cfgs (_macs_cfgs **cfgs)
int _macs_connect_sock (macs_session *sess, int svc)
 Establishes a connection to the server.

_macs_sock_macs_get_sock (macs_session *sess, int svc)
int _macs_free_socks (_macs_sock **ctx)
int _macs_add_server (_macs_ctx *ctx, const char *addr, const _macs_conn_type type)
int _macs_do_ping (_macs_sock *s, macs_session *sess, int server)
int _macs_write (_macs_sock *s, const void *morsel, size_t siz, const char *svc, const char *cmd, const macs_session *sess, const char *meth,...)
int _macs_read (_macs_sock *s, char **reply[], char **morsel)
 Reads a reply.

char * _macs_util_itoa (long int i)
 Converts an integer number to a string.

char * _macs_util_ftoa (double i)
 Converts a floating-point number to a string.

char * _macs_util_adm2str (char **R, char *M)
 Converts a reply's morsel into a string.

char * _macs_util_type2str (macs_profile_type type)
 Converts a macs_profile_type into the appropriate string.

char * _macs_util_svc2str (int svc)
 Converts a server spec into the appropriate string.


Detailed Description

Header for internal-only MACS functionality. Unless you're interested in libmacs' internal workings, you're probably looking for libmacs.h.

Id
common.h,v 1.11 2003/08/06 11:46:22 blake Exp

Define Documentation

#define _macs_free_reply R,
 
 

Value:

if (R) { free(R[2]); free(R); R=NULL; } \
    if (M) { free(M); M=NULL; }
Releases the memory associated with a reply.

Parameters:
R the reply to release
M the morsel to release

#define _macs_close_sock      if (S) S->isup=S->in_use=0;
 

Unlocks and closes a socket.

Parameters:
S The socket to unlock and close

#define _macs_free_sock      if (S) S->in_use=0;
 

Unlocks a socket.

Parameters:
S The socket to unlock


Typedef Documentation

typedef enum _macs_conn_type_enum _macs_conn_type
 

Enumerates the possible types of connections to the server.

typedef struct _macs_sock_struct _macs_sock
 

Linked list of sockets to auth servers

typedef struct _macs_cfgs_struct _macs_cfgs
 

Doubly-linked tree of configuration data. Represents config.xml

typedef struct _macs_session_struct _macs_sess
 

The structure of the macs internal session object.

This structure is holds non-user-servicable session information. An (opaque) instance of it is stored in macs_session pointers returned by successful calls to macs_init() and macs_new_sess()

typedef struct _macs_context_struct _macs_ctx
 

The structure of the macs context object.

This structure is holds the state of the macs library. An (opaque) instance of it is stored in macs_session pointers returned by successful calls to macs_init() and macs_new_sess()


Enumeration Type Documentation

enum _macs_conn_type_enum
 

Enumerates the possible types of connections to the server.

Enumeration values:
MACS_UNDEF  Denotes an uninitialized socket.
MACS_UNIX  Denotes a unix-domain socket connection.
MACS_TCP  Denotes an INET-domain (tcp) socket connection.


Function Documentation

void _macs_clean_sess macs_session   sess
 

Make existing sess as if it just came from macs_new_sess().

Parameters:
sess A MACS session

int _macs_parse_cf macs_session   sess
 

Parse the config file and set up the cfgs in the given ctx.

Parameters:
ctx The context to configure. ctx->cf needs to be initted.
Returns:
0 on failure, 1 on success

void _macs_free_cfgs _macs_cfgs **    cfgs
 

Free all data associated with the passed configuration tree.

Parameters:
cfgs A pointer-to-pointer of _macs_cfgs

int _macs_connect_sock macs_session   sess,
int    svc
 

Establishes a connection to the server.

Parameters:
sess The macs_session to work with.
svc Services that need to be available for connection to be considered successful. Logical ORing of MACS_ATS, MACS_AUS and MACS_RPS.
Returns:
1 on success, 0 on failure

_macs_sock* _macs_get_sock macs_session   sess,
int    svc
 

Finds a connected _macs_sock from the given list, or connects one.

Parameters:
ctx A _macs_ctx pointer.
svc The server-type of the socket to return. One of MACS_AUS, MACS_ATS, or MACS_UPS
Returns:
The connected _macs_sock, or NULL on failure

int _macs_free_socks _macs_sock **    ctx
 

Releases memory associated with the sockets.

Parameters:
ctx An opaque pointer-to-pointer of _macs_sock
Returns:
1 on success, 0 on failure

int _macs_add_server _macs_ctx   ctx,
const char *    addr,
const _macs_conn_type    type
 

Adds a server to the context.

Parameters:
ctx A _macs_ctx pointer from macs_init.
addr The address to add. If type is MACS_TCP, in host:port form; if type is MACS_UNIX, then a path, absolute or relative to MACS_HOME.
type The type of connection to make. One of MACS_TCP or MACS_UNIX

int _macs_do_ping _macs_sock   s,
macs_session   sess,
int    server
 

Pings a server to test for connectivity.

Parameters:
s The connected _macs_sock pointing at the server to test
sess The macs_session to work with.
server The type of server to ping. One of MACS_MUX, MACS_AUS, MACS_RPS or MACS_ATS
Returns:
1 on success, 0 on failure

int _macs_write _macs_sock   s,
const void *    morsel,
size_t    siz,
const char *    svc,
const char *    cmd,
const macs_session   sess,
const char *    meth,
...   
 

Write to the _macs_sock

Parameters:
s The _macs_sock to write to
morsel The data morsel
siz The size of the data morsel in bytes
svc The service to speak to
cmd The command to give the service
sess A MACS session
meth The method to apply to the command.
... A NULL-terminated list of command-specific words to be written consecutively.
Returns:
1 on success, 0 on failure
None of the words (svc, cmd, ...) may have spaces. This is not checked but it will break the protocol. The session information in the sess parameter will be used in the protocol. Absent uid and skey data will be replaced with "0"

int _macs_read _macs_sock   s,
char **    reply[],
char **    morsel
 

Reads a reply.

Parameters:
s The _macs_sock to read from.
reply A pointer to an array of strings. The reply will be stored here.
morsel A pointer-to-pointer to the morsel.
Returns:
1 on success, 0 on failure
Note:
After success, _macs_free_reply(reply,morsel) should be called to free resources.
This routine reads a reply from the given socket, including the data morsel, if any. The reply itself is broken into words and stored as an array of strings.

char* _macs_util_itoa long int    i
 

Converts an integer number to a string.

Parameters:
i the number to convert
Returns:
The converted string. free() it.

char* _macs_util_ftoa double    i
 

Converts a floating-point number to a string.

Parameters:
i the number to convert
Returns:
The converted string. free() it.

char* _macs_util_adm2str char **    R,
char *    M
 

Converts a reply's morsel into a string.

Parameters:
R The reply from _macs_read()
M The morsel from _macs_read()
Returns:
The morsel as as string (free() it), or NULL on failure.

char* _macs_util_type2str macs_profile_type    type
 

Converts a macs_profile_type into the appropriate string.

Parameters:
type The type to convert
Returns:
The type as a string (free() it), or NULL on failure

char* _macs_util_svc2str int    svc
 

Converts a server spec into the appropriate string.

Parameters:
svc One of MACS_MUX, MACS_AUS, MACS_RPS or MACS_ATS
Returns:
The server spec as a string (free() it), or NULL on failure


Generated on Fri Aug 8 09:53:44 2003 for MACS Client C API by doxygen1.3-rc3