File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libpdel / sys / logfile.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:25:53 2012 UTC (13 years, 1 month ago) by misho
Branches: libpdel, MAIN
CVS tags: v0_5_3, HEAD
libpdel

    1: 
    2: /*
    3:  * Copyright (c) 2001-2002 Packet Design, LLC.
    4:  * All rights reserved.
    5:  * 
    6:  * Subject to the following obligations and disclaimer of warranty,
    7:  * use and redistribution of this software, in source or object code
    8:  * forms, with or without modifications are expressly permitted by
    9:  * Packet Design; provided, however, that:
   10:  * 
   11:  *    (i)  Any and all reproductions of the source or object code
   12:  *         must include the copyright notice above and the following
   13:  *         disclaimer of warranties; and
   14:  *    (ii) No rights are granted, in any manner or form, to use
   15:  *         Packet Design trademarks, including the mark "PACKET DESIGN"
   16:  *         on advertising, endorsements, or otherwise except as such
   17:  *         appears in the above copyright notice or in the software.
   18:  * 
   19:  * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
   20:  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
   21:  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
   22:  * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
   23:  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
   24:  * OR NON-INFRINGEMENT.  PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
   25:  * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
   26:  * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
   27:  * RELIABILITY OR OTHERWISE.  IN NO EVENT SHALL PACKET DESIGN BE
   28:  * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
   29:  * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
   30:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
   31:  * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
   32:  * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
   33:  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   34:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
   35:  * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
   36:  * THE POSSIBILITY OF SUCH DAMAGE.
   37:  *
   38:  * Author: Archie Cobbs <archie@freebsd.org>
   39:  */
   40: 
   41: #ifndef _PDEL_SYS_LOGFILE_H_
   42: #define _PDEL_SYS_LOGFILE_H_
   43: 
   44: /*
   45:  * Support for on-disk circular log files. Each file contains the
   46:  * N most recent entries, where an entry is any opaque chunk of
   47:  * data supplied by the application. New entries overwrite the
   48:  * oldest entries in a circular fashion.
   49:  */
   50: 
   51: struct logfile;
   52: 
   53: __BEGIN_DECLS
   54: 
   55: /*
   56:  * Open/create a new logfile.
   57:  *
   58:  * "maxent" sets the maximum number of entries the file can hold.
   59:  * "maxdata" sets the maximum amount of entry data the file can
   60:  * hold.
   61:  *
   62:  * The size of the file will be approx.: maxdata + (8 * maxent) + 20
   63:  *
   64:  * If "path" already exists, it must be a valid logfile and the
   65:  * "maxent" and "maxdata" arguments are ignored.
   66:  *
   67:  * "flags" may be zero, O_SHLOCK or O_EXLOCK.
   68:  *
   69:  * If "path" is NULL, a memory-only logfile is created.
   70:  */
   71: extern struct	logfile *logfile_open(const char *path,
   72: 			int flags, u_int32_t maxent, u_int32_t maxdata);
   73: 
   74: /*
   75:  * Close a logfile.
   76:  */
   77: extern void	logfile_close(struct logfile **lfp);
   78: 
   79: /*
   80:  * Get the number of valid entries in a logfile.
   81:  */
   82: extern u_int32_t logfile_num_entries(struct logfile *lf);
   83: 
   84: /*
   85:  * Retrieve a logfile entry.
   86:  *
   87:  * "which" must be a negative number.
   88:  *
   89:  * Entry -1 is the most recent, -2 the second most recent, etc.
   90:  * If "lenp" is not NULL, the length of the entry is returned.
   91:  */
   92: extern const	void *logfile_get(struct logfile *lf, int which, int *lenp);
   93: 
   94: /*
   95:  * Add an entry.
   96:  */
   97: extern int	logfile_put(struct logfile *lf, const void *data, int len);
   98: 
   99: /*
  100:  * Trim the number of stored entries.
  101:  */
  102: extern void	logfile_trim(struct logfile *lf, int num);
  103: 
  104: /*
  105:  * Sync entries to disk.
  106:  */
  107: extern void	logfile_sync(struct logfile *lf);
  108: 
  109: __END_DECLS
  110: 
  111: #endif	/* _PDEL_SYS_LOGFILE_H_ */
  112: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>