ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbSocket.h
Go to the documentation of this file.
1
8#ifndef ngcbSocket_h
9#define ngcbSocket_h
10
11
12
13#include <stdio.h>
14#include <stdlib.h>
15#include <unistd.h>
16#include <string.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
25#ifndef str2str
26static __inline__ char *__str2str(char *s1, const char *s2, size_t n)
27{
28 size_t size = strlen(s2);
29 if (n > size) n = size;
30 memcpy(s1, s2, n);
31 s1[n] = '\0';
32 return (s1);
33}
34#define str2str(s1, s2, n) __str2str(s1, s2, n)
35#endif
36
40#define ngcbTAG_SUCCESS "!SUCCESS!\n"
41
45#define ngcbTAG_ERROR "!ERROR!\n"
46
50typedef struct {
51 int fd[3];
52 FILE *pipeIn;
53 FILE *pipeOut;
54 FILE *pipeErr;
55 int pid;
56 int stat;
58
62typedef struct {
63 char hostName[64];
64 char ipAddr[32];
66
70#define ngcbADDR_CACHE_SIZE 8
71
72/*
73 * Prototypes
74 */
75
79void ngcbRegisterLock(void (*lock)(void), void (*unlock)(void));
80
84void ngcbLock(void);
85
89void ngcbUnlock(void);
90
94void ngcbIpAddrCache(int flag);
95
100int ngcbGetHost(const char *name, char *ipAddr, char *hostName, char *erms);
101
106int ngcbGetHostName(char *name, int size);
107
111int ngcbGetIpAddr(const char *name, char *ipAddr, char *erms);
112
117int ngcbSocketPort(int fd);
118
123void ngcbSocketHost(int fd, char *ipAddr);
124
129int ngcbSocketWait(int fd, int timeout, char *erms);
130
137int ngcbSocketWaitIntr(int fd1, int fd2, int timeout, char *erms);
138
142int ngcbSocketPair(int fd[2], int bufferSize, char *erms);
143
148int ngcbHostCompare(const char *host1, const char *host2);
149
153int ngcbTcpService(const char *service, char *erms);
154
158int ngcbTcpAccept(int fd, char *erms);
159
164int ngcbTcpConnect(const char *service, char *erms);
165
172int ngcbTcpConnectTmo(const char *service, int tmo, char *erms);
173
177int ngcbTcpClose(int fd);
178
182int ngcbTcpWrite(int fd, const void *buffer, size_t size, char *erms);
183
187int ngcbTcpRead(int fd, void *buffer, size_t size, char *erms);
188
193
198int ngcbPipeOpen(const char *cmd, ngcb_pipe_t *p, char *erms);
199
204
210void ngcbPipeError(char *erms, int n, ngcb_pipe_t *p);
211
218int ngcbPipeIn(const char *cmd, char *msg, int n);
219
223int ngcbAddr(int fd, int board, int addr, int *buffer, int size, char *erms);
224
225
226#ifdef __cplusplus
227}
228#endif
229
230#endif
int ngcbGetHostName(char *name, int size)
Definition ngcbSocket.c:79
int ngcbSocketWaitIntr(int fd1, int fd2, int timeout, char *erms)
Definition ngcbSocket.c:274
int ngcbTcpConnect(const char *service, char *erms)
Definition ngcbTcp.c:186
int ngcbSocketPort(int fd)
Definition ngcbSocket.c:202
void ngcbPipeClose(ngcb_pipe_t *p)
Definition ngcbPipe.c:262
int ngcbPipeOpen(const char *cmd, ngcb_pipe_t *p, char *erms)
Definition ngcbPipe.c:80
void ngcbUnlock(void)
Definition ngcbSocket.c:68
int ngcbTcpClose(int fd)
Definition ngcbTcp.c:402
int ngcbHostCompare(const char *host1, const char *host2)
Definition ngcbSocket.c:357
void ngcbRegisterLock(void(*lock)(void), void(*unlock)(void))
Definition ngcbSocket.c:58
void ngcbLock(void)
Definition ngcbSocket.c:63
int ngcbTcpWrite(int fd, const void *buffer, size_t size, char *erms)
Definition ngcbTcp.c:460
void ngcbPipeInit(ngcb_pipe_t *p)
Definition ngcbPipe.c:68
int ngcbTcpService(const char *service, char *erms)
Definition ngcbTcp.c:39
int ngcbGetHost(const char *name, char *ipAddr, char *hostName, char *erms)
Definition ngcbSocket.c:95
void ngcbSocketHost(int fd, char *ipAddr)
Definition ngcbSocket.c:221
int ngcbSocketPair(int fd[2], int bufferSize, char *erms)
Definition ngcbSocket.c:322
int ngcbAddr(int fd, int board, int addr, int *buffer, int size, char *erms)
Definition ngcbAddr.c:122
int ngcbTcpRead(int fd, void *buffer, size_t size, char *erms)
Definition ngcbTcp.c:415
void ngcbIpAddrCache(int flag)
Definition ngcbSocket.c:73
int ngcbTcpAccept(int fd, char *erms)
Definition ngcbTcp.c:135
int ngcbTcpConnectTmo(const char *service, int tmo, char *erms)
Definition ngcbTcp.c:287
int ngcbGetIpAddr(const char *name, char *ipAddr, char *erms)
Definition ngcbSocket.c:137
void ngcbPipeError(char *erms, int n, ngcb_pipe_t *p)
Definition ngcbPipe.c:315
int ngcbSocketWait(int fd, int timeout, char *erms)
Definition ngcbSocket.c:242
int ngcbPipeIn(const char *cmd, char *msg, int n)
Definition ngcbPipe.c:355
Definition ngcbSocket.h:50
FILE * pipeIn
Definition ngcbSocket.h:52
FILE * pipeOut
Definition ngcbSocket.h:53
int pid
Definition ngcbSocket.h:55
int fd[3]
Definition ngcbSocket.h:51
FILE * pipeErr
Definition ngcbSocket.h:54
int stat
Definition ngcbSocket.h:56
Definition ngcbSocket.h:62
char ipAddr[32]
Definition ngcbSocket.h:64
char hostName[64]
Definition ngcbSocket.h:63