]> git.saurik.com Git - apple/syslog.git/blobdiff - syslogd.tproj/bsd_in.c
syslog-132.tar.gz
[apple/syslog.git] / syslogd.tproj / bsd_in.c
index 9b8a0a08e8453e1207984db9cb00c1a573a830c7..fa10fd46c68de7a5f7bf3a44a284b02e5fda863a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004-2008 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2010 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -40,7 +40,7 @@
 
 static int sock = -1;
 
-asl_msg_t *
+aslmsg
 bsd_in_acceptmsg(int fd)
 {
        uint32_t len;
@@ -55,7 +55,7 @@ bsd_in_acceptmsg(int fd)
 
        line[n] = '\0';
 
-       return asl_input_parse(line, n, NULL, 0);
+       return asl_input_parse(line, n, NULL, SOURCE_BSD_SOCKET);
 }
 
 int
@@ -70,40 +70,40 @@ bsd_in_init(void)
 
        if (global.launch_dict == NULL)
        {
-               asldebug("%s: laucnchd dict is NULL\n", MY_ID);
+               asldebug("%s: launchd dict is NULL\n", MY_ID);
                return -1;
        }
 
        sockets_dict = launch_data_dict_lookup(global.launch_dict, LAUNCH_JOBKEY_SOCKETS);
        if (sockets_dict == NULL)
        {
-               asldebug("%s: laucnchd lookup of LAUNCH_JOBKEY_SOCKETS failed\n", MY_ID);
+               asldebug("%s: launchd lookup of LAUNCH_JOBKEY_SOCKETS failed\n", MY_ID);
                return -1;
        }
 
        fd_array = launch_data_dict_lookup(sockets_dict, BSD_SOCKET_NAME);
        if (fd_array == NULL)
        {
-               asldebug("%s: laucnchd lookup of BSD_SOCKET_NAME failed\n", MY_ID);
+               asldebug("%s: launchd lookup of BSD_SOCKET_NAME failed\n", MY_ID);
                return -1;
        }
 
        len = launch_data_array_get_count(fd_array);
        if (len <= 0)
        {
-               asldebug("%s: laucnchd fd array is empty\n", MY_ID);
+               asldebug("%s: launchd fd array is empty\n", MY_ID);
                return -1;
        }
 
        if (len > 1)
        {
-               asldebug("%s: warning! laucnchd fd array has %d sockets\n", MY_ID, len);
+               asldebug("%s: warning! launchd fd array has %d sockets\n", MY_ID, len);
        }
 
        fd_dict = launch_data_array_get_index(fd_array, 0);
        if (fd_dict == NULL)
        {
-               asldebug("%s: laucnchd file discriptor array element 0 is NULL\n", MY_ID);
+               asldebug("%s: launchd file discriptor array element 0 is NULL\n", MY_ID);
                return -1;
        }
 
@@ -128,21 +128,23 @@ bsd_in_init(void)
                return -1;
        }
 
-       return aslevent_addfd(sock, ADDFD_FLAGS_LOCAL, bsd_in_acceptmsg, NULL, NULL);
+       return aslevent_addfd(SOURCE_BSD_SOCKET, sock, ADDFD_FLAGS_LOCAL, bsd_in_acceptmsg, NULL, NULL);
 }
 
 int
-bsd_in_reset(void)
+bsd_in_close(void)
 {
+       if (sock < 0) return 1;
+
+       aslevent_removefd(sock);
+       close(sock);
+       sock = -1;
+
        return 0;
 }
 
 int
-bsd_in_close(void)
+bsd_in_reset(void)
 {
-       if (sock < 0) return 1;
-
-       close(sock);
-       unlink(_PATH_SYSLOG_IN);
        return 0;
 }