Made first use of queued messages and fixed several bugs with that
This commit is contained in:
parent
44c85d1f2c
commit
8dc65b7e4b
@ -1136,6 +1136,8 @@ struct CdrpreskiN {
|
|||||||
|
|
||||||
/* to be transfered into skin */
|
/* to be transfered into skin */
|
||||||
int verbosity;
|
int verbosity;
|
||||||
|
char queue_severity[81];
|
||||||
|
char print_severity[81];
|
||||||
|
|
||||||
/** Stores eventually given absolute device address before translation */
|
/** Stores eventually given absolute device address before translation */
|
||||||
char raw_device_adr[Cdrskin_adrleN];
|
char raw_device_adr[Cdrskin_adrleN];
|
||||||
@ -1225,6 +1227,8 @@ int Cdrpreskin_new(struct CdrpreskiN **preskin, int flag)
|
|||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
o->verbosity= 0;
|
o->verbosity= 0;
|
||||||
|
strcpy(o->queue_severity,"NEVER");
|
||||||
|
strcpy(o->print_severity,"SORRY");
|
||||||
o->raw_device_adr[0]= 0;
|
o->raw_device_adr[0]= 0;
|
||||||
o->device_adr[0]= 0;
|
o->device_adr[0]= 0;
|
||||||
o->adr_trn= NULL;
|
o->adr_trn= NULL;
|
||||||
@ -1282,15 +1286,32 @@ int Cdrpreskin_destroy(struct CdrpreskiN **preskin, int flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Cdrpreskin_set_severities(struct CdrpreskiN *preskin, char *queue_severity,
|
||||||
|
char *print_severity, int flag)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(queue_severity!=NULL)
|
||||||
|
strcpy(preskin->queue_severity,queue_severity);
|
||||||
|
if(print_severity!=NULL)
|
||||||
|
strcpy(preskin->print_severity,print_severity);
|
||||||
|
#ifdef Cdrskin_libburn_has_burn_msgS
|
||||||
|
burn_msgs_set_severities(preskin->queue_severity, preskin->print_severity,
|
||||||
|
"cdrskin: ");
|
||||||
|
#endif
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int Cdrpreskin_initialize_lib(struct CdrpreskiN *preskin, int flag)
|
int Cdrpreskin_initialize_lib(struct CdrpreskiN *preskin, int flag)
|
||||||
{
|
{
|
||||||
if(!burn_initialize()) {
|
int ret;
|
||||||
|
|
||||||
|
ret= burn_initialize();
|
||||||
|
if(ret==0) {
|
||||||
fprintf(stderr,"cdrskin : FATAL : Initialization of libburn failed\n");
|
fprintf(stderr,"cdrskin : FATAL : Initialization of libburn failed\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
#ifdef Cdrskin_libburn_has_burn_msgS
|
Cdrpreskin_set_severities(preskin,NULL,NULL,0);
|
||||||
burn_msgs_set_severities("NEVER","SORRY","cdrskin: ");
|
|
||||||
#endif
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1761,12 +1782,8 @@ see_cdrskin_eng_html:;
|
|||||||
} else if(strcmp(argv[i],"-v")==0 || strcmp(argv[i],"-verbose")==0) {
|
} else if(strcmp(argv[i],"-v")==0 || strcmp(argv[i],"-verbose")==0) {
|
||||||
(o->verbosity)++;
|
(o->verbosity)++;
|
||||||
printf("cdrskin: verbosity level : %d\n",o->verbosity);
|
printf("cdrskin: verbosity level : %d\n",o->verbosity);
|
||||||
|
|
||||||
#ifdef Cdrskin_libburn_has_burn_msgS
|
|
||||||
if(o->verbosity>=Cdrskin_verbose_debuG)
|
if(o->verbosity>=Cdrskin_verbose_debuG)
|
||||||
burn_msgs_set_severities("NEVER","DEBUG","cdrskin: ");
|
Cdrpreskin_set_severities(o,"DEBUG","DEBUG",0);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
} else if(strcmp(argv[i],"-version")==0) {
|
} else if(strcmp(argv[i],"-version")==0) {
|
||||||
printf(
|
printf(
|
||||||
@ -1852,7 +1869,7 @@ dev_too_long:;
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"cdrskin: NOTE : Please inform libburn-hackers@pykix.org about:\n");
|
"cdrskin: NOTE : Please inform libburn-hackers@pykix.org about:\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" burn_drive_convert_fs_adr() returned %d\n",lret);
|
"cdrskin: burn_drive_convert_fs_adr() returned %d\n",lret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4471,6 +4488,7 @@ int Cdrskin_create(struct CdrskiN **o, struct CdrpreskiN **preskin,
|
|||||||
int *exit_value, int flag)
|
int *exit_value, int flag)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
char queue_severity[81],print_severity[81];
|
||||||
struct CdrskiN *skin;
|
struct CdrskiN *skin;
|
||||||
|
|
||||||
*o= NULL;
|
*o= NULL;
|
||||||
@ -4503,16 +4521,71 @@ int Cdrskin_create(struct CdrskiN **o, struct CdrpreskiN **preskin,
|
|||||||
|
|
||||||
printf("cdrskin: scanning for devices ...\n");
|
printf("cdrskin: scanning for devices ...\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
while (!burn_drive_scan(&(skin->drives), &(skin->n_drives))) {
|
|
||||||
|
#define Cdrskin_debug_libdax_msgS
|
||||||
/*
|
/*
|
||||||
if(skin->verbosity>=Cdrskin_verbose_debuG)
|
|
||||||
ClN(fprintf(stderr,"cdrskin_debug: ... still scanning ...\n"));
|
|
||||||
*/
|
*/
|
||||||
|
/* <<< In cdrskin there is not much sense in queueing library messages.
|
||||||
|
It is done here only for debugging */
|
||||||
|
#ifdef Cdrskin_debug_libdax_msgS
|
||||||
|
|
||||||
|
strcpy(queue_severity,skin->preskin->queue_severity);
|
||||||
|
strcpy(print_severity,skin->preskin->print_severity);
|
||||||
|
Cdrpreskin_set_severities(skin->preskin,"NOTE","NEVER",0);
|
||||||
|
|
||||||
|
#endif /* Cdrskin_debug_libdax_msgS */
|
||||||
|
|
||||||
|
while (!burn_drive_scan(&(skin->drives), &(skin->n_drives))) {
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
/* >>> ??? set a timeout ? */
|
/* >>> ??? set a timeout ? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef Cdrskin_debug_libdax_msgS
|
||||||
|
|
||||||
|
Cdrpreskin_set_severities(skin->preskin,queue_severity,print_severity,0);
|
||||||
|
|
||||||
|
#endif /* Cdrskin_debug_libdax_msgS */
|
||||||
|
|
||||||
printf("cdrskin: ... scanning for devices done\n");
|
printf("cdrskin: ... scanning for devices done\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef Cdrskin_debug_libdax_msgS
|
||||||
|
#ifdef Cdrskin_libburn_has_burn_msgS
|
||||||
|
|
||||||
|
{
|
||||||
|
char msg[BURN_MSGS_MESSAGE_LEN],msg_severity[81],filler[81];
|
||||||
|
int error_code,os_errno,first,i;
|
||||||
|
|
||||||
|
for(first= 1; ; first= 0) {
|
||||||
|
ret= burn_msgs_obtain("ALL",&error_code,msg,&os_errno,msg_severity);
|
||||||
|
if(ret==0)
|
||||||
|
break;
|
||||||
|
if(ret<0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"cdrskin: NOTE : Please inform libburn-hackers@pykix.org about:\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
"cdrskin: burn_msgs_obtain() returns %d\n",ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for(i=0;msg_severity[i]!=0;i++)
|
||||||
|
filler[i]= ' ';
|
||||||
|
filler[i]= 0;
|
||||||
|
if(first)
|
||||||
|
fprintf(stderr,
|
||||||
|
"cdrskin: -------------------- Messages from scanning --------------------\n");
|
||||||
|
fprintf(stderr,"cdrskin: %s : %s\n",msg_severity,msg);
|
||||||
|
fprintf(stderr,"cdrskin: %s ( code=%X , os_errno=%d )\n",
|
||||||
|
filler,error_code,os_errno);
|
||||||
|
}
|
||||||
|
if(first==0)
|
||||||
|
fprintf(stderr,
|
||||||
|
"cdrskin: ----------------------------------------------------------------\n");
|
||||||
|
}
|
||||||
|
#endif /* Cdrskin_libburn_has_burn_msgS */
|
||||||
|
#endif /* Cdrskin_debug_libdax_msgS */
|
||||||
|
|
||||||
ex:;
|
ex:;
|
||||||
return((*exit_value)==0);
|
return((*exit_value)==0);
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
#define Cdrskin_timestamP "2006.09.25.144506"
|
#define Cdrskin_timestamP "2006.09.26.114552"
|
||||||
|
@ -44,10 +44,11 @@ int burn_msgs_initialize(void)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if(libdax_messenger == NULL)
|
if(libdax_messenger == NULL) {
|
||||||
ret = libdax_msgs_new(&libdax_messenger,0);
|
ret = libdax_msgs_new(&libdax_messenger,0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
libdax_msgs_set_severities(libdax_messenger, LIBDAX_MSGS_SEV_NEVER,
|
libdax_msgs_set_severities(libdax_messenger, LIBDAX_MSGS_SEV_NEVER,
|
||||||
LIBDAX_MSGS_SEV_FATAL, "libburn: ", 0);
|
LIBDAX_MSGS_SEV_FATAL, "libburn: ", 0);
|
||||||
return 1;
|
return 1;
|
||||||
@ -173,7 +174,6 @@ int burn_msgs_obtain(char *minimum_severity,
|
|||||||
LIBDAX_MSGS_PRIO_ZERO, 0);
|
LIBDAX_MSGS_PRIO_ZERO, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
|
|
||||||
ret = libdax_msgs_item_get_msg(item, error_code, &textpt, os_errno, 0);
|
ret = libdax_msgs_item_get_msg(item, error_code, &textpt, os_errno, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
|
@ -1110,7 +1110,7 @@ int burn_msgs_set_severities(char *queue_severity,
|
|||||||
char *print_severity, char *print_id);
|
char *print_severity, char *print_id);
|
||||||
|
|
||||||
/* ts A60924 : ticket 74 */
|
/* ts A60924 : ticket 74 */
|
||||||
#define BURM_MSGS_MESSAGE_LEN 4096
|
#define BURN_MSGS_MESSAGE_LEN 4096
|
||||||
|
|
||||||
/** Obtain the oldest pending libburn message from the queue which has at
|
/** Obtain the oldest pending libburn message from the queue which has at
|
||||||
least the given minimum_severity. This message and any older message of
|
least the given minimum_severity. This message and any older message of
|
||||||
@ -1120,7 +1120,7 @@ int burn_msgs_set_severities(char *queue_severity,
|
|||||||
will discard the whole queue.
|
will discard the whole queue.
|
||||||
@param error_code Will become a unique error code as liste in
|
@param error_code Will become a unique error code as liste in
|
||||||
libburn/libdax_msgs.h
|
libburn/libdax_msgs.h
|
||||||
@param msg_text Must provide at least BURM_MSGS_MESSAGE_LEN bytes.
|
@param msg_text Must provide at least BURN_MSGS_MESSAGE_LEN bytes.
|
||||||
@param os_errno Will become the eventual errno related to the message
|
@param os_errno Will become the eventual errno related to the message
|
||||||
@param severity Will become the severity related to the message and
|
@param severity Will become the severity related to the message and
|
||||||
should provide at least 80 bytes.
|
should provide at least 80 bytes.
|
||||||
|
@ -58,6 +58,27 @@ static int libdax_msgs_item_new(struct libdax_msgs_item **item,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Detaches item from its queue and eventually readjusts start, end pointers
|
||||||
|
of the queue */
|
||||||
|
int libdax_msgs_item_unlink(struct libdax_msgs_item *o,
|
||||||
|
struct libdax_msgs_item **chain_start,
|
||||||
|
struct libdax_msgs_item **chain_end, int flag)
|
||||||
|
{
|
||||||
|
if(o->prev!=NULL)
|
||||||
|
o->prev->next= o->next;
|
||||||
|
if(o->next!=NULL)
|
||||||
|
o->next->prev= o->prev;
|
||||||
|
if(chain_start!=NULL)
|
||||||
|
if(*chain_start == o)
|
||||||
|
*chain_start= o->next;
|
||||||
|
if(chain_end!=NULL)
|
||||||
|
if(*chain_end == o)
|
||||||
|
*chain_end= o->prev;
|
||||||
|
o->next= o->prev= NULL;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int libdax_msgs_item_destroy(struct libdax_msgs_item **item,
|
int libdax_msgs_item_destroy(struct libdax_msgs_item **item,
|
||||||
int flag)
|
int flag)
|
||||||
{
|
{
|
||||||
@ -66,12 +87,9 @@ int libdax_msgs_item_destroy(struct libdax_msgs_item **item,
|
|||||||
o= *item;
|
o= *item;
|
||||||
if(o==NULL)
|
if(o==NULL)
|
||||||
return(0);
|
return(0);
|
||||||
|
libdax_msgs_item_unlink(o,NULL,NULL,0);
|
||||||
if(o->msg_text!=NULL)
|
if(o->msg_text!=NULL)
|
||||||
free((char *) o->msg_text);
|
free((char *) o->msg_text);
|
||||||
if(o->prev!=NULL)
|
|
||||||
o->prev->next= o->next;
|
|
||||||
if(o->next!=NULL)
|
|
||||||
o->next->prev= o->prev;
|
|
||||||
free((char *) o);
|
free((char *) o);
|
||||||
*item= NULL;
|
*item= NULL;
|
||||||
return(1);
|
return(1);
|
||||||
@ -314,6 +332,8 @@ int libdax_msgs_submit(struct libdax_msgs *m, int driveno, int error_code,
|
|||||||
strcpy(item->msg_text,msg_text);
|
strcpy(item->msg_text,msg_text);
|
||||||
}
|
}
|
||||||
item->os_errno= os_errno;
|
item->os_errno= os_errno;
|
||||||
|
if(m->oldest==NULL)
|
||||||
|
m->oldest= item;
|
||||||
m->youngest= item;
|
m->youngest= item;
|
||||||
m->count++;
|
m->count++;
|
||||||
libdax_msgs_unlock(m,0);
|
libdax_msgs_unlock(m,0);
|
||||||
@ -337,6 +357,7 @@ int libdax_msgs_obtain(struct libdax_msgs *m, struct libdax_msgs_item **item,
|
|||||||
int ret;
|
int ret;
|
||||||
struct libdax_msgs_item *im, *next_im= NULL;
|
struct libdax_msgs_item *im, *next_im= NULL;
|
||||||
|
|
||||||
|
*item= NULL;
|
||||||
ret= libdax_msgs_lock(m,0);
|
ret= libdax_msgs_lock(m,0);
|
||||||
if(ret<=0)
|
if(ret<=0)
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -345,6 +366,7 @@ int libdax_msgs_obtain(struct libdax_msgs *m, struct libdax_msgs_item **item,
|
|||||||
next_im= im->next;
|
next_im= im->next;
|
||||||
if(im->severity>=severity)
|
if(im->severity>=severity)
|
||||||
break;
|
break;
|
||||||
|
libdax_msgs_item_unlink(im,&(m->oldest),&(m->youngest),0);
|
||||||
libdax_msgs_item_destroy(&im,0); /* severity too low: delete */
|
libdax_msgs_item_destroy(&im,0); /* severity too low: delete */
|
||||||
}
|
}
|
||||||
if(im==NULL)
|
if(im==NULL)
|
||||||
@ -354,6 +376,7 @@ int libdax_msgs_obtain(struct libdax_msgs *m, struct libdax_msgs_item **item,
|
|||||||
}
|
}
|
||||||
if(im==NULL)
|
if(im==NULL)
|
||||||
{ret= 0; goto ex;}
|
{ret= 0; goto ex;}
|
||||||
|
libdax_msgs_item_unlink(im,&(m->oldest),&(m->youngest),0);
|
||||||
*item= im;
|
*item= im;
|
||||||
ret= 1;
|
ret= 1;
|
||||||
ex:;
|
ex:;
|
||||||
|
Loading…
Reference in New Issue
Block a user