wok rev 12212

syslinux/md5sum.c32: use non rockridge names
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Mar 31 17:00:54 2012 +0200 (2012-03-31)
parents 7219c33850c6
children 2dde678153c7
files syslinux/stuff/extra/md5sum.c
line diff
     1.1 --- a/syslinux/stuff/extra/md5sum.c	Sat Mar 31 15:32:23 2012 +0200
     1.2 +++ b/syslinux/stuff/extra/md5sum.c	Sat Mar 31 17:00:54 2012 +0200
     1.3 @@ -273,6 +273,36 @@
     1.4  	return (unsigned char *)hex_value;
     1.5  }
     1.6  
     1.7 +static char *unrock(const char *name)
     1.8 +{
     1.9 +	static char buffer[256];
    1.10 +	char *out = buffer;
    1.11 +	int i, j;
    1.12 +	for (i = 0, j = 8; *name && (buffer + 255) > (out + i); name++) {
    1.13 +		if (*name == '/') {
    1.14 +			out[i++] = *name;
    1.15 +			out += i;
    1.16 +			i = 0; j = 8;
    1.17 +		}
    1.18 +		else if (*name == '.') {
    1.19 +			if (i > 8) i = 8;
    1.20 +			for (j = 0; j < i; j++)
    1.21 +				if (out[j] == '.') out[j] = '_';
    1.22 +			out[i++] = *name;
    1.23 +			j = i + 3;
    1.24 +		}
    1.25 +		else if (i >= j) continue;
    1.26 +		else if ((*name >= 'A' && *name <= 'Z') || *name == '_' ||
    1.27 +		    (*name >= '0' && *name <= '9'))
    1.28 +			out[i++] = *name;
    1.29 +		else if (*name >= 'a' && *name <= 'z')
    1.30 +			out[i++] = *name + 'A' - 'a';
    1.31 +		else out[i++] = '_';
    1.32 +	}
    1.33 +	out[i] = 0;
    1.34 +	return buffer;
    1.35 +}
    1.36 +
    1.37  static uint8_t *hash_file(const char *filename)
    1.38  {
    1.39  	int src_fd, count;
    1.40 @@ -281,6 +311,9 @@
    1.41  
    1.42  	src_fd = open(filename, O_RDONLY);
    1.43  	if (src_fd < 0) {
    1.44 +		src_fd = open(unrock(filename), O_RDONLY);
    1.45 +	}
    1.46 +	if (src_fd < 0) {
    1.47  		return NULL;
    1.48  	}
    1.49  
    1.50 @@ -311,6 +344,8 @@
    1.51  		FILE *fp;
    1.52  		char *line, buffer[256];
    1.53  		fp = fopen(*argv,"r");
    1.54 +		if (fp == NULL)
    1.55 +			fp = fopen(unrock(*argv),"r");
    1.56  
    1.57  		while ((line = fgets(buffer,256,fp)) != NULL) {
    1.58  			uint8_t *hash_value;
    1.59 @@ -333,6 +368,8 @@
    1.60  			}
    1.61  			*filename_ptr = '\0';
    1.62  			*++filename_ptr = '/';
    1.63 +			if (filename_ptr[1] == '/')
    1.64 +				filename_ptr++;
    1.65  
    1.66  			status = "NOT CHECKED" BLANK "\n";
    1.67  			hash_value = hash_file(filename_ptr);