diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2012-11-16 01:00:05 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2012-11-16 01:00:05 +0000 |
commit | a469f8a57669e1948d5cc29005d8c097312de63a (patch) | |
tree | 4af697f80e08ff9f10989840ea8a2669b73b8e08 /cups/http-addrlist.c | |
parent | 76aa1ac14cceecf4968355e1ea6af822bce9cfc3 (diff) | |
download | cups-a469f8a57669e1948d5cc29005d8c097312de63a.tar.gz |
Merge changes from CUPS 1.7svn-r10704.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@4027 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups/http-addrlist.c')
-rw-r--r-- | cups/http-addrlist.c | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index 223a68695..e62a556f4 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -14,11 +14,12 @@ * * Contents: * - * httpAddrConnect() - Connect to any of the addresses in the list. + * httpAddrConnect() - Connect to any of the addresses in the list. * httpAddrConnect2() - Connect to any of the addresses in the list with a - * timeout and optional cancel. + * timeout and optional cancel. + * httpAddrCopyList() - Copy an address list. * httpAddrFreeList() - Free an address list. - * httpAddrGetList() - Get a list of addresses for a hostname. + * httpAddrGetList() - Get a list of addresses for a hostname. */ /* @@ -119,7 +120,7 @@ httpAddrConnect2( DEBUG_printf(("2httpAddrConnect2: Trying %s:%d...", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), - _httpAddrPort(&(addrlist->addr)))); + httpAddrPort(&(addrlist->addr)))); if ((*sock = (int)socket(_httpAddrFamily(&(addrlist->addr)), SOCK_STREAM, 0)) < 0) @@ -201,7 +202,7 @@ httpAddrConnect2( { DEBUG_printf(("1httpAddrConnect2: Connected to %s:%d...", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), - _httpAddrPort(&(addrlist->addr)))); + httpAddrPort(&(addrlist->addr)))); #ifdef O_NONBLOCK fcntl(*sock, F_SETFL, flags); @@ -282,7 +283,7 @@ httpAddrConnect2( { DEBUG_printf(("1httpAddrConnect2: Connected to %s:%d...", httpAddrString(&peer, temp, sizeof(temp)), - _httpAddrPort(&peer))); + httpAddrPort(&peer))); return (addrlist); } @@ -295,7 +296,7 @@ httpAddrConnect2( DEBUG_printf(("1httpAddrConnect2: Unable to connect to %s:%d: %s", httpAddrString(&(addrlist->addr), temp, sizeof(temp)), - _httpAddrPort(&(addrlist->addr)), strerror(errno))); + httpAddrPort(&(addrlist->addr)), strerror(errno))); #ifndef WIN32 if (errno == EINPROGRESS) @@ -327,6 +328,55 @@ httpAddrConnect2( } + +/* + * 'httpAddrCopyList()' - Copy an address list. + * + * @since CUPS 1.7@ + */ + +http_addrlist_t * /* O - New address list or @code NULL@ on error */ +httpAddrCopyList( + http_addrlist_t *src) /* I - Source address list */ +{ + http_addrlist_t *dst = NULL, /* First list entry */ + *prev = NULL, /* Previous list entry */ + *current = NULL;/* Current list entry */ + + + while (src) + { + if ((current = malloc(sizeof(http_addrlist_t))) == NULL) + { + current = dst; + + while (current) + { + prev = current; + current = current->next; + + free(prev); + } + + return (NULL); + } + + memcpy(current, src, sizeof(http_addrlist_t)); + + current->next = NULL; + + if (prev) + prev->next = current; + else + dst = current; + + src = src->next; + } + + return (dst); +} + + /* * 'httpAddrFreeList()' - Free an address list. * |