]> git.saurik.com Git - apple/libc.git/blame - gen/asl_store.h
Libc-498.1.5.tar.gz
[apple/libc.git] / gen / asl_store.h
CommitLineData
b5d655f7
A
1#ifndef __ASL_STORE_H__
2#define __ASL_STORE_H__
3
4/*
5 * Copyright (c) 2007-2008 Apple Inc. All rights reserved.
6 *
7 * @APPLE_LICENSE_HEADER_START@
8 *
9 * "Portions Copyright (c) 2007 Apple Inc. All Rights
10 * Reserved. This file contains Original Code and/or Modifications of
11 * Original Code as defined in and that are subject to the Apple Public
12 * Source License Version 1.0 (the 'License'). You may not use this file
13 * except in compliance with the License. Please obtain a copy of the
14 * License at http://www.apple.com/publicsource and read it before using
15 * this file.
16 *
17 * The Original Code and all software distributed under the License are
18 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
19 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
20 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
22 * License for the specific language governing rights and limitations
23 * under the License."
24 *
25 * @APPLE_LICENSE_HEADER_END@
26 */
27
28#include <stdio.h>
29#include <stdint.h>
30#include <sys/time.h>
31#include <asl.h>
32#include <asl_file.h>
33
34#define PATH_ASL_STORE "/var/log/asl"
35#define PATH_ASL_ARCHIVE "/var/log/asl.archive"
36#define FILE_ASL_STORE_DATA "StoreData"
37#define FILE_ASL_STORE_SWEEP_SEMAPHORE "SweepStore"
38
39#define FILE_CACHE_SIZE 64
40#define FILE_CACHE_TTL 300
41
42typedef struct
43{
44 time_t ts;
45 uid_t u;
46 gid_t g;
47 char *path;
48 asl_file_t *f;
49} asl_cached_file_t;
50
51typedef struct
52{
53 char *base_dir;
54 FILE *storedata;
55 uint64_t next_id;
56 asl_file_t *db;
57 asl_cached_file_t file_cache[FILE_CACHE_SIZE];
58 void *work;
59 time_t start_today;
60 time_t start_tomorrow;
61 time_t last_write;
62 size_t max_file_size;
63} asl_store_t;
64
65uint32_t asl_store_open_write(const char *basedir, asl_store_t **s);
66uint32_t asl_store_open_read(const char *basedir, asl_store_t **s);
67uint32_t asl_store_close(asl_store_t *s);
68uint32_t asl_store_statistics(asl_store_t *s, aslmsg *msg);
69
70uint32_t asl_store_save(asl_store_t *s, aslmsg msg);
71
72uint32_t asl_store_match(asl_store_t *s, aslresponse query, aslresponse *res, uint64_t *last_id, uint64_t start_id, uint32_t count, int32_t direction);
73uint32_t asl_store_match_timeout(asl_store_t *s, aslresponse query, aslresponse *res, uint64_t *last_id, uint64_t start_id, uint32_t count, int32_t direction, uint32_t usec);
74
75uint32_t asl_store_match_start(asl_store_t *s, uint64_t start_id, int32_t direction);
76uint32_t asl_store_match_next(asl_store_t *s, aslresponse query, aslresponse *res, uint32_t count);
77
78uint32_t asl_store_max_file_size(asl_store_t *s, size_t max);
79uint32_t asl_store_signal_sweep(asl_store_t *s);
80uint32_t asl_store_sweep_file_cache(asl_store_t *s);
81
82#endif __ASL_STORE_H__