#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>Go to the source code of this file.
Classes | |
| struct | ngcb_pipe_t |
| struct | ngcb_saddr_cache |
Macros | |
| #define | str2str(s1, s2, n) |
| #define | ngcbTAG_SUCCESS "!SUCCESS!\n" |
| #define | ngcbTAG_ERROR "!ERROR!\n" |
| #define | ngcbADDR_CACHE_SIZE 8 |
Functions | |
| void | ngcbRegisterLock (void(*lock)(void), void(*unlock)(void)) |
| void | ngcbLock (void) |
| void | ngcbUnlock (void) |
| void | ngcbIpAddrCache (int flag) |
| int | ngcbGetHost (const char *name, char *ipAddr, char *hostName, char *erms) |
| int | ngcbGetHostName (char *name, int size) |
| int | ngcbGetIpAddr (const char *name, char *ipAddr, char *erms) |
| int | ngcbSocketPort (int fd) |
| void | ngcbSocketHost (int fd, char *ipAddr) |
| int | ngcbSocketWait (int fd, int timeout, char *erms) |
| int | ngcbSocketWaitIntr (int fd1, int fd2, int timeout, char *erms) |
| int | ngcbSocketPair (int fd[2], int bufferSize, char *erms) |
| int | ngcbHostCompare (const char *host1, const char *host2) |
| int | ngcbTcpService (const char *service, char *erms) |
| int | ngcbTcpAccept (int fd, char *erms) |
| int | ngcbTcpConnect (const char *service, char *erms) |
| int | ngcbTcpConnectTmo (const char *service, int tmo, char *erms) |
| int | ngcbTcpClose (int fd) |
| int | ngcbTcpWrite (int fd, const void *buffer, size_t size, char *erms) |
| int | ngcbTcpRead (int fd, void *buffer, size_t size, char *erms) |
| void | ngcbPipeInit (ngcb_pipe_t *p) |
| int | ngcbPipeOpen (const char *cmd, ngcb_pipe_t *p, char *erms) |
| void | ngcbPipeClose (ngcb_pipe_t *p) |
| void | ngcbPipeError (char *erms, int n, ngcb_pipe_t *p) |
| int | ngcbPipeIn (const char *cmd, char *msg, int n) |
| int | ngcbAddr (int fd, int board, int addr, int *buffer, int size, char *erms) |
| #define ngcbADDR_CACHE_SIZE 8 |
Default IP-address cache size
| #define ngcbTAG_ERROR "!ERROR!\n" |
ERROR reply
| #define ngcbTAG_SUCCESS "!SUCCESS!\n" |
SUCCESS reply
| #define str2str | ( | s1, | |
| s2, | |||
| n ) |
| int ngcbAddr | ( | int | fd, |
| int | board, | ||
| int | addr, | ||
| int * | buffer, | ||
| int | size, | ||
| char * | erms ) |
Remote address access
| int ngcbGetHost | ( | const char * | name, |
| char * | ipAddr, | ||
| char * | hostName, | ||
| char * | erms ) |
Convert name to ip-address if name is a hostname or converts name to hostname, if name is an ip-address.
| int ngcbGetHostName | ( | char * | name, |
| int | size ) |
Returns the host name of the calling host. The maximum length of the name is given by size.
| int ngcbGetIpAddr | ( | const char * | name, |
| char * | ipAddr, | ||
| char * | erms ) |
Converts name to an ip-address.
| int ngcbHostCompare | ( | const char * | host1, |
| const char * | host2 ) |
Check, whether two hosts are identical. The function returns zero if the comparison was successfull, otherwise a non-zero value is returned.
| void ngcbIpAddrCache | ( | int | flag | ) |
Enable/disable IP-address cache.
| void ngcbLock | ( | void | ) |
Lock - using the registered functions
| void ngcbPipeClose | ( | ngcb_pipe_t * | p | ) |
Close the pipe and terminates the executed process.
| void ngcbPipeError | ( | char * | erms, |
| int | n, | ||
| ngcb_pipe_t * | p ) |
Read the stderr output of the executed process up to a length of n-1 characters. The returned error message is then terminated with a null character.
| int ngcbPipeIn | ( | const char * | cmd, |
| char * | msg, | ||
| int | n ) |
Read up to n-1 characters from stdout of cmd, put them to msg and add a terminating NULL character. If an error occurs, stderr is read in the same way and copied to msg. In case of error the function returns (-1), otherwise zero is returned.
| void ngcbPipeInit | ( | ngcb_pipe_t * | p | ) |
Initialize/reset pipe structure.
| int ngcbPipeOpen | ( | const char * | cmd, |
| ngcb_pipe_t * | p, | ||
| char * | erms ) |
Execute command as a child process and create a pipe between caller and executed process.
| void ngcbRegisterLock | ( | void(* | lock )(void), |
| void(* | unlock )(void) ) |
Register locking functions
| void ngcbSocketHost | ( | int | fd, |
| char * | ipAddr ) |
Returns the peer (remote) ipAddr (as string) associated with a socket.
| int ngcbSocketPair | ( | int | fd[2], |
| int | bufferSize, | ||
| char * | erms ) |
Create a pair of connected UNIX-domain sockets.
| int ngcbSocketPort | ( | int | fd | ) |
Return the port number associated with a socket. If the socket is not valid zero is returned.
| int ngcbSocketWait | ( | int | fd, |
| int | timeout, | ||
| char * | erms ) |
Wait with timeout (in millisconds) for a socket to become readable. A negative value means no-timeout.
| int ngcbSocketWaitIntr | ( | int | fd1, |
| int | fd2, | ||
| int | timeout, | ||
| char * | erms ) |
Waits with timeout (in millisconds) for socket fd1 or fd2 to become readable. A negative value means no-timeout. If a timeout occurs, the value -1 is returned. If socket fd2 becomes readable first, the value -2 is returned (interrupted).
| int ngcbTcpAccept | ( | int | fd, |
| char * | erms ) |
Accept a tcp/ip client connection request and return the client socket.
| int ngcbTcpClose | ( | int | fd | ) |
Close tcp/ip socket.
| int ngcbTcpConnect | ( | const char * | service, |
| char * | erms ) |
Connect to a tcp/ip socket service specified in the format "host:port". The function returns a client socket descriptor.
| int ngcbTcpConnectTmo | ( | const char * | service, |
| int | tmo, | ||
| char * | erms ) |
Cnnects to a tcp/ip socket service specified in the format "host:port". The function returns a client socket descriptor. The connect timeout is given in seconds. Zero or a negavitve number falls back to the default connection timeout as provided by the OS.
| int ngcbTcpRead | ( | int | fd, |
| void * | buffer, | ||
| size_t | size, | ||
| char * | erms ) |
Read size bytes of from tcp/ip socket into buffer.
| int ngcbTcpService | ( | const char * | service, |
| char * | erms ) |
Open a tcp/ip server socket.
| int ngcbTcpWrite | ( | int | fd, |
| const void * | buffer, | ||
| size_t | size, | ||
| char * | erms ) |
Write size bytes of buffer to tcp/ip socket.
| void ngcbUnlock | ( | void | ) |
Unlock - using the registered functions