version 1.7, 2004/11/09 20:43:22 |
version 1.8, 2004/12/07 17:10:56 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* |
/* |
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> |
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* modification, are permitted provided that the following conditions |
* are met: |
* are met: |
* |
* |
* 1. Redistributions of source code must retain the above copyright |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* notice, this list of conditions and the following disclaimer. |
* 2. The name of the author may not be used to endorse or promote products |
* 2. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* derived from this software without specific prior written permission. |
* |
* |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
*/ |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
|
|
char *cvsd_sock_path = CVSD_SOCK_PATH; |
char *cvsd_sock_path = CVSD_SOCK_PATH; |
|
|
|
|
|
|
/* daemon API */ |
/* daemon API */ |
#ifdef CVSD |
#ifdef CVSD |
int cvsd_sock = -1; |
int cvsd_sock = -1; |
|
|
* we close it before reopening it. |
* we close it before reopening it. |
* Returns 0 on success, -1 on failure. |
* Returns 0 on success, -1 on failure. |
*/ |
*/ |
|
|
int |
int |
cvsd_sock_open(void) |
cvsd_sock_open(void) |
{ |
{ |
|
|
|
|
cvsd_sock = socket(AF_LOCAL, SOCK_STREAM, 0); |
cvsd_sock = socket(AF_LOCAL, SOCK_STREAM, 0); |
if (cvsd_sock == -1) { |
if (cvsd_sock == -1) { |
cvs_log(LP_ERRNO, "failed to open socket"); |
cvs_log(LP_ERRNO, "failed to open socket"); |
return (-1); |
return (-1); |
} |
} |
|
|
|
|
* |
* |
* Close the local socket. |
* Close the local socket. |
*/ |
*/ |
|
|
void |
void |
cvsd_sock_close(void) |
cvsd_sock_close(void) |
{ |
{ |
|
|
* no available child processes, a new one will be created unless the number |
* no available child processes, a new one will be created unless the number |
* of children has attained the maximum. |
* of children has attained the maximum. |
*/ |
*/ |
|
|
int |
int |
cvsd_sock_accept(int fd) |
cvsd_sock_accept(int fd) |
{ |
{ |
|
|
* |
* |
* Open a connection to the CVS server's local socket. |
* Open a connection to the CVS server's local socket. |
*/ |
*/ |
|
|
int |
int |
cvs_sock_connect(const char *path) |
cvs_sock_connect(const char *path) |
{ |
{ |
|
|
* |
* |
* Disconnect from the open socket to the CVS server. |
* Disconnect from the open socket to the CVS server. |
*/ |
*/ |
|
|
void |
void |
cvs_sock_disconnect(void) |
cvs_sock_disconnect(void) |
{ |
{ |