MCPcopy Create free account
hub / github.com/OpenPrinting/cups / http_create

Function http_create

cups/http.c:3990–4096  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3988 */
3989
3990static http_t * /* O - HTTP connection */
3991http_create(
3992 const char *host, /* I - Hostname */
3993 int port, /* I - Port number */
3994 http_addrlist_t *addrlist, /* I - Address list or @code NULL@ */
3995 int family, /* I - Address family or AF_UNSPEC */
3996 http_encryption_t encryption, /* I - Encryption to use */
3997 int blocking, /* I - 1 for blocking mode */
3998 _http_mode_t mode) /* I - _HTTP_MODE_CLIENT or _SERVER */
3999{
4000 http_t *http; /* New HTTP connection */
4001 char service[255]; /* Service name */
4002 http_addrlist_t *myaddrlist = NULL; /* My address list */
4003
4004
4005 DEBUG_printf(("4http_create(host=\"%s\", port=%d, addrlist=%p, family=%d, encryption=%d, blocking=%d, mode=%d)", host, port, (void *)addrlist, family, encryption, blocking, mode));
4006
4007 if (!host && mode == _HTTP_MODE_CLIENT)
4008 return (NULL);
4009
4010 httpInitialize();
4011
4012 /*
4013 * Lookup the host...
4014 */
4015
4016 if (addrlist)
4017 {
4018 myaddrlist = httpAddrCopyList(addrlist);
4019 }
4020 else
4021 {
4022 snprintf(service, sizeof(service), "%d", port);
4023
4024 myaddrlist = httpAddrGetList(host, family, service);
4025 }
4026
4027 if (!myaddrlist)
4028 return (NULL);
4029
4030 /*
4031 * Allocate memory for the structure...
4032 */
4033
4034 if ((http = calloc(1, sizeof(http_t))) == NULL)
4035 {
4036 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
4037 httpAddrFreeList(myaddrlist);
4038 return (NULL);
4039 }
4040
4041 /*
4042 * Initialize the HTTP data...
4043 */
4044
4045 http->mode = mode;
4046 http->activity = time(NULL);
4047 http->addrlist = myaddrlist;

Callers 2

httpAcceptConnectionFunction · 0.85
httpConnect2Function · 0.85

Calls 6

httpInitializeFunction · 0.85
httpAddrCopyListFunction · 0.85
httpAddrGetListFunction · 0.85
_cupsSetErrorFunction · 0.85
httpAddrFreeListFunction · 0.85
http_set_waitFunction · 0.85

Tested by

no test coverage detected