]>
git.saurik.com Git - apple/syslog.git/blob - syslogd.tproj/klog_in.c
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 2004 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 #include <sys/types.h>
27 #include <sys/socket.h>
38 #define forever for(;;)
40 #define MY_ID "klog_in"
46 static char kline
[MAXLINE
+ 1];
49 klog_in_acceptmsg(int fd
)
56 while ((n
== 1) && (c
!= '\n'))
58 if (kx
< MAXLINE
) kline
[kx
++] = c
;
62 if (kx
== 0) return NULL
;
68 return asl_syslog_input_convert(kline
, n
, NULL
, 1);
74 asldebug("%s: init\n", MY_ID
);
75 if (kfd
>= 0) return kfd
;
77 kfd
= open(_PATH_KLOG
, O_RDONLY
, 0);
80 asldebug("%s: couldn't open %s: %s\n", MY_ID
, _PATH_KLOG
, strerror(errno
));
84 if (fcntl(kfd
, F_SETFL
, O_NONBLOCK
) < 0)
88 asldebug("%s: couldn't set O_NONBLOCK for fd %d (%s): %s\n", MY_ID
, kfd
, _PATH_KLOG
, strerror(errno
));
92 return aslevent_addfd(kfd
, klog_in_acceptmsg
, NULL
, NULL
);
104 if (kfd
< 0) return 1;