nscdcli.c (814aaaa7da4dab462d90e12e7b48b75f2093ccfd) nscdcli.c (b4b4b5304bd22eab265c9c049cb7fc6b55c4ef3f)
1/*-
2 * Copyright (c) 2005 Michael Bushkov <bushman@rsu.ru>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 175 unchanged lines hidden (view full) ---

184 struct kevent eventlist;
185 struct sockaddr_un client_address;
186 int client_address_len, client_socket;
187 int res;
188
189 TRACE_IN(open_nscd_connection);
190 assert(params != NULL);
191
1/*-
2 * Copyright (c) 2005 Michael Bushkov <bushman@rsu.ru>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 175 unchanged lines hidden (view full) ---

184 struct kevent eventlist;
185 struct sockaddr_un client_address;
186 int client_address_len, client_socket;
187 int res;
188
189 TRACE_IN(open_nscd_connection);
190 assert(params != NULL);
191
192 client_socket = socket(PF_LOCAL, SOCK_STREAM|SOCK_NONBLOCK, 0);
192 client_socket = socket(PF_LOCAL, SOCK_STREAM, 0);
193 client_address.sun_family = PF_LOCAL;
194 strlcpy(client_address.sun_path, params->socket_path,
195 sizeof(client_address.sun_path));
196 client_address_len = sizeof(client_address.sun_family) +
197 strlen(client_address.sun_path) + 1;
198
199 res = connect(client_socket, (struct sockaddr *)&client_address,
200 client_address_len);
201 if (res == -1) {
202 close(client_socket);
203 TRACE_OUT(open_nscd_connection);
204 return (NULL);
205 }
193 client_address.sun_family = PF_LOCAL;
194 strlcpy(client_address.sun_path, params->socket_path,
195 sizeof(client_address.sun_path));
196 client_address_len = sizeof(client_address.sun_family) +
197 strlen(client_address.sun_path) + 1;
198
199 res = connect(client_socket, (struct sockaddr *)&client_address,
200 client_address_len);
201 if (res == -1) {
202 close(client_socket);
203 TRACE_OUT(open_nscd_connection);
204 return (NULL);
205 }
206 fcntl(client_socket, F_SETFL, O_NONBLOCK);
206
207 retval = calloc(1, sizeof(*retval));
208 assert(retval != NULL);
209
210 retval->sockfd = client_socket;
211
212 retval->write_queue = kqueue();
213 assert(retval->write_queue != -1);

--- 73 unchanged lines hidden ---
207
208 retval = calloc(1, sizeof(*retval));
209 assert(retval != NULL);
210
211 retval->sockfd = client_socket;
212
213 retval->write_queue = kqueue();
214 assert(retval->write_queue != -1);

--- 73 unchanged lines hidden ---