BRL-CAD
pkg.c File Reference
#include "common.h"
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <windows.h>
#include <io.h>
#include <fcntl.h>
#include <errno.h>
#include "pkg.h"
Include dependency graph for pkg.c:

Go to the source code of this file.

Macros

#define PKG_READ(d, buf, nbytes)   read((d), (buf), (nbytes))
 
#define PKG_SEND(d, buf, nbytes)   write((d), (buf), (nbytes))
 
#define PKG_CK(p)
 
#define MAXQLEN   512 /* largest packet we will queue on stream */
 
#define DMSG(s)   if (_pkg_debug) { _pkg_timestamp(); fprintf(_pkg_debug, "%s", s); fflush(_pkg_debug); }
 
#define MAX_PKG_ERRBUF_SIZE   80
 

Functions

unsigned short pkg_gshort (char *buf)
 
unsigned long pkg_glong (char *buf)
 
char * pkg_pshort (char *buf, unsigned short s)
 
char * pkg_plong (char *buf, unsigned long l)
 
struct pkg_connpkg_open (const char *host, const char *service, const char *protocol, const char *uname, const char *passwd, const struct pkg_switch *switchp, void(*errlog)(const char *msg))
 
struct pkg_connpkg_transerver (const struct pkg_switch *switchp, void(*errlog)(const char *))
 
int pkg_permserver (const char *service, const char *protocol, int backlog, void(*errlog)(const char *msg))
 
int pkg_permserver_ip (const char *ipOrHostname, const char *service, const char *protocol, int backlog, void(*errlog)(const char *msg))
 
struct pkg_connpkg_getclient (int fd, const struct pkg_switch *switchp, void(*errlog)(const char *msg), int nodelay)
 
void pkg_close (struct pkg_conn *pc)
 
int pkg_send (int type, const char *buf, size_t len, struct pkg_conn *pc)
 
int pkg_2send (int type, const char *buf1, size_t len1, const char *buf2, size_t len2, struct pkg_conn *pc)
 
int pkg_stream (int type, const char *buf, size_t len, struct pkg_conn *pc)
 
int pkg_flush (struct pkg_conn *pc)
 
int pkg_waitfor (int type, char *buf, size_t len, struct pkg_conn *pc)
 
char * pkg_bwaitfor (int type, struct pkg_conn *pc)
 
int pkg_process (struct pkg_conn *pc)
 
int pkg_block (struct pkg_conn *pc)
 
int pkg_suckin (struct pkg_conn *pc)
 

Variables

int pkg_nochecking = 0
 
int pkg_permport = 0
 

Detailed Description

LIBPKG provides routines to manage multiplexing and de-multiplexing synchronous and asynchronous messages across stream connections.

Definition in file pkg.c.

Macro Definition Documentation

#define PKG_READ (   d,
  buf,
  nbytes 
)    read((d), (buf), (nbytes))

Definition at line 118 of file pkg.c.

Referenced by pkg_suckin().

#define PKG_SEND (   d,
  buf,
  nbytes 
)    write((d), (buf), (nbytes))

Definition at line 119 of file pkg.c.

Referenced by pkg_2send(), and pkg_send().

#define PKG_CK (   p)
Value:
{ \
if (p==PKC_NULL||p->pkc_magic!=PKG_MAGIC) { \
snprintf(_pkg_errbuf, MAX_PKG_ERRBUF_SIZE, "%s: bad pointer %p line %d\n", __FILE__, (void *)(p), __LINE__); \
_pkg_errlog(_pkg_errbuf);abort(); \
} \
}
#define MAX_PKG_ERRBUF_SIZE
Definition: pkg.c:145
if(share_geom)
Definition: nmg_mod.c:3829
#define PKG_MAGIC
Definition: pkg.h:71
#define PKC_NULL
Definition: pkg.h:103

Definition at line 122 of file pkg.c.

Referenced by pkg_2send(), pkg_block(), pkg_bwaitfor(), pkg_close(), pkg_process(), pkg_send(), pkg_suckin(), and pkg_waitfor().

#define MAXQLEN   512 /* largest packet we will queue on stream */

Definition at line 129 of file pkg.c.

Referenced by pkg_send(), and pkg_stream().

#define DMSG (   s)    if (_pkg_debug) { _pkg_timestamp(); fprintf(_pkg_debug, "%s", s); fflush(_pkg_debug); }

Definition at line 133 of file pkg.c.

Referenced by pkg_process().

#define MAX_PKG_ERRBUF_SIZE   80

Function Documentation

struct pkg_conn* pkg_open ( const char *  host,
const char *  service,
const char *  protocol,
const char *  uname,
const char *  passwd,
const struct pkg_switch switchp,
void(*)(const char *msg)  errlog 
)

Definition at line 343 of file pkg.c.

References MAX_PKG_ERRBUF_SIZE, memset(), and PKC_ERROR.

Here is the call graph for this function:

struct pkg_conn* pkg_transerver ( const struct pkg_switch switchp,
void(*)(const char *)  errlog 
)

Definition at line 501 of file pkg.c.

int pkg_permserver ( const char *  service,
const char *  protocol,
int  backlog,
void(*)(const char *msg)  errlog 
)

Definition at line 693 of file pkg.c.

int pkg_permserver_ip ( const char *  ipOrHostname,
const char *  service,
const char *  protocol,
int  backlog,
void(*)(const char *msg)  errlog 
)

Definition at line 702 of file pkg.c.

struct pkg_conn* pkg_getclient ( int  fd,
const struct pkg_switch switchp,
void(*)(const char *msg)  errlog,
int  nodelay 
)

Definition at line 724 of file pkg.c.

References PKC_ERROR, and PKC_NULL.

Variable Documentation

int pkg_nochecking = 0

Definition at line 142 of file pkg.c.

int pkg_permport = 0

Definition at line 143 of file pkg.c.