Update libiso_msgs with new Thomas changes.
This commit is contained in:
parent
57025a614d
commit
88eea232aa
@ -1,7 +1,8 @@
|
||||
|
||||
/* libiso_msgs
|
||||
Message handling facility of libiso.
|
||||
Copyright (C) 2006 Thomas Schmitt <scdbackup@gmx.net>, provided under GPL
|
||||
Copyright (C) 2006 - 2008 Thomas Schmitt <scdbackup@gmx.net>,
|
||||
provided under GPL version 2
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -39,7 +40,7 @@ static int libiso_msgs_item_new(struct libiso_msgs_item **item,
|
||||
if(ret==0)
|
||||
o->timestamp= tv.tv_sec+0.000001*tv.tv_usec;
|
||||
o->process_id= getpid();
|
||||
o->driveno= -1;
|
||||
o->origin= -1;
|
||||
o->severity= LIBISO_MSGS_SEV_ALL;
|
||||
o->priority= LIBISO_MSGS_PRIO_ZERO;
|
||||
o->error_code= 0;
|
||||
@ -108,12 +109,12 @@ int libiso_msgs_item_get_msg(struct libiso_msgs_item *item,
|
||||
|
||||
|
||||
int libiso_msgs_item_get_origin(struct libiso_msgs_item *item,
|
||||
double *timestamp, pid_t *process_id, int *driveno,
|
||||
double *timestamp, pid_t *process_id, int *origin,
|
||||
int flag)
|
||||
{
|
||||
*timestamp= item->timestamp;
|
||||
*process_id= item->process_id;
|
||||
*driveno= item->driveno;
|
||||
*origin= item->origin;
|
||||
return(1);
|
||||
}
|
||||
|
||||
@ -137,6 +138,7 @@ int libiso_msgs_new(struct libiso_msgs **m, int flag)
|
||||
(*m)= o= (struct libiso_msgs *) malloc(sizeof(struct libiso_msgs));
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
o->refcount= 1;
|
||||
o->oldest= NULL;
|
||||
o->youngest= NULL;
|
||||
o->count= 0;
|
||||
@ -152,43 +154,6 @@ int libiso_msgs_new(struct libiso_msgs **m, int flag)
|
||||
}
|
||||
|
||||
|
||||
int libiso_msgs_destroy(struct libiso_msgs **m, int flag)
|
||||
{
|
||||
struct libiso_msgs *o;
|
||||
struct libiso_msgs_item *item, *next_item;
|
||||
|
||||
o= *m;
|
||||
if(o==NULL)
|
||||
return(0);
|
||||
|
||||
#ifndef LIBISO_MSGS_SINGLE_THREADED
|
||||
if(pthread_mutex_destroy(&(o->lock_mutex))!=0) {
|
||||
pthread_mutex_unlock(&(o->lock_mutex));
|
||||
pthread_mutex_destroy(&(o->lock_mutex));
|
||||
}
|
||||
#endif
|
||||
|
||||
for(item= o->oldest; item!=NULL; item= next_item) {
|
||||
next_item= item->next;
|
||||
libiso_msgs_item_destroy(&item,0);
|
||||
}
|
||||
free((char *) o);
|
||||
*m= NULL;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int libiso_msgs_set_severities(struct libiso_msgs *m, int queue_severity,
|
||||
int print_severity, const char *print_id, int flag)
|
||||
{
|
||||
m->queue_severity= queue_severity;
|
||||
m->print_severity= print_severity;
|
||||
strncpy(m->print_id,print_id,80);
|
||||
m->print_id[80]= 0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
static int libiso_msgs_lock(struct libiso_msgs *m, int flag)
|
||||
{
|
||||
|
||||
@ -219,6 +184,65 @@ static int libiso_msgs_unlock(struct libiso_msgs *m, int flag)
|
||||
}
|
||||
|
||||
|
||||
int libiso_msgs_destroy(struct libiso_msgs **m, int flag)
|
||||
{
|
||||
struct libiso_msgs *o;
|
||||
struct libiso_msgs_item *item, *next_item;
|
||||
|
||||
o= *m;
|
||||
if(o==NULL)
|
||||
return(0);
|
||||
if(o->refcount > 1) {
|
||||
if(libiso_msgs_lock(*m,0)<=0)
|
||||
return(-1);
|
||||
o->refcount--;
|
||||
libiso_msgs_unlock(*m,0);
|
||||
*m= NULL;
|
||||
return(1);
|
||||
}
|
||||
|
||||
#ifndef LIBISO_MSGS_SINGLE_THREADED
|
||||
if(pthread_mutex_destroy(&(o->lock_mutex))!=0) {
|
||||
pthread_mutex_unlock(&(o->lock_mutex));
|
||||
pthread_mutex_destroy(&(o->lock_mutex));
|
||||
}
|
||||
#endif
|
||||
|
||||
for(item= o->oldest; item!=NULL; item= next_item) {
|
||||
next_item= item->next;
|
||||
libiso_msgs_item_destroy(&item,0);
|
||||
}
|
||||
free((char *) o);
|
||||
*m= NULL;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int libiso_msgs_refer(struct libiso_msgs **pt, struct libiso_msgs *m, int flag)
|
||||
{
|
||||
if(libiso_msgs_lock(m,0)<=0)
|
||||
return(0);
|
||||
m->refcount++;
|
||||
*pt= m;
|
||||
libiso_msgs_unlock(m,0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int libiso_msgs_set_severities(struct libiso_msgs *m, int queue_severity,
|
||||
int print_severity, char *print_id, int flag)
|
||||
{
|
||||
if(libiso_msgs_lock(m,0)<=0)
|
||||
return(0);
|
||||
m->queue_severity= queue_severity;
|
||||
m->print_severity= print_severity;
|
||||
strncpy(m->print_id,print_id,80);
|
||||
m->print_id[80]= 0;
|
||||
libiso_msgs_unlock(m,0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int libiso_msgs__text_to_sev(char *severity_name, int *severity,
|
||||
int flag)
|
||||
{
|
||||
@ -287,7 +311,7 @@ int libiso_msgs__sev_to_text(int severity, char **severity_name,
|
||||
}
|
||||
|
||||
|
||||
int libiso_msgs_submit(struct libiso_msgs *m, int driveno, int error_code,
|
||||
int libiso_msgs_submit(struct libiso_msgs *m, int origin, int error_code,
|
||||
int severity, int priority, char *msg_text,
|
||||
int os_errno, int flag)
|
||||
{
|
||||
@ -325,7 +349,7 @@ int libiso_msgs_submit(struct libiso_msgs *m, int driveno, int error_code,
|
||||
ret= libiso_msgs_item_new(&item,m->youngest,0);
|
||||
if(ret<=0)
|
||||
goto failed;
|
||||
item->driveno= driveno;
|
||||
item->origin= origin;
|
||||
item->error_code= error_code;
|
||||
item->severity= severity;
|
||||
item->priority= priority;
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
/* libiso_msgs
|
||||
Message handling facility of libisofs.
|
||||
Copyright (C) 2006-2007 Thomas Schmitt <scdbackup@gmx.net>,
|
||||
provided under GPL
|
||||
Message handling facility of libiso.
|
||||
Copyright (C) 2006-2008 Thomas Schmitt <scdbackup@gmx.net>,
|
||||
provided under GPL version 2
|
||||
*/
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ struct libiso_msgs_item {
|
||||
|
||||
double timestamp;
|
||||
pid_t process_id;
|
||||
int driveno;
|
||||
int origin;
|
||||
|
||||
int severity;
|
||||
int priority;
|
||||
@ -43,6 +43,8 @@ struct libiso_msgs_item {
|
||||
|
||||
struct libiso_msgs {
|
||||
|
||||
int refcount;
|
||||
|
||||
struct libiso_msgs_item *oldest;
|
||||
struct libiso_msgs_item *youngest;
|
||||
int count;
|
||||
@ -68,6 +70,31 @@ struct libiso_msgs {
|
||||
#ifndef LIBISO_MSGS_H_INTERNAL
|
||||
|
||||
|
||||
/* Architectural aspects */
|
||||
/*
|
||||
libiso_msgs is designed to serve in libraries which want to offer their
|
||||
applications a way to control the output of library messages. It shall be
|
||||
incorporated by an owner, i.e. a software entity which encloses the code
|
||||
of the .c file.
|
||||
|
||||
Owner of libdax_msgs is libburn. A fully compatible variant named libiso_msgs
|
||||
is owned by libisofs and can get generated by a script of the libburn
|
||||
project: libburn/libiso_msgs_to_xyz_msgs.sh .
|
||||
|
||||
Reason: One cannot link two owners of the same variant together because
|
||||
both would offer the same functions to the linker. For that situation one
|
||||
has to create a compatible variant as it is done for libisofs.
|
||||
|
||||
Compatible variants may get plugged together by call combinations like
|
||||
burn_set_messenger(iso_get_messenger());
|
||||
A new variant would demand a _set_messenger() function if it has to work
|
||||
with libisofs. If only libburn is planned as link partner then a simple
|
||||
_get_messenger() does suffice.
|
||||
Take care to shutdown libburn before its provider of the *_msgs object
|
||||
gets shut down.
|
||||
|
||||
*/
|
||||
|
||||
/* Public Opaque Handles */
|
||||
|
||||
/** A pointer to this is a opaque handle to a message handling facility */
|
||||
@ -86,7 +113,7 @@ struct libiso_msgs_item;
|
||||
|
||||
/* It is well advisable to let applications select severities via strings and
|
||||
forwarded functions libiso_msgs__text_to_sev(), libiso_msgs__sev_to_text().
|
||||
These macros are for use by libdax/libburn only.
|
||||
These macros are for use by the owner of libiso_msgs.
|
||||
*/
|
||||
|
||||
/** Use this to get messages of any severity. Do not use for submitting.
|
||||
@ -118,7 +145,7 @@ struct libiso_msgs_item;
|
||||
*/
|
||||
#define LIBISO_MSGS_SEV_SORRY 0x60000000
|
||||
|
||||
/** An error message which puts the whole operation of libdax in question
|
||||
/** An error message which puts the whole operation of the program in question
|
||||
*/
|
||||
#define LIBISO_MSGS_SEV_FATAL 0x70000000
|
||||
|
||||
@ -134,7 +161,7 @@ struct libiso_msgs_item;
|
||||
|
||||
/* Registered Priorities */
|
||||
|
||||
/* Priorities are to be used by libburn/libdax only. */
|
||||
/* Priorities are to be selected by the programmers and not by the user. */
|
||||
|
||||
#define LIBISO_MSGS_PRIO_ZERO 0x00000000
|
||||
#define LIBISO_MSGS_PRIO_LOW 0x10000000
|
||||
@ -146,12 +173,23 @@ struct libiso_msgs_item;
|
||||
#define LIBISO_MSGS_PRIO_NEVER 0x7fffffff
|
||||
|
||||
|
||||
/* Origin numbers of libburn drives may range from 0 to 1048575 */
|
||||
#define LIBISO_MSGS_ORIGIN_DRIVE_BASE 0
|
||||
#define LIBISO_MSGS_ORIGIN_DRIVE_TOP 0xfffff
|
||||
|
||||
/* Origin numbers of libisofs images may range from 1048575 to 2097152 */
|
||||
#define LIBISO_MSGS_ORIGIN_IMAGE_BASE 0x100000
|
||||
#define LIBISO_MSGS_ORIGIN_IMAGE_TOP 0x1fffff
|
||||
|
||||
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
/* Calls initiated from inside libdax/libburn */
|
||||
/* Calls initiated from inside the direct owner (e.g. from libburn) */
|
||||
|
||||
|
||||
/** Create new empty message handling facility with queue.
|
||||
/** Create new empty message handling facility with queue and issue a first
|
||||
official reference to it.
|
||||
@param flag Bitfield for control purposes (unused yet, submit 0)
|
||||
@return >0 success, <=0 failure
|
||||
*/
|
||||
@ -160,18 +198,37 @@ int libiso_msgs_new(struct libiso_msgs **m, int flag);
|
||||
|
||||
/** Destroy a message handling facility and all its eventual messages.
|
||||
The submitted pointer gets set to NULL.
|
||||
Actually only the last destroy call of all offical references to the object
|
||||
will really dispose it. All others just decrement the reference counter.
|
||||
Call this function only with official reference pointers obtained by
|
||||
libiso_msgs_new() or libiso_msgs_refer(), and only once per such pointer.
|
||||
@param flag Bitfield for control purposes (unused yet, submit 0)
|
||||
@return 1 for success, 0 for pointer to NULL
|
||||
@return 1 for success, 0 for pointer to NULL, -1 for fatal error
|
||||
*/
|
||||
int libiso_msgs_destroy(struct libiso_msgs **m, int flag);
|
||||
|
||||
|
||||
/** Create an official reference to an existing libiso_msgs object. The
|
||||
references keep the object alive at least until it is released by
|
||||
a matching number of destroy calls. So each reference MUST be revoked
|
||||
by exactly one call to libiso_msgs_destroy().
|
||||
@param pt The pointer to be set and registered
|
||||
@param m A pointer to the existing object
|
||||
@param flag Bitfield for control purposes (unused yet, submit 0)
|
||||
@return 1 for success, 0 for failure
|
||||
*/
|
||||
int libiso_msgs_refer(struct libiso_msgs **pt, struct libiso_msgs *o, int flag);
|
||||
|
||||
|
||||
/** Submit a message to a message handling facility.
|
||||
@param driveno libdax drive number. Use -1 if no number is known.
|
||||
@param origin program specific identification number of the originator of
|
||||
a message. E.g. drive number. Programs should have an own
|
||||
range of origin numbers. See above LIBISO_MSGS_ORIGIN_*_BASE
|
||||
Use -1 if no number is known.
|
||||
@param error_code Unique error code. Use only registered codes. See below.
|
||||
The same unique error_code may be issued at different
|
||||
occasions but those should be equivalent out of the view
|
||||
of a libdax application. (E.g. "cannot open ATA drive"
|
||||
of a libiso_msgs application. (E.g. "cannot open ATA drive"
|
||||
versus "cannot open SCSI drive" would be equivalent.)
|
||||
@param severity The LIBISO_MSGS_SEV_* of the event.
|
||||
@param priority The LIBISO_MSGS_PRIO_* number of the event.
|
||||
@ -180,12 +237,13 @@ int libiso_msgs_destroy(struct libiso_msgs **m, int flag);
|
||||
@param flag Bitfield for control purposes (unused yet, submit 0)
|
||||
@return 1 on success, 0 on rejection, <0 for severe errors
|
||||
*/
|
||||
int libiso_msgs_submit(struct libiso_msgs *m, int driveno, int error_code,
|
||||
int libiso_msgs_submit(struct libiso_msgs *m, int origin, int error_code,
|
||||
int severity, int priority, char *msg_text,
|
||||
int os_errno, int flag);
|
||||
|
||||
|
||||
/* Calls from applications (to be forwarded by libdax/libburn) */
|
||||
|
||||
/* Calls from applications (to be forwarded by direct owner) */
|
||||
|
||||
|
||||
/** Convert a registered severity number into a severity name
|
||||
@ -209,12 +267,12 @@ int libiso_msgs__text_to_sev(char *severity_name, int *severity,
|
||||
LIBISO_MSGS_SEV_ALL) and for messages to be printed directly to stderr
|
||||
(default LIBISO_MSGS_SEV_NEVER).
|
||||
@param print_id A text of at most 80 characters to be printed before
|
||||
any eventually printed message (default is "libdax: ").
|
||||
any eventually printed message (default is "libiso: ").
|
||||
@param flag Bitfield for control purposes (unused yet, submit 0)
|
||||
@return always 1 for now
|
||||
*/
|
||||
int libiso_msgs_set_severities(struct libiso_msgs *m, int queue_severity,
|
||||
int print_severity, const char *print_id, int flag);
|
||||
int print_severity, char *print_id, int flag);
|
||||
|
||||
|
||||
/** Obtain a message item that has at least the given severity and priority.
|
||||
@ -256,7 +314,7 @@ int libiso_msgs_item_get_msg(struct libiso_msgs_item *item,
|
||||
@return 1 on success, 0 on invalid item, <0 for servere errors
|
||||
*/
|
||||
int libiso_msgs_item_get_origin(struct libiso_msgs_item *item,
|
||||
double *timestamp, pid_t *process_id, int *driveno,
|
||||
double *timestamp, pid_t *process_id, int *origin,
|
||||
int flag);
|
||||
|
||||
|
||||
@ -276,7 +334,7 @@ int libiso_msgs_item_get_rank(struct libiso_msgs_item *item,
|
||||
|
||||
|
||||
Format: error_code (LIBISO_MSGS_SEV_*,LIBISO_MSGS_PRIO_*) = explanation
|
||||
If no severity or priority are fixely associates, use "(,)".
|
||||
If no severity or priority are fixely associated, use "(,)".
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Range "libiso_msgs" : 0x00000000 to 0x0000ffff
|
||||
@ -284,6 +342,7 @@ Range "libiso_msgs" : 0x00000000 to 0x0000ffff
|
||||
0x00000000 (ALL,ZERO) = Initial setting in new libiso_msgs_item
|
||||
0x00000001 (DEBUG,ZERO) = Test error message
|
||||
0x00000002 (DEBUG,ZERO) = Debugging message
|
||||
0x00000003 (FATAL,HIGH) = Out of virtual memory
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
@ -304,6 +363,7 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
|
||||
0x00020006 (FATAL,HIGH) = Too many scsi siblings
|
||||
0x00020007 (NOTE,HIGH) = Closed O_EXCL scsi siblings
|
||||
0x00020008 (SORRY,HIGH) = Device busy. Failed to fcntl-lock
|
||||
0x00020009 (SORRY,HIGH) = Neither stdio-path nor its directory exist
|
||||
|
||||
General library operations:
|
||||
|
||||
@ -313,7 +373,7 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
|
||||
0x00020104 (SORRY,HIGH) = NULL pointer caught
|
||||
0x00020105 (SORRY,HIGH) = Drive is already released
|
||||
0x00020106 (SORRY,HIGH) = Drive is busy on attempt to close
|
||||
0x00020107 (SORRY,HIGH) = Drive is busy on attempt to shut down library
|
||||
0x00020107 (WARNING,HIGH) = A drive is still busy on shutdown of library
|
||||
0x00020108 (SORRY,HIGH) = Drive is not grabbed on disc status inquiry
|
||||
0x00020108 (FATAL,HIGH) = Could not allocate new drive object
|
||||
0x00020109 (FATAL,HIGH) = Library not running
|
||||
@ -371,7 +431,31 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
|
||||
0x0002013d (DEBUG,LOW) = Waiting for free buffer space takes long time
|
||||
0x0002013e (SORRY,HIGH) = Timeout with waiting for free buffer. Now disabled
|
||||
0x0002013f (DEBUG,LOW) = Reporting total time spent with waiting for buffer
|
||||
|
||||
0x00020140 (FATAL,HIGH) = Drive is busy on attempt to write random access
|
||||
0x00020141 (SORRY,HIGH) = Write data count not properly aligned
|
||||
0x00020142 (FATAL,HIGH) = Drive is not grabbed on random access write
|
||||
0x00020143 (SORRY,HIGH) = Read start address not properly aligned
|
||||
0x00020144 (SORRY,HIGH) = SCSI error on read
|
||||
0x00020145 (FATAL,HIGH) = Drive is busy on attempt to read data
|
||||
0x00020146 (FATAL,HIGH) = Drive is a virtual placeholder
|
||||
0x00020147 (SORRY,HIGH) = Cannot address start byte
|
||||
0x00020148 (SORRY,HIGH) = Cannot write desired amount of data
|
||||
0x00020149 (SORRY,HIGH) = Unsuitable filetype for pseudo-drive
|
||||
0x0002014a (SORRY,HIGH) = Cannot read desired amount of data
|
||||
0x0002014b (SORRY,HIGH) = Drive is already registered resp. scanned
|
||||
0x0002014c (FATAL,HIGH) = Emulated drive caught in SCSI function
|
||||
0x0002014d (SORRY,HIGH) = Asynchromous SCSI error
|
||||
0x0002014f (SORRY,HIGH) = Timeout with asynchromous SCSI command
|
||||
0x00020150 (DEBUG,LOW) = Reporting asynchronous waiting time
|
||||
0x00020151 (FATAL,HIGH) = Read attempt on write-only drive
|
||||
0x00020152 (FATAL,HIGH) = Cannot start fifo thread
|
||||
0x00020153 (SORRY,HIGH) = Read error on fifo input
|
||||
0x00020154 (NOTE,HIGH) = Forwarded input error ends output
|
||||
0x00020155 (SORRY,HIGH) = Desired fifo buffer too large
|
||||
0x00020156 (SORRY,HIGH) = Desired fifo buffer too small
|
||||
0x00020157 (FATAL,HIGH) = burn_source is not a fifo object
|
||||
0x00020158 (DEBUG,LOW) = Reporting thread disposal precautions
|
||||
0x00020159 (DEBUG,HIGH) = TOC Format 0 returns inconsistent data
|
||||
|
||||
libiso_audioxtr:
|
||||
0x00020200 (SORRY,HIGH) = Cannot open audio source file
|
||||
@ -379,6 +463,7 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
|
||||
0x00020202 (SORRY,HIGH) = Failed to prepare reading of audio data
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Range "vreixo" : 0x00030000 to 0x0003ffff
|
||||
|
||||
@ -424,6 +509,19 @@ Range "vreixo" : 0x00030000 to 0x0003ffff
|
||||
0x00030301 (NOTE,MEDIUM) = Unsupported file type for Joliet tree
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Range "application" : 0x00040000 to 0x0004ffff
|
||||
|
||||
0x00040000 (ABORT,HIGH) : Application supplied message
|
||||
0x00040001 (FATAL,HIGH) : Application supplied message
|
||||
0x00040002 (SORRY,HIGH) : Application supplied message
|
||||
0x00040003 (WARNING,HIGH) : Application supplied message
|
||||
0x00040004 (HINT,HIGH) : Application supplied message
|
||||
0x00040005 (NOTE,HIGH) : Application supplied message
|
||||
0x00040006 (UPDATE,HIGH) : Application supplied message
|
||||
0x00040007 (DEBUG,HIGH) : Application supplied message
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
#endif /* LIDBAX_MSGS_________________ */
|
||||
|
@ -384,7 +384,7 @@ struct iso_read_image_features
|
||||
unsigned int hasJoliet :1;
|
||||
|
||||
/**
|
||||
* It will be set to 1 if the image is an ISO 9660:1999, i.e. it ha
|
||||
* It will be set to 1 if the image is an ISO 9660:1999, i.e. it has
|
||||
* a version 2 Enhanced Volume Descriptor.
|
||||
*/
|
||||
unsigned int hasIso1999 :1;
|
||||
|
Loading…
Reference in New Issue
Block a user