"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/file.c" between
dosfstools-4.1.tar.gz and dosfstools-4.2.tar.gz

About: dosfstools are utilities to create, check and label (MS-DOS) FAT filesystems.

file.c  (dosfstools-4.1):file.c  (dosfstools-4.2)
/* file.c - Additional file attributes /* file.c - Additional file attributes
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch> Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch> Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
Copyright (C) 2020 Pali Rohár <pali.rohar@gmail.com>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 40 skipping to change at line 41
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include "common.h" #include "common.h"
#include "file.h" #include "file.h"
#include "msdos_fs.h" #include "msdos_fs.h"
#include "charconv.h" #include "charconv.h"
FDSC *fp_root = NULL; FDSC *fp_root = NULL;
static void put_char(char **p, unsigned char c) static void put_char(char **p, unsigned char c, unsigned int out_size)
{ {
if (dos_char_to_printable(p, c)) if (dos_char_to_printable(p, c, out_size))
return; return;
if ((c >= ' ' && c < 0x7f) || c >= 0xa0) if (out_size >= 1 && c >= ' ' && c < 0x7f)
*(*p)++ = c; *(*p)++ = c;
else { else if (out_size >= 4) {
*(*p)++ = '\\'; *(*p)++ = '\\';
*(*p)++ = '0' + (c >> 6); *(*p)++ = '0' + (c >> 6);
*(*p)++ = '0' + ((c >> 3) & 7); *(*p)++ = '0' + ((c >> 3) & 7);
*(*p)++ = '0' + (c & 7); *(*p)++ = '0' + (c & 7);
} }
} }
/** /**
* Construct the "pretty-printed" representation of the name in a short director y entry. * Construct the "pretty-printed" representation of the name in a short director y entry.
* *
* @param[in] fixed Pointer to name[0] of a DIR_ENT * @param[in] fixed Pointer to name[0] of a DIR_ENT
* *
* @return Pointer to static string containing pretty "8.3" equivalent of the * @return Pointer to static string containing pretty "8.3" equivalent of the
* name in the directory entry. * name in the directory entry.
*/ */
char *file_name(unsigned char *fixed) char *file_name(unsigned char *fixed)
{ {
static char path[MSDOS_NAME * 4 + 2]; static char path[256];
char *p; char *p;
int i, j; int i, j;
p = path; p = path;
for (i = j = 0; i < 8; i++) i = j = 0;
if (fixed[0] == 0x05) {
put_char(&p, 0xe5, path + sizeof(path) - 1 - p);
++i;
++j;
}
for (; i < 8; i++)
if (fixed[i] != ' ') { if (fixed[i] != ' ') {
while (j++ < i) while (j++ < i)
*p++ = ' '; *p++ = ' ';
put_char(&p, fixed[i]); put_char(&p, fixed[i], path + sizeof(path) - 1 - p);
} }
if (strncmp((const char *)(fixed + 8), " ", 3)) { if (strncmp((const char *)(fixed + 8), " ", 3)) {
*p++ = '.'; *p++ = '.';
for (i = j = 0; i < 3; i++) for (i = j = 0; i < 3; i++)
if (fixed[i + 8] != ' ') { if (fixed[i + 8] != ' ') {
while (j++ < i) while (j++ < i)
*p++ = ' '; *p++ = ' ';
put_char(&p, fixed[i + 8]); put_char(&p, fixed[i + 8], path + sizeof(path) - 1 - p);
} }
} }
*p = 0; *p = 0;
return path; return path;
} }
int file_cvt(unsigned char *name, unsigned char *fixed) int file_cvt(unsigned char *name, unsigned char *fixed)
{ {
unsigned char c; unsigned char c;
int size, ext, cnt; int size, ext, cnt;
skipping to change at line 129 skipping to change at line 136
printf("Expected three octal digits.\n"); printf("Expected three octal digits.\n");
return 0; return 0;
} }
c = c * 8 + *name++ - '0'; c = c * 8 + *name++ - '0';
} }
name--; name--;
} }
if (islower(c)) if (islower(c))
c = toupper(c); c = toupper(c);
if (size) { if (size) {
*fixed++ = c; if (size == 8 && c == 0xE5)
*fixed++ = 0x05;
else
*fixed++ = c;
size--; size--;
} }
name++; name++;
} }
if (*name || size == 8) if (*name || size == 8)
return 0; return 0;
if (!ext) { if (!ext) {
while (size--) while (size--)
*fixed++ = ' '; *fixed++ = ' ';
size = 3; size = 3;
 End of changes. 10 change blocks. 
9 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)