diff -aburN cdde-0.2.0/CHANGELOG lccdde-0.3.0/CHANGELOG --- cdde-0.2.0/CHANGELOG 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/CHANGELOG 2007-12-17 15:21:04.000000000 +0000 @@ -1,3 +1,11 @@ +Version 0.3.0 +============= +17/12/07 + +* libxml have been disabled +* to run cdde : cdde -d /dev/cdrom +* exec progs must be in $HOME/.cdde/prog_type + Version 0.2.0 ============= 11/17/04 diff -aburN cdde-0.2.0/configure.in lccdde-0.3.0/configure.in --- cdde-0.2.0/configure.in 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/configure.in 2007-12-17 17:16:56.000000000 +0000 @@ -1,6 +1,6 @@ dnl This is an autoconf script to generate a configure script AC_INIT(src/cdde.c) -AM_INIT_AUTOMAKE(cdde, 0.2.0) +AM_INIT_AUTOMAKE(cdde, 0.3.0) dnl Specify a header configureation file AM_CONFIG_HEADER(src/config.h) @@ -12,11 +12,9 @@ CFLAGS="" dnl Checks for libraries. -AM_PATH_XML2(2.6.13,,AC_MSG_ERROR([*** libxml2 >= 2.6.13 not installed - please install ***])) AC_OUTPUT( Makefile src/Makefile cdde.1 - cdde.xml.5 ) diff -aburN cdde-0.2.0/Makefile.am lccdde-0.3.0/Makefile.am --- cdde-0.2.0/Makefile.am 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/Makefile.am 2007-12-17 17:18:25.000000000 +0000 @@ -1,3 +1,3 @@ SUBDIRS = src -man_MANS = cdde.1 cdde.xml.5 +man_MANS = cdde.1 diff -aburN cdde-0.2.0/src/cdde.c lccdde-0.3.0/src/cdde.c --- cdde-0.2.0/src/cdde.c 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/src/cdde.c 2007-12-17 15:29:21.000000000 +0000 @@ -33,6 +33,7 @@ #include #include #include +#include // my headers #include "config.h" @@ -46,7 +47,7 @@ /////////////////////// char * datatags[] = { "audio", "data", "dvd", "mixed", "blank", "vcd", "svcd" }; extern int errno; // for error checking -char * filename = NULL; // the config file filename +char * filename = NULL; // the cdrom device int keeprunning = 1; // keep checking drives int numchildren = 0; // the number of children we have executed int delay; // the polling delay @@ -73,7 +74,7 @@ { removedrive(0); } - + /* V0.0.3 // make sure the config file is there if (stat(filename, &fileinfo) == -1) { @@ -81,13 +82,6 @@ { case ENOENT: syslog(LOG_ERR, "Error: Config file %s does not exist!", filename); - if (saveconfig(filename)) - { - syslog(LOG_ERR, "Error: Couldn't create template file."); - } else { - syslog(LOG_INFO, "I created a template configuration file located at %s", filename); - syslog(LOG_INFO, "I suggest you edit it to make sure the values are useful before you run cdde again."); - } break; case EACCES: syslog(LOG_ERR, "Error: Can't read from config file %s", filename); @@ -96,7 +90,7 @@ exit (1); } - + V0.0.3 */ // read the config file if (loadconfig(filename)) { @@ -349,21 +343,6 @@ // remove a drive from the list void removedrive(unsigned int drivenum) { - xmlChar * data; - drive * d; - int i; - - drives = list_removenth(drives, (void **)&d, drivenum); - - for (i=0; icommands[i]) > 0) - { - d->commands[i] = list_pop(d->commands[i], (void **)&data); - xmlFree(data); - } - } - free(d); } @@ -379,10 +358,10 @@ { // create string representing where the config file is filename = (char *) strdup(getenv("HOME")); - filename = realloc(filename, ((strlen(filename)+1) + strlen("/.cdde.xml")) * sizeof(char)); - filename = (char *) strcat(filename, "/.cdde.xml"); + filename = realloc(filename, ((strlen(filename)+1) + strlen("/.cdde.conf")) * sizeof(char)); + filename = (char *) strcat(filename, "/.cdde.conf"); } - + /* V0.0.3 // make sure the config file is there if (stat(filename, &fileinfo) == -1) { @@ -390,13 +369,6 @@ { case ENOENT: fprintf(stderr, "Error: Config file %s does not exist!\n", filename); - if (saveconfig(filename)) - { - fprintf(stderr, "Error: Couldn't create template file.\n"); - } else { - printf("I created a template configuration file located at %s\n", filename); - printf("I suggest you edit it to make sure the values are useful before you run cdde again.\n"); - } break; case EACCES: fprintf(stderr, "Error: Can't read from config file %s!\n", filename); @@ -404,6 +376,7 @@ } return 0; } + V0.0.3 */ if (!batchmode) daemonize(); // don't call printf after this point (we don't have a terminal anymore) syslog(LOG_INFO, "CDDE v%s started", VERSION); @@ -431,8 +404,9 @@ { if (checkdrive((drive *)list_nth(drives, i)) != 0) { - removedrive(i); - i--; + // removedrive(i); + // i--; + return 1; } } if (batchmode) break; diff -aburN cdde-0.2.0/src/cdde.h lccdde-0.3.0/src/cdde.h --- cdde-0.2.0/src/cdde.h 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/src/cdde.h 2007-12-17 15:16:27.000000000 +0000 @@ -20,6 +20,7 @@ For more details see the file COPYING */ +#include #ifndef __cdde_h__ #define __cdde_h__ @@ -40,7 +41,7 @@ // globals /////////////////////// extern char * datatags[]; -extern char * filename; // the config file filename +extern char * filename; // the CD/DVD device extern int numchildren; // the number of children we have executed extern int delay; // the polling delay #include "list.h" diff -aburN cdde-0.2.0/src/configfile.c lccdde-0.3.0/src/configfile.c --- cdde-0.2.0/src/configfile.c 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/src/configfile.c 2007-12-17 15:26:19.000000000 +0000 @@ -29,87 +29,28 @@ #include extern int errno; +typedef struct _drive2 +{ + char * filename; + list * commands[NUM_DATA_TYPES]; + int dontexecute; +} drive2; + + // read a configuration file // returns nonzero on error int loadconfig(char * filename) { - xmlDocPtr doc = NULL; - xmlNodePtr cur = NULL; - char * temp = NULL; - - // parse the document - doc = xmlParseFile(filename); - if (doc == NULL) - { - syslog(LOG_ERR, "Error: Could not parse document"); - xmlFreeDoc(doc); - return 1; - } - - // get the root node - cur = xmlDocGetRootElement(doc); - if (cur == NULL) - { - syslog(LOG_ERR, "Error: Could not parse document: unable to find root element"); - xmlFreeDoc(doc); - return 1; - } - - // make sure the root is a "cdde" - if (xmlStrcmp(cur->name, (const xmlChar *) "cdde")) - { - syslog(LOG_ERR, "Error: Could not parse document: root element is not \"cdde\""); - xmlFreeDoc(doc); - return 1; - } - - // find the delay - temp = xmlGetProp(cur, (const xmlChar *) "delay"); - if (temp == NULL) - { - syslog(LOG_WARNING, "Warning: Did not find polling delay in config file, using %d", DEFAULT_SLEEP_N); - delay = DEFAULT_SLEEP_N; - } else { - errno = 0; - delay = strtol(temp, NULL, 10); - if (errno != 0) - { - syslog(LOG_WARNING, "Warning: Delay had under/overflow, using %d", DEFAULT_SLEEP_N); - delay = DEFAULT_SLEEP_N; - } - if (delay < 0) - { - syslog(LOG_WARNING, "Warning: Delay can't be negative, using %d", DEFAULT_SLEEP_N); - delay = DEFAULT_SLEEP_N; - } - - xmlFree(temp); - } - if (verbose) syslog(LOG_INFO, "Using polling delay of %d microseconds", delay); - - // find all of the children - cur = cur->xmlChildrenNode; - while (cur != NULL) - { - if (!xmlStrcmp(cur->name, (const xmlChar *) "drive")) - { - parsedrive(cur); - } - cur = cur->next; - } - xmlFreeDoc(doc); - + parsedrive("sr0"); return 0; } -// parse the nodes -// and their children -void parsedrive(xmlNodePtr cur) +void parsedrive(char * drive) { int i; - drive * d = malloc(sizeof(drive)); - xmlChar * data; - +// FIXME : why drive fails gcc + drive2 * d = malloc(sizeof(drive2)); + char buffer[255]; if (d == NULL) { syslog(LOG_ERR, "Error: Couldn't allocate memory for drive"); @@ -121,28 +62,21 @@ } d->dontexecute = dontrunfirst; - d->filename = xmlGetProp(cur, "path"); - - // search it's children for commands, and add them - cur = cur->xmlChildrenNode; - while (cur != NULL) - { + // d->filename = "/dev/hdc"; + d->filename = filename; + syslog(LOG_INFO, "Loading configs for %s \n", d->filename); for (i=0; iname, (const xmlChar *) datatags[i])) - { - data = xmlGetProp(cur, "command"); - d->commands[i] = list_push(d->commands[i], data); + sprintf(buffer,"%s%s%s",getenv("HOME"),"/.cdde/autoexec/",datatags[i]); + // syslog(LOG_INFO, "i : %d : %s \n",i,datatags[i]); + syslog(LOG_INFO, "%s \n",buffer); + // d->commands[i] = list_push(d->commands[i],"/bin/audiocd"); + d->commands[i] = list_push(d->commands[i],buffer); if (d->commands[i] == NULL) { syslog(LOG_ERR, "Error: Couldn't allocate memory"); exit(1); } - - break; - } - } - cur = cur->next; } drives = list_push(drives, d); if (drives == NULL) @@ -151,71 +85,3 @@ exit(1); } } - -// write a template configuation file -// returns zero on success -int saveconfig(char * filename) -{ - xmlDocPtr doc; - xmlNodePtr cur; - xmlNodePtr root; - xmlNodePtr subroot; - int retval = 0; - - // create the root - root = xmlNewNode(NULL, (xmlChar *) "cdde"); - xmlSetProp(root, (xmlChar *) "delay", (xmlChar *) DEFAULT_SLEEP_S); - - // add a drive - // FIXME: try to guess cdrom device paths by looking at fstab - subroot = xmlNewNode(NULL, (xmlChar *) "drive"); - xmlSetProp(subroot, (xmlChar *) "path", (xmlChar *) "/dev/cdrom"); - xmlAddChild(root, subroot); - - // add commands - cur = xmlNewNode(NULL, (xmlChar *) "audio"); - xmlSetProp(cur, (xmlChar *) "command", (xmlChar *) "echo A audio cd was inserted."); - xmlAddChild(subroot, cur); - - // add commands - cur = xmlNewNode(NULL, (xmlChar *) "data"); - xmlSetProp(cur, (xmlChar *) "command", (xmlChar *) "echo A data cd was inserted."); - xmlAddChild(subroot, cur); - - // add commands - cur = xmlNewNode(NULL, (xmlChar *) "dvd"); - xmlSetProp(cur, (xmlChar *) "command", (xmlChar *) "echo A dvd was inserted."); - xmlAddChild(subroot, cur); - - // add commands - cur = xmlNewNode(NULL, (xmlChar *) "vcd"); - xmlSetProp(cur, (xmlChar *) "command", (xmlChar *) "echo A vcd was inserted."); - xmlAddChild(subroot, cur); - - // add commands - cur = xmlNewNode(NULL, (xmlChar *) "svcd"); - xmlSetProp(cur, (xmlChar *) "command", (xmlChar *) "echo A svcd was inserted."); - xmlAddChild(subroot, cur); - - // add commands - cur = xmlNewNode(NULL, (xmlChar *) "blank"); - xmlSetProp(cur, (xmlChar *) "command", (xmlChar *) "echo A blank cdr was inserted."); - xmlAddChild(subroot, cur); - - // add commands - cur = xmlNewNode(NULL, (xmlChar *) "mixed"); - xmlSetProp(cur, (xmlChar *) "command", (xmlChar *) "echo A mixed (audio/data) cd was inserted."); - xmlAddChild(subroot, cur); - - // create the document - doc = xmlNewDoc("1.0"); - xmlDocSetRootElement(doc, root); - - // write out the xml document - if (xmlSaveFormatFile (filename, doc, 1) == -1) retval = -1; - - // free memory - xmlFreeDoc(doc); - - return retval; -} diff -aburN cdde-0.2.0/src/configfile.h lccdde-0.3.0/src/configfile.h --- cdde-0.2.0/src/configfile.h 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/src/configfile.h 2007-12-14 11:24:32.000000000 +0000 @@ -24,13 +24,9 @@ #ifndef __configfile_h__ #define __configfile_h__ -// libxml headers -#include -#include - // read a configuration file int loadconfig(char * filename); -void parsedrive(xmlNodePtr cur); +void parsedrive(char * drive); // write a template configuation file int saveconfig(char * filename); diff -aburN cdde-0.2.0/src/Makefile.am lccdde-0.3.0/src/Makefile.am --- cdde-0.2.0/src/Makefile.am 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/src/Makefile.am 2007-12-14 11:25:05.000000000 +0000 @@ -7,7 +7,5 @@ string.c string.h \ list.c list.h -INCLUDES = @XML_CPPFLAGS@ -LDADD = @XML_LIBS@ CLEANFILES = *~ DISTCLEANFILES = .deps/*.P diff -aburN cdde-0.2.0/src/stamp-h1 lccdde-0.3.0/src/stamp-h1 --- cdde-0.2.0/src/stamp-h1 1970-01-01 00:00:00.000000000 +0000 +++ lccdde-0.3.0/src/stamp-h1 2007-12-17 17:18:35.000000000 +0000 @@ -0,0 +1 @@ +timestamp for src/config.h diff -aburN cdde-0.2.0/src/util.c lccdde-0.3.0/src/util.c --- cdde-0.2.0/src/util.c 2004-11-18 03:22:04.000000000 +0000 +++ lccdde-0.3.0/src/util.c 2007-12-17 17:21:11.000000000 +0000 @@ -134,7 +134,11 @@ { int c; int longindex = 0; - + if(argc==1) + { + printf("Usage: %s -d /dev/cdrom [-rbvVh]\n", PACKAGE); + exit(0); + } struct option long_options[] = { { "help", 0, NULL, '?' }, @@ -143,14 +147,15 @@ { "config", 1, NULL, 'c' }, { "run", 0, NULL, 'r' }, { "batch", 0, NULL, 'b' }, + { "device", 0, NULL, 'd' }, { 0, 0, 0, 0 } }; - while ((c = getopt_long(argc, argv, "c:Vvhrb", long_options, &longindex)) != -1) + while ((c = getopt_long(argc, argv, "d:Vvhrb", long_options, &longindex)) != -1) { switch (c) { - case 'c': + case 'd': filename = (char *) substr(optarg, 0, strlen(optarg)); break; case 'V': @@ -170,13 +175,12 @@ case 'h': case '?': default: - printf("Usage: %s [-c filename] [-rbvVh]\n", PACKAGE); + printf("Usage: %s -d /dev/cdrom [-rbvVh]\n", PACKAGE); printf("Run commands when discs are inserted into CD/DVD drives.\n\n"); printf(" -r\t--run\t\tRun commands on disc already in drive when is started.\n"); printf(" -b\t--batch\t\tBatch mode: check all drives once then exit.\n"); printf("\t\t\t(implies -r)\n"); - printf(" -c\t--config\tUse an alternate config file. (Default is ~/.cdde.xml)\n"); printf(" -V\t--version\tPrint out version information.\n"); printf(" -v\t--verbose\tPrint out lots of information.\n"); printf(" -h\t--help\t\tPrint this help message.\n");