libnjb: deltr.c

libnjb 2.2.7

deltr.c
#include "common.h"
void usage (void);
int main (int argc, char **argv)
{
njb_t njbs[NJB_MAX_DEVICES], *njb;
u_int32_t id;
int n, debug, syntax, opt;
extern int optind;
extern char *optarg;
char *endptr;
debug= syntax= 0;
while ( (opt= getopt(argc, argv, "D:")) != -1 ) {
switch (opt) {
case 'D':
debug= atoi(optarg);
break;
default:
usage();
}
}
argc-= optind;
argv+= optind;
if ( argc != 1 ) usage();
id= strtoul(argv[0], &endptr, 10);
if ( endptr[0] != '\0' ) {
fprintf(stderr, "invalid track id %s\n", argv[0]);
return 1;
}
if ( debug ) NJB_Set_Debug(debug);
if ( NJB_Discover(njbs, 0, &n) == -1 ) {
fprintf(stderr, "could not locate any jukeboxes\n");
return 1;
}
if ( n == 0 ) {
fprintf(stderr, "no NJB devices found\n");
return 0;
}
njb= njbs;
if ( NJB_Open(njb) == -1 ) {
NJB_Error_Dump(njb, stderr);
return 1;
}
if ( NJB_Capture(njb) == -1 ) {
NJB_Error_Dump(njb, stderr);
return 1;
}
if ( NJB_Delete_Track(njb, id) == -1 ) {
NJB_Error_Dump(njb, stderr);
}
NJB_Release(njb);
NJB_Close(njb);
return 0;
}
void usage (void)
{
fprintf(stderr, "usage: deltr [ -D debuglvl ] <trackid>\n");
exit(1);
}
NJB_Discover
int NJB_Discover(njb_t *njbs, int limit, int *n)
Definition: procedure.c:108
NJB_Open
int NJB_Open(njb_t *njb)
Definition: procedure.c:130
NJB_Close
void NJB_Close(njb_t *njb)
Definition: procedure.c:184
njb_struct
Definition: libnjb.h:182
NJB_Capture
int NJB_Capture(njb_t *njb)
Definition: procedure.c:223
NJB_MAX_DEVICES
#define NJB_MAX_DEVICES
Definition: libnjb.h:60
NJB_Delete_Track
int NJB_Delete_Track(njb_t *njb, u_int32_t trackid)
Definition: procedure.c:2415
NJB_Set_Debug
void NJB_Set_Debug(int debug_flags)
Definition: procedure.c:2819
NJB_Error_Dump
void NJB_Error_Dump(njb_t *njb, FILE *fp)
Definition: njb_error.c:418
NJB_Release
int NJB_Release(njb_t *njb)
Definition: procedure.c:266