X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=comstack%2Funix.c;h=0cccf5f690d221253cb972ed6e06735a22e57ada;hb=a662fb07cab81d45cdd1b8f5b7e68c21992a8678;hp=a3d4e5852e20a20ae581a6f21f551a5e42f819a9;hpb=f78b96e6645bb3309719a234ff68699d8fccb975;p=yaz-moved-to-github.git diff --git a/comstack/unix.c b/comstack/unix.c index a3d4e58..0cccf5f 100644 --- a/comstack/unix.c +++ b/comstack/unix.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data * See the file LICENSE for details. * - * $Id: unix.c,v 1.1 2002-06-04 11:36:10 adam Exp $ + * $Id: unix.c,v 1.6 2002-09-20 22:23:13 adam Exp $ * UNIX socket COMSTACK. By Morten Bøgeskov. */ #ifndef WIN32 @@ -26,6 +26,10 @@ /* Chas added the following, so we get the definition of completeBER */ #include +#ifndef YAZ_SOCKLEN_T +#define YAZ_SOCKLEN_T int +#endif + int unix_close(COMSTACK h); int unix_put(COMSTACK h, char *buf, int size); int unix_get(COMSTACK h, char **buf, int *bufsize); @@ -43,6 +47,10 @@ COMSTACK unix_accept(COMSTACK h); char *unix_addrstr(COMSTACK h); void *unix_straddr(COMSTACK h, const char *str); +#ifndef SUN_LEN +#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ + + strlen ((ptr)->sun_path)) +#endif #if 0 #define TRC(x) x #else @@ -143,16 +151,15 @@ COMSTACK unix_type(int s, int blocking, int protocol, void *vp) int unix_strtoaddr_ex(const char *str, struct sockaddr_un *add) { - struct hostent *hp; - char *p, buf[512]; - short int port = 210; - unsigned tmpadd; - + char *cp; if (!unix_init ()) return 0; TRC(fprintf(stderr, "unix_strtoaddress: %s\n", str ? str : "NULL")); add->sun_family = AF_UNIX; strncpy(add->sun_path, str, sizeof(add->sun_path)); + cp = strchr (add->sun_path, ':'); + if (cp) + *cp = '\0'; return 1; } @@ -227,7 +234,6 @@ int unix_connect(COMSTACK h, void *address) */ int unix_rcvconnect(COMSTACK h) { - unix_state *sp = (unix_state *)h->cprivate; TRC(fprintf(stderr, "unix_rcvconnect\n")); if (h->state == CS_ST_DATAXFER) @@ -248,7 +254,6 @@ int unix_rcvconnect(COMSTACK h) int unix_bind(COMSTACK h, void *address, int mode) { struct sockaddr *addr = (struct sockaddr *)address; - unsigned long one = 1; const char * path = ((struct sockaddr_un *)addr)->sun_path; struct stat stat_buf; @@ -304,11 +309,7 @@ int unix_listen(COMSTACK h, char *raddr, int *addrlen, void *cd) { struct sockaddr_un addr; -#ifdef __cplusplus - socklen_t len = SUN_LEN(&addr); -#else - int len = SUN_LEN(&addr); -#endif + YAZ_SOCKLEN_T len = SUN_LEN(&addr); TRC(fprintf(stderr, "unix_listen pid=%d\n", getpid())); if (h->state != CS_ST_IDLE)