| 1078 | */ |
| 1079 | |
| 1080 | static ippeve_client_t * /* O - Client */ |
| 1081 | create_client(ippeve_printer_t *printer, /* I - Printer */ |
| 1082 | int sock) /* I - Listen socket */ |
| 1083 | { |
| 1084 | ippeve_client_t *client; /* Client */ |
| 1085 | |
| 1086 | |
| 1087 | if ((client = calloc(1, sizeof(ippeve_client_t))) == NULL) |
| 1088 | { |
| 1089 | perror("Unable to allocate memory for client"); |
| 1090 | return (NULL); |
| 1091 | } |
| 1092 | |
| 1093 | client->printer = printer; |
| 1094 | |
| 1095 | /* |
| 1096 | * Accept the client and get the remote address... |
| 1097 | */ |
| 1098 | |
| 1099 | if ((client->http = httpAcceptConnection(sock, 1)) == NULL) |
| 1100 | { |
| 1101 | perror("Unable to accept client connection"); |
| 1102 | |
| 1103 | free(client); |
| 1104 | |
| 1105 | return (NULL); |
| 1106 | } |
| 1107 | |
| 1108 | httpGetHostname(client->http, client->hostname, sizeof(client->hostname)); |
| 1109 | |
| 1110 | if (Verbosity) |
| 1111 | fprintf(stderr, "Accepted connection from %s\n", client->hostname); |
| 1112 | |
| 1113 | return (client); |
| 1114 | } |
| 1115 | |
| 1116 | |
| 1117 | /* |
no test coverage detected