ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcbSocket.h
Go to the documentation of this file.
1
7#ifndef ngcbSocket_h
8#define ngcbSocket_h
9
10
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <unistd.h>
15#include <string.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
24#ifndef str2str
25static __inline__ char *__str2str(char *s1, const char *s2, size_t n)
26{
27 size_t size = strlen(s2);
28 if (n > size) n = size;
29 memcpy(s1, s2, n);
30 s1[n] = '\0';
31 return (s1);
32}
33#define str2str(s1, s2, n) __str2str(s1, s2, n)
34#endif
35
39#define ngcbTAG_SUCCESS "!SUCCESS!\n"
40
44#define ngcbTAG_ERROR "!ERROR!\n"
45
49typedef struct {
50 int fd[3];
51 FILE *pipeIn;
52 FILE *pipeOut;
53 FILE *pipeErr;
54 int pid;
56
60typedef struct {
61 char hostName[64];
62 char ipAddr[32];
64
68#define ngcbADDR_CACHE_SIZE 8
69
70/*
71 * Prototypes
72 */
73
77void ngcbRegisterLock(void (*lock)(void), void (*unlock)(void));
78
82void ngcbLock(void);
83
87void ngcbUnlock(void);
88
92void ngcbIpAddrCache(int flag);
93
98int ngcbGetHost(const char *name, char *ipAddr, char *hostName, char *erms);
99
104int ngcbGetHostName(char *name, int size);
105
109int ngcbGetIpAddr(const char *name, char *ipAddr, char *erms);
110
115int ngcbSocketPort(int fd);
116
121void ngcbSocketHost(int fd, char *ipAddr);
122
127int ngcbSocketWait(int fd, int timeout, char *erms);
128
135int ngcbSocketWaitIntr(int fd1, int fd2, int timeout, char *erms);
136
140int ngcbSocketPair(int fd[2], int bufferSize, char *erms);
141
145int ngcbTcpService(const char *service, char *erms);
146
150int ngcbTcpAccept(int fd, char *erms);
151
156int ngcbTcpConnect(const char *service, char *erms);
157
164int ngcbTcpConnectTmo(const char *service, int tmo, char *erms);
165
169int ngcbTcpClose(int fd);
170
174int ngcbTcpWrite(int fd, const void *buffer, size_t size, char *erms);
175
179int ngcbTcpRead(int fd, void *buffer, size_t size, char *erms);
180
185
190int ngcbPipeOpen(const char *cmd, ngcb_pipe_t *p, char *erms);
191
196
202void ngcbPipeError(char *erms, int n, ngcb_pipe_t *p);
203
210int ngcbPipeIn(const char *cmd, char *msg, int n);
211
215int ngcbAddr(int fd, int board, int addr, int *buffer, int size, char *erms);
216
217
218#ifdef __cplusplus
219}
220#endif
221
222#endif
int ngcbGetHostName(char *name, int size)
Definition ngcbSocket.c:78
int ngcbSocketWaitIntr(int fd1, int fd2, int timeout, char *erms)
Definition ngcbSocket.c:273
int ngcbTcpConnect(const char *service, char *erms)
Definition ngcbTcp.c:185
int ngcbSocketPort(int fd)
Definition ngcbSocket.c:201
void ngcbPipeClose(ngcb_pipe_t *p)
Definition ngcbPipe.c:260
int ngcbPipeOpen(const char *cmd, ngcb_pipe_t *p, char *erms)
Definition ngcbPipe.c:78
void ngcbUnlock(void)
Definition ngcbSocket.c:67
int ngcbTcpClose(int fd)
Definition ngcbTcp.c:401
void ngcbRegisterLock(void(*lock)(void), void(*unlock)(void))
Definition ngcbSocket.c:57
void ngcbLock(void)
Definition ngcbSocket.c:62
int ngcbTcpWrite(int fd, const void *buffer, size_t size, char *erms)
Definition ngcbTcp.c:459
void ngcbPipeInit(ngcb_pipe_t *p)
Definition ngcbPipe.c:67
int ngcbTcpService(const char *service, char *erms)
Definition ngcbTcp.c:38
int ngcbGetHost(const char *name, char *ipAddr, char *hostName, char *erms)
Definition ngcbSocket.c:94
void ngcbSocketHost(int fd, char *ipAddr)
Definition ngcbSocket.c:220
int ngcbSocketPair(int fd[2], int bufferSize, char *erms)
Definition ngcbSocket.c:321
int ngcbAddr(int fd, int board, int addr, int *buffer, int size, char *erms)
Definition ngcbAddr.c:121
int ngcbTcpRead(int fd, void *buffer, size_t size, char *erms)
Definition ngcbTcp.c:414
void ngcbIpAddrCache(int flag)
Definition ngcbSocket.c:72
int ngcbTcpAccept(int fd, char *erms)
Definition ngcbTcp.c:134
int ngcbTcpConnectTmo(const char *service, int tmo, char *erms)
Definition ngcbTcp.c:286
int ngcbGetIpAddr(const char *name, char *ipAddr, char *erms)
Definition ngcbSocket.c:136
void ngcbPipeError(char *erms, int n, ngcb_pipe_t *p)
Definition ngcbPipe.c:296
int ngcbSocketWait(int fd, int timeout, char *erms)
Definition ngcbSocket.c:241
int ngcbPipeIn(const char *cmd, char *msg, int n)
Definition ngcbPipe.c:336
Definition ngcbSocket.h:49
FILE * pipeIn
Definition ngcbSocket.h:51
FILE * pipeOut
Definition ngcbSocket.h:52
int pid
Definition ngcbSocket.h:54
int fd[3]
Definition ngcbSocket.h:50
FILE * pipeErr
Definition ngcbSocket.h:53
Definition ngcbSocket.h:60
char ipAddr[32]
Definition ngcbSocket.h:62
char hostName[64]
Definition ngcbSocket.h:61