LOGFILE.H C-5

NAME

logfile.h - include file for transaction log file

SYNOPSIS

#include <cbase/logfile.h>

DESCRIPTION

This include file contains symbolic definitions for the data structures written to the transaction log file.

CONTENTS

/*

* @(#)logfile.h 4.5

*

* Format of Transaction Logging File

*

* Overview:

* Each entry in log file has three parts:

* header, entry, argument

* Each part is preceded by the size of that part.

* The header has a common format for all entries.

* The entry part depends on the entry type of the header.

* Each entry type has its own format and must be read

* using the correct format.

* The argument part is optional, but even when not used,

* there will be a zero size recorded for that part.

*

* Header Format:

* Header

* Record Type (TL_BEGIN, TL_END, TL_BEFORE, etc.)

* UNIX System Time (GMT)

* Process Id #

*

* Record Formats (starred (*) entries are arguments):

* TL_PROC:

* Terminal Name (if defined)

* User/group Id (real and effective)

*

* Program Id (optional)

*

* TL_BEGIN:

* Transaction Id (unique #/ per process)

* * Transaction Comment

* TL_END, TL_COMMIT, TL_CANCEL:

* Transaction Id (same as TL_BEGIN)

* TL_BEFORE, TL_AFTER, TL_CLOSE:

* Change Type (DINSERT, DDELETE, DUPDATE, DCLOSE)

* Internal File Id

* Record Number

* * Record Image (actual size will vary between files)

* TL_OPEN, TL_REMOVE, TL_CLEAR, TL_EXPAND:

* File Id (data base name, logical file name)

* Number of Records (only TL_EXPAND)

* Internal File Id (only TL_OPEN)

* TL_CREATE, TL_CONVERT:

* File Id (same as TL_OPEN)

* Number of Records (only TL_CREATE)

* Internal File Id (unused)

* * File Definition

*/

typedef short TLSIZE; /* type of all sizes in logging file */

typedef long DLID; /* type of transaction marker ID's */

#define TL_MAGIC 04310 /* Logfile magic number */

#define TL_VERSION 300 /* Version 3.00 */

#define FAILED 0 /* Logging operation failed */

#define SUCCEED 1 /* Logging operation succeeded */

/* Entry Types */

#define TL_BEGIN 001 /* Begin Transaction Marker */

#define TL_COMMIT 002 /* Transaction is comitted to finish */

#define TL_CANCEL 003 /* Transaction was cancelled */

#define TL_END 004 /* End Transaction Marker */

#define TL_BEFORE 005 /* Record Change Before Image */

#define TL_AFTER 006 /* Record Change After Image */

#define TL_OPEN 007 /* Open File Marker */

#define TL_CLOSE 010 /* Close File Marker */

#define TL_REMOVE 011 /* Remove File Marker */

#define TL_CLEAR 012 /* Clear File Marker */

#define TL_CONVERT 013 /* Convert File To New Definition Marker */

#define TL_EXPAND 014 /* Expand File to New Size */

#define TL_CREATE 015 /* Create New File */

#define TL_PROC 016 /* Process identification */

/* Logfile Constants */

#define TL_PROGZ 64 /* Maximum program name size */

/* Logfile Header Structure Layout */

typedef struct tl_head {

char tlh_type; /* Entry Type */

long tlh_time; /* UNIX Current GMT Time */

int tlh_pid; /* Process Id */

} TLHEAD;

/* Logfile Process Identification Structure Layout */

typedef struct tl_proc {

char tlp_tty[16]; /* Terminal Name (if available) */

short tlp_ruser; /* Real User Id */

short tlp_euser; /* Effective User Id */

short tlp_rgroup; /* Real Group Id */

short tlp_egroup; /* Effective Group Id */

} TLPROC;

/* Logfile Begin / End Transaction Marker Structure Layout */

typedef struct tl_mark {

DLID tlm_id; /* Transaction Id */

} TLMARK;

/* Logfile Record Change and File Close Structure Layout */

typedef struct tl_change {

char tlc_func; /* Change Function (DUPDATE, etc.) */

long tlc_file; /* File Id */

rno_t tlc_slot; /* Record Number */

/* Record Size (including prefix) follows in file */

/* Record Image follows in file (actual size will vary between files) */

} TLCHG;

/* Logfile Structure Layout for OPEN, CLEAR, REMOVE, etc. */

typedef struct tl_file {

char tlf_dbname[DBNAMZ]; /* File Id - data base name */

char tlf_lfile[DBFILZ]; /* File Id - logical file name */

rno_t tlf_nrec; /* Number of records */

long tlf_file; /* File Id for changes */

} TLFILE;

/*

* For TL_CREATE and TL_CONVERT, file definition as used by RMS

* will follow TLFILE structure in logfile.

*/