summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMartin Prochnow <nordlicht@martins-kabuff.de>2006-03-29 18:54:49 +0200
committerAndreas Mair <andreas@vdr-developer.org>2006-03-29 18:54:49 +0200
commit0ff08f0bfb1460e0d0035081956a75b92aaa8359 (patch)
tree3a77a0dec260c32659bf7dda9e35ef04299b8d47 /tools
parent54d5f6870a7351584fcb1c3e861a4fc9224badf3 (diff)
downloadvdr-plugin-extrecmenu-0ff08f0bfb1460e0d0035081956a75b92aaa8359.tar.gz
vdr-plugin-extrecmenu-0ff08f0bfb1460e0d0035081956a75b92aaa8359.tar.bz2
Version 0.8v0.8
- added some logging - added option to hide the "new recordings column" - added possibility to edit lifetime and priority at the rename menu - changed alternative new marker, it marks now the recordings that are not "rewinded", if turned of the behaviour is like that of VDR's recordings menu - added support for a file length.vdr, containing the length of a recording as a string - new version of 'dvdarchive.sh'; thanks to vejoun from vdr-portal.de - added two small tools (in tools/); isodetect to check for a dvd in drive (optionally used by 'dvdarchive.sh'); getlength to create a length.vdr - updated error messages, more detailed now - fixed quoting of the parameters for dvdarchive.sh to avoid problems with filenames containing a ' - fixed unnecessary calls of 'dvdarchive.sh'; thanks to vejoun from vdr-portal.de for reporting
Diffstat (limited to 'tools')
-rw-r--r--tools/getlength.c68
-rw-r--r--tools/isodetect.c150
2 files changed, 218 insertions, 0 deletions
diff --git a/tools/getlength.c b/tools/getlength.c
new file mode 100644
index 0000000..946e01c
--- /dev/null
+++ b/tools/getlength.c
@@ -0,0 +1,68 @@
+/*
+ * getlength - a small tool to get the length of a VDR recording by the size
+ * of the file index.vdr
+ *
+ * (c) by Martin Prochnow
+ * Distributed under the terms of the GPL v2.0 (see COPYING at the root dir of
+ * this archive).
+ *
+ * Compile with: gcc getlength.c -o getlength
+ *
+ * Usage: 'getlength' if index.vdr is in the current working directory or
+ 'getlength /PATH/TO/RECDIR/' else
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+int main(int argc,char **argv)
+{
+ char *filename;
+ int hasindex,length;
+ struct stat status;
+ FILE *out;
+
+ switch(argc)
+ {
+ case 1: asprintf(&filename,"./index.vdr");break;
+ case 2: asprintf(&filename,"%s/index.vdr",argv[1]);break;
+ default: fprintf(stderr,"Usage:\ngetlength [PATH/TO/index.vdr]\n");exit(-1);
+ }
+
+ hasindex=!access(filename,R_OK);
+ if(hasindex)
+ {
+ stat(filename,&status);
+ length=status.st_size/12000; // calculate length if the recording by the size of index.vdr
+
+ free(filename);
+ switch(argc)
+ {
+ case 1: asprintf(&filename,"./length.vdr");break;
+ case 2: asprintf(&filename,"%s/length.vdr",argv[1]);break;
+ }
+ if((out=fopen(filename,"w"))!=NULL)
+ {
+ fprintf(out,"%d\n",length);
+ fclose(out);
+ }
+ else
+ {
+ perror("Error while open length.vdr");
+ free(filename);
+ exit(-1);
+ }
+ }
+ else
+ {
+ perror("Error while accessing index.vdr");
+ free(filename);
+ exit(-1);
+ }
+
+ free(filename);
+ return 0;
+}
diff --git a/tools/isodetect.c b/tools/isodetect.c
new file mode 100644
index 0000000..25c4c68
--- /dev/null
+++ b/tools/isodetect.c
@@ -0,0 +1,150 @@
+/*
+ isodetect.c
+
+ gcc -O2 -Wall isodetect.c -o isodetect
+
+ Looks in first block of an block-device and checks if there is an ISO9660-
+ filesystem on it. This is done by checking for a string "CD001".
+
+ Also reads certain information out of the block.
+
+ 14.11.95 T.Niederreiter (based on cdlabel.c by aeb)
+*/
+
+#include <stdio.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <termio.h>
+
+char buf[1024];
+char devname[80];
+
+void printnsp(int begin, int end, char *txt);
+void printchar(unsigned char c);
+
+main(int argc, char **argv) {
+FILE * infile;
+int c;
+int id=0;
+
+ /* Default device to check */
+ strcpy(devname,"/dev/cdrom");
+
+ while ((c = getopt (argc,argv,"hVpPAd:")) != EOF) {
+ switch(c) {
+ case 0:
+ break;
+
+ case 'V':
+ id=1;
+ break;
+
+ case 'p':
+ id=2;
+ break;
+
+ case 'P':
+ id=3;
+ break;
+
+ case 'A':
+ id=4;
+ break;
+
+ case 'd':
+ strcpy(devname,optarg);
+ break;
+
+ case 'h':
+ printf("Usage: %s [OPTIONS]\n",argv[0]);
+ printf("\
+ -h show help (this text)\n\
+ -V print VOLUME_ID of ISO9660-Image\n\
+ -p print PREPARER_ID of ISO9660-Image\n\
+ -P print PUBLISHER_ID of ISO9660-Image\n\
+ -A print APPLICATION_ID of ISO9660-Image\n\
+ -d <device>\n");
+
+ exit(1);
+ }
+ }
+
+ infile = fopen(devname, "rb");
+
+ if (infile == NULL) {
+ perror(devname);
+ exit(1);
+ }
+
+ if (lseek(fileno(infile), 32768, SEEK_SET) < 0) {
+ perror("lseek");
+ exit(1);
+ }
+
+ if (read(fileno(infile), buf, sizeof(buf)) != sizeof(buf)) {
+ perror("read");
+ exit(1);
+ }
+
+ if (strncmp(buf, "\001CD001\001", 8) != 0) {
+ if (id==0) {
+ printf("Not ISO9660\n");
+ exit(0);
+ }
+ }
+ else {
+ switch(id) {
+ case 0:
+ printf("ISO9660\n");
+ exit(0);
+ break;
+
+ case 1:
+ printnsp(40,72,"Volume_ID"); /* 32 */
+ break;
+
+ case 3:
+ printnsp(318,446,"Publisher"); /* 128 */
+ break;
+
+ case 2:
+ printnsp(446,574,"Preparer"); /* 128 */
+ break;
+
+ case 4:
+ printnsp(574,702,"Application"); /* 128 */
+ break;
+ }
+ }
+ exit(0);
+}
+
+int empty(char c) {
+ return (c == 0 || c == ' ');
+}
+
+void printnsp(int begin, int end, char *txt) {
+int i,j,k;
+
+ for(i=begin; i<end; i++) {
+ if (empty(buf[i]))
+ continue;
+ for(j=i+1; j<end; j++)
+ if (!buf[j] || (j < end-1
+ && empty(buf[j]) && empty(buf[j+1]))) break;
+ for(k=i; k<j; k++)
+ printchar(buf[k]);
+ printf("\n");
+ i = j;
+ }
+}
+
+void printchar(unsigned char c) {
+ if (isprint(c) || isspace(c))
+ putchar(c);
+ else
+ printf("\\%03o", c);
+}
+
+