xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

libiso_msgs.c File Reference
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/time.h>
#include "libiso_msgs.h"
Include dependency graph for libiso_msgs.c:

Go to the source code of this file.

Macros

#define LIBISO_MSGS_H_INTERNAL   1
 

Functions

static int libiso_msgs_item_new (struct libiso_msgs_item **item, struct libiso_msgs_item *link, int flag)
 
int libiso_msgs_item_unlink (struct libiso_msgs_item *o, struct libiso_msgs_item **chain_start, struct libiso_msgs_item **chain_end, int flag)
 
int libiso_msgs_item_destroy (struct libiso_msgs_item **item, int flag)
 
int libiso_msgs_item_get_msg (struct libiso_msgs_item *item, int *error_code, char **msg_text, int *os_errno, int flag)
 
int libiso_msgs_item_get_origin (struct libiso_msgs_item *item, double *timestamp, pid_t *process_id, int *origin, int flag)
 
int libiso_msgs_item_get_rank (struct libiso_msgs_item *item, int *severity, int *priority, int flag)
 
int libiso_msgs_new (struct libiso_msgs **m, int flag)
 
static int libiso_msgs_lock (struct libiso_msgs *m, int flag)
 
static int libiso_msgs_unlock (struct libiso_msgs *m, int flag)
 
int libiso_msgs_destroy (struct libiso_msgs **m, int flag)
 
int libiso_msgs_refer (struct libiso_msgs **pt, struct libiso_msgs *m, int flag)
 
int libiso_msgs_set_severities (struct libiso_msgs *m, int queue_severity, int print_severity, char *print_id, int flag)
 
int libiso_msgs__text_to_sev (char *severity_name, int *severity, int flag)
 
int libiso_msgs__sev_to_text (int severity, char **severity_name, int flag)
 
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)
 
int libiso_msgs_obtain (struct libiso_msgs *m, struct libiso_msgs_item **item, int severity, int priority, int flag)
 
int libiso_msgs_destroy_item (struct libiso_msgs *m, struct libiso_msgs_item **item, int flag)
 

Macro Definition Documentation

◆ LIBISO_MSGS_H_INTERNAL

#define LIBISO_MSGS_H_INTERNAL   1

Definition at line 21 of file libiso_msgs.c.

Function Documentation

◆ libiso_msgs__sev_to_text()

int libiso_msgs__sev_to_text ( int  severity,
char **  severity_name,
int  flag 
)

Convert a registered severity number into a severity name

Parameters
flagBitfield for control purposes: bit0= list all severity names in a blank separated string
Returns
>0 success, <=0 failure

Definition at line 286 of file libiso_msgs.c.

References LIBISO_MSGS_SEV_ABORT, LIBISO_MSGS_SEV_ALL, LIBISO_MSGS_SEV_DEBUG, LIBISO_MSGS_SEV_ERRFILE, LIBISO_MSGS_SEV_FAILURE, LIBISO_MSGS_SEV_FATAL, LIBISO_MSGS_SEV_HINT, LIBISO_MSGS_SEV_MISHAP, LIBISO_MSGS_SEV_NEVER, LIBISO_MSGS_SEV_NOTE, LIBISO_MSGS_SEV_SORRY, LIBISO_MSGS_SEV_UPDATE, and LIBISO_MSGS_SEV_WARNING.

Referenced by iso_obtain_msgs(), iso_sev_to_text(), and libiso_msgs_submit().

◆ libiso_msgs__text_to_sev()

int libiso_msgs__text_to_sev ( char *  severity_name,
int *  severity,
int  flag 
)

◆ libiso_msgs_destroy()

