Date: Sun, 21 Jan 2001 20:49:30 -0800 (PST) From: <scottl@FreeBSD.org> To: freebsd-multimedia@freebsd.org Subject: Let's try this again Message-ID: <200101220449.f0M4nUh59958@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
Yeah, Outlook sucks, sorry about that. Here are the pr0n DVD enabling patches again. Scott diff -c xine-0.3.5/input/dvd_udf.c xine-0.3.5.new/input/dvd_udf.c *** xine-0.3.5/input/dvd_udf.c Fri Jan 12 16:38:15 2001 --- xine-0.3.5.new/input/dvd_udf.c Sun Jan 21 18:33:07 2001 *************** *** 25,30 **** --- 25,31 ---- #include <stdio.h> + #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> *************** *** 275,284 **** int UDFMapICB (int fd, struct AD ICB, uint8_t *FileType, struct AD *File) { ! uint8_t LogBlock[DVD_VIDEO_LB_LEN]; uint32_t lbnum; uint16_t TagID; lbnum=partition.Start+ICB.Location; do { --- 276,290 ---- int UDFMapICB (int fd, struct AD ICB, uint8_t *FileType, struct AD *File) { ! uint8_t *LogBlock; uint32_t lbnum; uint16_t TagID; + if ((LogBlock = (uint8_t*)malloc(DVD_VIDEO_LB_LEN)) == NULL) { + fprintf(stderr, "%s: malloc failed\n", __FUNCTION__); + return 0; + } + lbnum=partition.Start+ICB.Location; do { *************** *** 287,296 **** --- 293,304 ---- if (TagID==261) { UDFFileEntry(LogBlock,FileType,File); + free(LogBlock); return 1; }; } while ((lbnum<=partition.Start+ICB.Location+(ICB.Length-1)/DVD_VIDEO_LB_LEN) && (TagID!=261)); + free(LogBlock); return 0; } *************** *** 303,315 **** int UDFScanDir (int fd, struct AD Dir, char *FileName, struct AD *FileICB) { ! uint8_t LogBlock[DVD_VIDEO_LB_LEN*30]; uint32_t lbnum, lb_dir_end, offset; uint16_t TagID; uint8_t filechar; ! char filename[MAX_FILE_LEN]; ! int p; /* * read complete directory --- 311,329 ---- int UDFScanDir (int fd, struct AD Dir, char *FileName, struct AD *FileICB) { ! uint8_t *LogBlock; uint32_t lbnum, lb_dir_end, offset; uint16_t TagID; uint8_t filechar; ! char *filename; ! int p, retval = 0; + LogBlock = (uint8_t*)malloc(DVD_VIDEO_LB_LEN * 30); + filename = (char*)malloc(MAX_FILE_LEN); + if ((LogBlock == NULL) || (filename == NULL)) { + fprintf(stderr, "%s: malloc failed\n", __FUNCTION__); + goto bail; + } /* * read complete directory *************** *** 335,347 **** if (TagID==257) { p += UDFFileIdentifier(&LogBlock[p],&filechar,filename,FileICB); ! if (!strcasecmp (FileName,filename)) ! return 1; } else p=offset; } ! return 0; } --- 349,368 ---- if (TagID==257) { p += UDFFileIdentifier(&LogBlock[p],&filechar,filename,FileICB); ! if (!strcasecmp (FileName,filename)) { ! retval = 1; ! goto bail; ! } } else p=offset; } ! retval = 0; ! ! bail: ! free(LogBlock); ! free(filename); ! return retval; } *************** *** 354,365 **** int UDFFindPartition (int fd, int partnum, struct Partition *part) { ! uint8_t LogBlock[DVD_VIDEO_LB_LEN],Anchor[DVD_VIDEO_LB_LEN]; uint32_t lbnum,MVDS_location,MVDS_length; uint16_t TagID; uint32_t lastsector; ! int i,terminate,volvalid; /* find anchor */ lastsector=0; --- 375,392 ---- int UDFFindPartition (int fd, int partnum, struct Partition *part) { ! uint8_t *LogBlock,*Anchor; uint32_t lbnum,MVDS_location,MVDS_length; uint16_t TagID; uint32_t lastsector; ! int i,terminate,volvalid,retval = 0; + LogBlock = (uint8_t*)malloc(DVD_VIDEO_LB_LEN); + Anchor = (uint8_t*)malloc(DVD_VIDEO_LB_LEN); + if ((LogBlock == NULL) || (Anchor == NULL)) { + fprintf(stderr, "%s: malloc failed\n", __FUNCTION__); + goto bail; + } /* find anchor */ lastsector=0; *************** *** 373,386 **** TagID=0; if (TagID!=2) { /* not an anchor? */ ! if (terminate) return 0; /* final try failed */ if (lastsector) { /* we already found the last sector */ lbnum=lastsector; /* try #3, alternative backup anchor */ terminate=1; /* but thats just about enough, then! */ } else { /* TODO: find last sector of the disc (this is optional) */ if (lastsector) lbnum=lastsector-256; /* try #2, backup anchor */ ! else return 0; /* unable to find last sector */ } } else break; /* it is an anchor! continue... */ } --- 400,413 ---- TagID=0; if (TagID!=2) { /* not an anchor? */ ! if (terminate) goto bail; /* final try failed */ if (lastsector) { /* we already found the last sector */ lbnum=lastsector; /* try #3, alternative backup anchor */ terminate=1; /* but thats just about enough, then! */ } else { /* TODO: find last sector of the disc (this is optional) */ if (lastsector) lbnum=lastsector-256; /* try #2, backup anchor */ ! else goto bail; /* unable to find last sector */ } } else break; /* it is an anchor! continue... */ } *************** *** 413,419 **** if ((!part->valid) || (!volvalid)) UDFExtentAD(&Anchor[24],&MVDS_length,&MVDS_location); /* backup volume descriptor */ } while (i-- && ((!part->valid) || (!volvalid))); ! return (part->valid); /* we only care for the partition, not the volume */ } --- 440,451 ---- if ((!part->valid) || (!volvalid)) UDFExtentAD(&Anchor[24],&MVDS_length,&MVDS_location); /* backup volume descriptor */ } while (i-- && ((!part->valid) || (!volvalid))); ! retval = part->valid; /* we only care for the partition, not the volume */ ! ! bail: ! free(LogBlock); ! free(Anchor); ! return retval; } *************** *** 426,447 **** uint32_t UDFFindFile (int fd, char *filename, off_t *size) { ! uint8_t LogBlock[DVD_VIDEO_LB_LEN]; uint8_t filetype; ! uint32_t lbnum; uint16_t TagID; struct AD RootICB,File,ICB; ! char tokenline[MAX_FILE_LEN] = ""; char *token; off_t lb_number; - int Partition=0; /* this is the standard location for DVD Video */ ! strcat (tokenline,filename); /* Find partition */ if (!UDFFindPartition(fd, Partition,&partition)) ! return 0; /* Find root dir ICB */ lbnum=partition.Start; --- 458,486 ---- uint32_t UDFFindFile (int fd, char *filename, off_t *size) { ! uint8_t *LogBlock; uint8_t filetype; ! uint32_t lbnum, retval = 0; uint16_t TagID; struct AD RootICB,File,ICB; ! char *tokenline; char *token; off_t lb_number; int Partition=0; /* this is the standard location for DVD Video */ + + LogBlock = (uint8_t*)malloc(DVD_VIDEO_LB_LEN); + tokenline = (char*)malloc(MAX_FILE_LEN); + if ((LogBlock == NULL) || (tokenline == NULL)) { + fprintf(stderr, "%s: malloc failed\n", __FUNCTION__); + goto bail; + } + memset(tokenline, 0, MAX_FILE_LEN); ! strncat (tokenline,filename,MAX_FILE_LEN); /* Find partition */ if (!UDFFindPartition(fd, Partition,&partition)) ! goto bail; /* Find root dir ICB */ lbnum=partition.Start; *************** *** 456,478 **** UDFAD(&LogBlock[400],&RootICB,UDFADlong); } while ((lbnum<partition.Start+partition.Length) && (TagID!=8) && (TagID!=256)); if (TagID!=256) ! return 0; if (RootICB.Partition!=Partition) ! return 0; /* Find root dir */ if (!UDFMapICB(fd, RootICB,&filetype,&File)) ! return 0; if (filetype!=4) /* root dir should be dir */ ! return 0; /* Tokenize filepath */ token=strtok(tokenline,"/"); while (token) { if (!UDFScanDir(fd, File,token,&ICB)) ! return 0; if (!UDFMapICB(fd, ICB,&filetype,&File)) ! return 0; token=strtok(NULL,"/"); } --- 495,517 ---- UDFAD(&LogBlock[400],&RootICB,UDFADlong); } while ((lbnum<partition.Start+partition.Length) && (TagID!=8) && (TagID!=256)); if (TagID!=256) ! goto bail; if (RootICB.Partition!=Partition) ! goto bail; /* Find root dir */ if (!UDFMapICB(fd, RootICB,&filetype,&File)) ! goto bail; if (filetype!=4) /* root dir should be dir */ ! goto bail; /* Tokenize filepath */ token=strtok(tokenline,"/"); while (token) { if (!UDFScanDir(fd, File,token,&ICB)) ! goto bail; if (!UDFMapICB(fd, ICB,&filetype,&File)) ! goto bail; token=strtok(NULL,"/"); } *************** *** 480,486 **** lb_number = partition.Start+File.Location ; ! return lb_number; } --- 519,530 ---- lb_number = partition.Start+File.Location ; ! retval = lb_number; ! ! bail: ! free(LogBlock); ! free(tokenline); ! return retval; } *************** *** 489,516 **** */ void UDFListDir(int fd, char *dirname, int nMaxFiles, char **file_list, int *nFiles) { ! uint8_t LogBlock[30*DVD_VIDEO_LB_LEN]; uint32_t lbnum; uint16_t TagID; struct AD RootICB,Dir,ICB; ! char tokenline[MAX_FILE_LEN]; char *token, *ntoken; uint8_t filetype; ! char filename[MAX_FILE_LEN]; int p; uint8_t filechar; char *dest; int Partition=0; /* this is the standard location for DVD Video */ *nFiles = 0; tokenline[0]='\0'; ! strcat(tokenline,dirname); /* Find partition */ if (!UDFFindPartition(fd, Partition,&partition)) { /* no partition found (no disc ??) */ *nFiles = -1; ! return; } /* Find root dir ICB */ --- 533,568 ---- */ void UDFListDir(int fd, char *dirname, int nMaxFiles, char **file_list, int *nFiles) { ! uint8_t *LogBlock; uint32_t lbnum; uint16_t TagID; struct AD RootICB,Dir,ICB; ! char *tokenline; char *token, *ntoken; uint8_t filetype; ! char *filename; int p; uint8_t filechar; char *dest; int Partition=0; /* this is the standard location for DVD Video */ + LogBlock = (uint8_t*)malloc(DVD_VIDEO_LB_LEN * 30); + tokenline = (char*)malloc(MAX_FILE_LEN); + filename = (char*)malloc(MAX_FILE_LEN); + if ((LogBlock == NULL) || (tokenline == NULL) || (filename == NULL)) { + fprintf(stderr, "%s: malloc failed\n", __FUNCTION__); + goto bail; + } + *nFiles = 0; tokenline[0]='\0'; ! strncat(tokenline,dirname,MAX_FILE_LEN); /* Find partition */ if (!UDFFindPartition(fd, Partition,&partition)) { /* no partition found (no disc ??) */ *nFiles = -1; ! goto bail; } /* Find root dir ICB */ *************** *** 528,542 **** && (TagID!=8) && (TagID!=256)); if (TagID!=256) ! return ; if (RootICB.Partition!=Partition) ! return ; /* Find root dir */ if (!UDFMapICB(fd, RootICB,&filetype,&Dir)) ! return ; if (filetype!=4) ! return ; /* root dir should be dir */ --- 580,594 ---- && (TagID!=8) && (TagID!=256)); if (TagID!=256) ! goto bail; if (RootICB.Partition!=Partition) ! goto bail; /* Find root dir */ if (!UDFMapICB(fd, RootICB,&filetype,&Dir)) ! goto bail; if (filetype!=4) ! goto bail; /* root dir should be dir */ *************** *** 546,554 **** while (token != NULL) { if (!UDFScanDir(fd, Dir,token,&ICB)) ! return ; if (!UDFMapICB(fd, ICB,&filetype,&Dir)) ! return ; if (ntoken == NULL) { uint32_t lb_dir_end, offset; --- 598,606 ---- while (token != NULL) { if (!UDFScanDir(fd, Dir,token,&ICB)) ! goto bail; if (!UDFMapICB(fd, ICB,&filetype,&Dir)) ! goto bail; if (ntoken == NULL) { uint32_t lb_dir_end, offset; *************** *** 582,592 **** if (strcmp (filename,"")) { dest = file_list[*nFiles]; ! strcpy (dest,filename); (*nFiles)++; if ((*nFiles)>=nMaxFiles) ! return; } --- 634,644 ---- if (strcmp (filename,"")) { dest = file_list[*nFiles]; ! strncpy (dest,filename,256); (*nFiles)++; if ((*nFiles)>=nMaxFiles) ! goto bail; } *************** *** 600,604 **** --- 652,662 ---- token=ntoken; ntoken=strtok(NULL,"/"); } + + bail: + free(LogBlock); + free(tokenline); + free(filename); + return; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-multimedia" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101220449.f0M4nUh59958>