* rpc msg C API rearranged to separate socket/connect from connect

This commit is contained in:
Olof hagsand 2021-01-12 14:03:07 +01:00
parent 8cde7a4ded
commit 2a392ca0e9
11 changed files with 93 additions and 69 deletions

View file

@ -63,13 +63,14 @@ INSTALLFLAGS = @INSTALLFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
CPPFLAGS = @CPPFLAGS@
LINKAGE = @LINKAGE@
INCLUDES = -I. @INCLUDES@ -I$(top_srcdir)/lib -I$(top_srcdir)/include
ifeq ($(LINKAGE),dynamic)
CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR)
else
ifeq ($(LINKAGE),static)
CLIXON_LIB = libclixon.a
else
CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR)
endif
# For dependency. A little strange that we rely on it being built in the src dir

View file

@ -96,6 +96,7 @@ main(int argc,
cbuf *cb = cbuf_new();
clicon_handle h;
int dbg = 0;
int s;
/* In the startup, logs to stderr & debug flag set later */
clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR);
@ -167,12 +168,15 @@ main(int argc,
if ((msg = clicon_msg_encode(getpid(), "%s", cbuf_get(cb))) < 0)
goto done;
if (strcmp(family, "UNIX")==0){
if (clicon_rpc_connect_unix(h, msg, sockpath, &retdata, NULL) < 0)
if (clicon_rpc_connect_unix(h, sockpath, &s) < 0)
goto done;
}
else
if (clicon_rpc_connect_inet(h, msg, sockpath, 4535, &retdata, NULL) < 0)
if (clicon_rpc_connect_inet(h, sockpath, 4535, &s) < 0)
goto done;
if (clicon_rpc(s, msg, &retdata) < 0)
goto done;
close(s);
fprintf(stdout, "%s\n", retdata);
retval = 0;
done: