Finally, implement a mini-parser for RockRidge alternative filenames,

so the filenames can be displayed and selected in full beauty.  If RR
is present, the match is now case-sensitive, if RR is missing, the
match is case-insensitive (as it used to be before).
This commit is contained in:
Joerg Wunsch 1997-12-04 21:52:47 +00:00
parent 4d9deedb49
commit 3bb99eb225
4 changed files with 63 additions and 34 deletions

View File

@ -24,11 +24,10 @@
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:03 rpd
* $Id: boot.h,v 1.21 1997/08/31 06:11:26 phk Exp $
* $Id: boot.h,v 1.22 1997/09/24 07:44:34 phk Exp $
*/
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/time.h>
#include <ufs/ffs/fs.h>
@ -81,10 +80,9 @@ void printf(const char *format, ...);
void putchar(int c);
void delay1ms(void);
int gets(char *buf);
#ifndef CDBOOT
int strcmp(const char *s1, const char *s2);
#else /* CDBOOT */
int strncasecmp(const char *s1, const char *s2, size_t s);
#ifdef CDBOOT
int strcasecmp(const char *s1, const char *s2);
#endif /* !CDBOOT */
void bcopy(const void *from, void *to, size_t len);
void twiddle(void);

View File

@ -24,7 +24,7 @@
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:57 rpd
* $Id: io.c,v 1.23 1997/06/09 05:10:55 bde Exp $
* $Id: io.c,v 1.24 1997/07/12 10:23:19 joerg Exp $
*/
#include "boot.h"
@ -258,8 +258,6 @@ gets(char *buf)
return 0;
}
#ifndef CDBOOT
int
strcmp(const char *s1, const char *s2)
{
@ -271,26 +269,22 @@ strcmp(const char *s1, const char *s2)
return 1;
}
#else /* CDBOOT */
#ifdef CDBOOT
int
strncasecmp(const char *s1, const char *s2, size_t s)
strcasecmp(const char *s1, const char *s2)
{
/*
* We only consider ASCII chars and don't anticipate
* control characters (they are invalid in filenames
* anyway).
*/
while (s > 0 && (*s1 & 0x5f) == (*s2 & 0x5f)) {
while ((*s1 & 0x5f) == (*s2 & 0x5f)) {
if (!*s1++)
return 0;
s2++;
}
if (s == 0)
return 0;
return 1;
}
#endif /* !CDBOOT */
void

View File

@ -24,7 +24,7 @@
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:03 rpd
* $Id$
* $Id: boot.h,v 1.1 1997/07/11 05:52:38 joerg Exp $
*/
/*
* Extensions for El Torito CD-ROM booting:
@ -155,7 +155,8 @@ void printf(const char *format, ...);
void putchar(int c);
void delay1ms(void);
int gets(char *buf);
int strncasecmp(const char *s1, const char *s2, size_t s);
int strcasecmp(const char *s1, const char *s2);
int strcmp(const char *s1, const char *s2);
void bcopy(const void *from, void *to, size_t len);
void twiddle(void);

View File

@ -27,7 +27,7 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id: cdrom.c,v 1.1 1997/07/11 05:52:39 joerg Exp $
* $Id: cdrom.c,v 1.2 1997/12/02 21:13:59 joerg Exp $
*/
@ -52,6 +52,7 @@ static u_int32_t curblk, startblk, filesize, offset;
static int bread(u_int32_t rba, size_t nblks, void *buf);
static void badread(const char *msg, u_int32_t blkno);
static struct iso_directory_record *find(const char *path, int list_only);
static char *get_rr_name(struct iso_directory_record *dirp, size_t *len_ret);
static int iread(u_char *buf, size_t len,
void (*copyfun)(const void *src, void *dst, size_t size));
@ -207,18 +208,56 @@ xread(u_char *buf, size_t len)
return iread(buf, len, pcpy);
}
/*
* XXX Todo:
* Use RR attributes if present
*/
static char *
get_rr_name(struct iso_directory_record *dirp, size_t *len_ret)
{
struct rr_header {
char type[2];
u_char len;
u_char version;
} *rrp;
struct rr_nm_header {
struct rr_header rrh;
u_char flags;
char name[0]; /* XXX -- using gcc extension */
} *rrnmp;
char *cp;
cp = dirp->name + (u_char)dirp->name_len[0];
/* round up to 16-bit boundary; ugly */
cp = (char *)(((int)cp + 1) & ~1);
rrp = (struct rr_header *)cp;
if (rrp->type[0] != 'R' || rrp->type[1] != 'R') {
DPRINTF(("no RR, "));
return 0;
}
DPRINTF(("RR attribs: "));
cp += rrp->len;
while (cp - (char *)dirp <= (u_char)dirp->length[0]) {
rrp = (struct rr_header *)cp;
DPRINTF(("%c%c ", rrp->type[0], rrp->type[1]));
if (rrp->type[0] == 'N' && rrp->type[1] == 'M') {
rrnmp = (struct rr_nm_header *)rrp;
*len_ret = rrp->len - sizeof(struct rr_nm_header);
return rrnmp->name;
}
cp += rrp->len;
}
return 0;
}
static struct iso_directory_record *
find(const char *path, int list_only)
{
struct iso_directory_record *dirp;
char *ptr;
char *ptr, *rrname;
size_t len, entrylen;
char namebuf[256];
int i;
int (*comp)(const char *, const char *);
while (*path && *path == '/')
path++;
@ -261,21 +300,18 @@ find(const char *path, int list_only)
DPRINTF(("directory\n"));
continue;
}
rrname = get_rr_name(dirp, &len);
comp = rrname? strcmp: strcasecmp;
#ifdef DEBUG
bcopy(dirp->name, namebuf, len);
bcopy(rrname? rrname: dirp->name, namebuf, len);
namebuf[len] = 0;
DPRINTF(("name `%s'\n", namebuf));
#else /* !DEBUG */
if (list_only) {
bcopy(dirp->name, namebuf, len);
namebuf[len] = 0;
printf("%s ", namebuf);
}
#endif /* DEBUG */
if (!list_only &&
strncasecmp(path, dirp->name, len) == 0)
if (list_only) {
#ifndef DEBUG
printf("%s ", namebuf);
#endif
} else if (comp(path, namebuf) == 0)
return dirp;
}
#ifndef DEBUG