int libiso_msgs_destroy ( 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 official 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.

Parameters
flagBitfield for control purposes (unused yet, submit 0)
Returns
1 for success, 0 for pointer to NULL, -1 for fatal error

Definition at line 190 of file libiso_msgs.c.

References libiso_msgs_item_destroy(), libiso_msgs_lock(), and libiso_msgs_unlock().

Referenced by iso_finish().

◆ libiso_msgs_destroy_item()

int libiso_msgs_destroy_item ( struct libiso_msgs *  m,
struct libiso_msgs_item **  item,
int  flag 
)

Destroy a message item obtained by libiso_msgs_obtain(). The submitted pointer gets set to NULL. Caution: Copy eventually obtained msg_text before destroying the item, if you want to use it further.

Parameters
flagBitfield for control purposes (unused yet, submit 0)
Returns
1 for success, 0 for pointer to NULL, <0 for severe errors

Definition at line 430 of file libiso_msgs.c.

References libiso_msgs_item_destroy(), libiso_msgs_lock(), and libiso_msgs_unlock().

Referenced by iso_obtain_msgs().

◆ libiso_msgs_item_destroy()

int libiso_msgs_item_destroy ( struct libiso_msgs_item **  item,
int  flag 
)

◆ libiso_msgs_item_get_msg()

int libiso_msgs_item_get_msg ( struct libiso_msgs_item *  item,
int *  error_code,
char **  msg_text,
int *  os_errno,
int  flag 
)

Obtain from a message item the three application oriented components as submitted with the originating call of libiso_msgs_submit(). Caution: msg_text becomes a pointer into item, not a copy.

Parameters
flagBitfield for control purposes (unused yet, submit 0)
Returns
1 on success, 0 on invalid item, <0 for servere errors

Definition at line 103 of file libiso_msgs.c.

Referenced by iso_obtain_msgs().

◆ libiso_msgs_item_get_origin()

int libiso_msgs_item_get_origin ( struct libiso_msgs_item *  item,
double *  timestamp,
pid_t *  process_id,
int *  origin,
int  flag 
)

Obtain from a message item the submitter identification submitted with the originating call of libiso_msgs_submit().

Parameters
flagBitfield for control purposes (unused yet, submit 0)
Returns
1 on success, 0 on invalid item, <0 for servere errors

Definition at line 114 of file libiso_msgs.c.

Referenced by iso_obtain_msgs().

◆ libiso_msgs_item_get_rank()

int libiso_msgs_item_get_rank ( struct libiso_msgs_item *  item,
int *  severity,
int *  priority,
int  flag 
)

Obtain from a message item severity and priority as submitted with the originating call of libiso_msgs_submit().

Parameters
flagBitfield for control purposes (unused yet, submit 0)
Returns
1 on success, 0 on invalid item, <0 for servere errors

Definition at line 125 of file libiso_msgs.c.

Referenced by iso_obtain_msgs().

◆ libiso_msgs_item_new()

static int libiso_msgs_item_new ( struct libiso_msgs_item **  item,
struct libiso_msgs_item *  link,
int  flag 
)
static

Definition at line 30 of file libiso_msgs.c.

References LIBISO_MSGS_PRIO_ZERO, and LIBISO_MSGS_SEV_ALL.

Referenced by libiso_msgs_submit().

◆ libiso_msgs_item_unlink()

int libiso_msgs_item_unlink ( struct libiso_msgs_item *  o,
struct libiso_msgs_item **  chain_start,
struct libiso_msgs_item **  chain_end,
int  flag 
)

Detaches item from its queue and eventually readjusts start, end pointers of the queue

Definition at line 67 of file libiso_msgs.c.

Referenced by libiso_msgs_item_destroy(), and libiso_msgs_obtain().

◆ libiso_msgs_lock()

static int libiso_msgs_lock ( struct libiso_msgs *  m,
int  flag 
)
static

◆ libiso_msgs_new()

int libiso_msgs_new ( struct libiso_msgs **  m,
int  flag 
)

Create new empty message handling facility with queue and issue a first official reference to it.

Parameters
flagBitfield for control purposes (unused yet, submit 0)
Returns
>0 success, <=0 failure

Definition at line 137 of file libiso_msgs.c.

References LIBISO_MSGS_SEV_ALL, and LIBISO_MSGS_SEV_NEVER.

Referenced by iso_init_with_flag().

◆ libiso_msgs_obtain()

int libiso_msgs_obtain ( struct libiso_msgs *  m,
struct libiso_msgs_item **  item,
int  severity,
int  priority,
int  flag 
)

Obtain a message item that has at least the given severity and priority. Usually all older messages of lower severity are discarded then. If no item of sufficient severity was found, all others are discarded from the queue.

Parameters
flagBitfield for control purposes (unused yet, submit 0)
Returns
1 if a matching item was found, 0 if not, <0 for severe errors

Definition at line 396 of file libiso_msgs.c.

References libiso_msgs_item_destroy(), libiso_msgs_item_unlink(), libiso_msgs_lock(), and libiso_msgs_unlock().

Referenced by iso_obtain_msgs().

◆ libiso_msgs_refer()

int libiso_msgs_refer ( struct libiso_msgs **  pt,
struct libiso_msgs *  o,
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().

Parameters
ptThe pointer to be set and registered
mA pointer to the existing object
flagBitfield for control purposes (unused yet, submit 0)
Returns
1 for success, 0 for failure

Definition at line 224 of file libiso_msgs.c.

References libiso_msgs_lock(), and libiso_msgs_unlock().

◆ libiso_msgs_set_severities()

int libiso_msgs_set_severities ( struct libiso_msgs *  m,
int  queue_severity,
int  print_severity,
char *  print_id,
int  flag 
)

Set minimum severity for messages to be queued (default LIBISO_MSGS_SEV_ALL) and for messages to be printed directly to stderr (default LIBISO_MSGS_SEV_NEVER).

Parameters
print_idA text of at most 80 characters to be printed before any eventually printed message (default is "libiso: ").
flagBitfield for control purposes (unused yet, submit 0)
Returns
always 1 for now

Definition at line 235 of file libiso_msgs.c.

References libiso_msgs_lock(), and libiso_msgs_unlock().

Referenced by iso_init_with_flag(), and iso_set_msgs_severities().

◆ libiso_msgs_submit()

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 
)

Submit a message to a message handling facility.

Parameters
originprogram 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.
error_codeUnique 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 libiso_msgs application. (E.g. "cannot open ATA drive" versus "cannot open SCSI drive" would be equivalent.)
severityThe LIBISO_MSGS_SEV_* of the event.
priorityThe LIBISO_MSGS_PRIO_* number of the event.
msg_textPrintable and human readable message text.
os_errnoEventual error code from operating system (0 if none)
flagBitfield for control purposes (unused yet, submit 0)
Returns
1 on success, 0 on rejection, <0 for severe errors

Definition at line 328 of file libiso_msgs.c.

References libiso_msgs__sev_to_text(), libiso_msgs_item_destroy(), libiso_msgs_item_new(), libiso_msgs_lock(), and libiso_msgs_unlock().

Referenced by iso_msg_debug(), iso_msg_submit(), iso_msgs_submit(), and iso_report_errfile().

◆ libiso_msgs_unlock()

static int libiso_msgs_unlock ( struct libiso_msgs *  m,
int  flag 
)
static