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 macs' internal workings, you're probably looking for libmacs.h. More...

#include <libgdome/gdome.h>

Go to the source code of this file.

Data Structures

struct  _macs_sock_struct
 #include for gdome functionality 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 _macs_sock_struct _macs_sock
 #include for gdome functionality

typedef _macs_context_struct _macs_ctx
 The structure of the macs context object.


Functions

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

char * _macs_util_itoa (long int i)
 Converts a digit 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_svr2str (int server)
 Converts a server spec into the appropriate string.


Detailed Description

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

Id:
common.h,v 1.2 2002/07/27 02:12:41 santana Exp


Define Documentation

#define _macs_free_reply R,
 
 

Value:

if (R) { free(*R); 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 struct _macs_sock_struct _macs_sock
 

#include for gdome functionality

Linked list of sockets to auth servers

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 returned by a successful call to macs_init() and is passed as the first argument to other API calls.


Function Documentation

int _macs_connect_socks _macs_ctx   ctx,
int    servers
 

Find good, working servers and brings up connections to them.

Parameters:
ctx  A _macs_ctx pointer from macs_init.
servers  The types of servers to connect to. An ORing of MACS_AUS, MACS_ATS, MACS_UPS, and MACS_ALL
Returns:
1 on success, 0 on failure

_macs_sock* _macs_get_sock const _macs_ctx   ctx,
int    server
 

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

Parameters:
ctx  A _macs_ctx pointer.
server  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_ctx   ctx,
int    servers
 

Releases memory associated with the sockets.

Parameters:
ctx  An opaque _macs_ctx pointer from macs_init.
servers  The types of servers to connect to. An ORing of MACS_AUS, MACS_ATS, MACS_UPS, and MACS_ALL
Returns:
1 on success, 0 on failure

int _macs_add_server _macs_ctx   ctx,
const char *    addr,
int    stype
 

Adds a server to the context.

Parameters:
ctx  A _macs_ctx pointer from macs_init.
addr  The address to add, in host:port form
stype  The type of server to add. One of MACS_AUS, MACS_UPS, or MACS_ATS

int _macs_do_ping _macs_sock   s,
int    server
 

Pings a server to test for connectivity.

Parameters:
s  The connected _macs_sock pointing at the server to test
server  The type of server to ping. One of MACS_AUS, MACS_UPS 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 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
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.

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 a digit 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_svr2str int    server
 

Converts a server spec into the appropriate string.

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


Generated on Tue Oct 8 22:15:53 2002 for MACS Client C API by doxygen1.2.16