mirror of
https://github.com/reactos/reactos.git
synced 2024-06-19 19:28:22 +00:00
[CDMAKE] Remove module
We've been using mkisofs for 5 years now and are not looking back. - Colin Finck
This commit is contained in:
parent
ba0d16f3b3
commit
c24e09401b
|
@ -1,2 +0,0 @@
|
|||
|
||||
add_host_tool(cdmake cdmake.c dirhash.c llmsort.c)
|
File diff suppressed because it is too large
Load diff
|
@ -1,15 +0,0 @@
|
|||
#ifndef _WIN32
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
#define DIR_SEPARATOR_CHAR '/'
|
||||
#define DIR_SEPARATOR_STRING "/"
|
||||
#else
|
||||
#define DIR_SEPARATOR_CHAR '\\'
|
||||
#define DIR_SEPARATOR_STRING "\\"
|
||||
#endif
|
||||
|
||||
#define MANUFACTURER_ID "ReactOS Foundation"
|
||||
#define PUBLISHER_ID "ReactOS Foundation"
|
||||
#define DATA_PREP_ID "ReactOS Foundation"
|
||||
#define APP_ID "CDMAKE CD-ROM Premastering Utility"
|
|
@ -1,238 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS CD-ROM Maker
|
||||
* FILE: tools/cdmake/dirhash.c
|
||||
* PURPOSE: CD-ROM Premastering Utility - Directory names hashing
|
||||
* PROGRAMMERS: Art Yerkes
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "config.h"
|
||||
#include "dirhash.h"
|
||||
|
||||
#ifndef max
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* This is the famous DJB hash */
|
||||
static unsigned int
|
||||
djb_hash(const char *name)
|
||||
{
|
||||
unsigned int val = 5381;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; name[i]; i++)
|
||||
{
|
||||
val = (33 * val) + name[i];
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
split_path(const char *path, char **dirname, char **filename /* OPTIONAL */)
|
||||
{
|
||||
const char *result;
|
||||
|
||||
/* Retrieve the file name */
|
||||
char *last_slash_1 = strrchr(path, '/');
|
||||
char *last_slash_2 = strrchr(path, '\\');
|
||||
|
||||
if (last_slash_1 || last_slash_2)
|
||||
result = max(last_slash_1, last_slash_2) + 1;
|
||||
else
|
||||
result = path;
|
||||
|
||||
/* Duplicate the file name for the user if needed */
|
||||
if (filename)
|
||||
*filename = strdup(result);
|
||||
|
||||
/* Remove any trailing directory separators */
|
||||
while (result > path && (*(result-1) == '/' || *(result-1) == '\\'))
|
||||
result--;
|
||||
|
||||
/* Retrieve and duplicate the directory */
|
||||
*dirname = malloc(result - path + 1);
|
||||
if (result > path)
|
||||
memcpy(*dirname, path, result - path);
|
||||
(*dirname)[result - path] = '\0'; // NULL-terminate
|
||||
}
|
||||
|
||||
void normalize_dirname(char *filename)
|
||||
{
|
||||
int i, tgt;
|
||||
int slash = 1;
|
||||
|
||||
for (i = 0, tgt = 0; filename[i]; i++)
|
||||
{
|
||||
if (slash)
|
||||
{
|
||||
if (filename[i] != '/' && filename[i] != '\\')
|
||||
{
|
||||
filename[tgt++] = toupper(filename[i]);
|
||||
slash = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (filename[i] == '/' || filename[i] == '\\')
|
||||
{
|
||||
slash = 1;
|
||||
filename[tgt++] = DIR_SEPARATOR_CHAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename[tgt++] = toupper(filename[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
filename[tgt] = '\0'; // NULL-terminate
|
||||
}
|
||||
|
||||
static struct target_dir_entry *
|
||||
get_entry_by_normname(struct target_dir_hash *dh, const char *norm)
|
||||
{
|
||||
unsigned int hashcode;
|
||||
struct target_dir_entry *de;
|
||||
hashcode = djb_hash(norm);
|
||||
de = dh->buckets[hashcode % NUM_DIR_HASH_BUCKETS];
|
||||
while (de && strcmp(de->normalized_name, norm))
|
||||
de = de->next_dir_hash_entry;
|
||||
return de;
|
||||
}
|
||||
|
||||
static void
|
||||
delete_entry(struct target_dir_hash *dh, struct target_dir_entry *de)
|
||||
{
|
||||
struct target_dir_entry **ent;
|
||||
ent = &dh->buckets[de->hashcode % NUM_DIR_HASH_BUCKETS];
|
||||
while (*ent && ((*ent) != de))
|
||||
ent = &(*ent)->next_dir_hash_entry;
|
||||
if (*ent)
|
||||
*ent = (*ent)->next_dir_hash_entry;
|
||||
}
|
||||
|
||||
struct target_dir_entry *
|
||||
dir_hash_create_dir(struct target_dir_hash *dh, const char *casename, const char *targetnorm)
|
||||
{
|
||||
struct target_dir_entry *de, *parent_de;
|
||||
char *parentcase = NULL;
|
||||
char *case_name = NULL;
|
||||
char *parentname = NULL;
|
||||
struct target_dir_entry **ent;
|
||||
|
||||
if (!dh->root.normalized_name)
|
||||
{
|
||||
dh->root.normalized_name = strdup("");
|
||||
dh->root.case_name = strdup("");
|
||||
dh->root.hashcode = djb_hash("");
|
||||
dh->buckets[dh->root.hashcode % NUM_DIR_HASH_BUCKETS] = &dh->root;
|
||||
}
|
||||
|
||||
/* Check whether the directory was already created and just return it if so */
|
||||
de = get_entry_by_normname(dh, targetnorm);
|
||||
if (de)
|
||||
return de;
|
||||
|
||||
/*
|
||||
* If *case_name == '\0' after the following call to split_path(...),
|
||||
* for example in the case where casename == "subdir/dir/", then just
|
||||
* create the directories "subdir" and "dir" by a recursive call to
|
||||
* dir_hash_create_dir(...) and return 'parent_de' instead (see after).
|
||||
* We do not (and we never) create a no-name directory inside it.
|
||||
*/
|
||||
split_path(casename, &parentcase, &case_name);
|
||||
split_path(targetnorm, &parentname, NULL);
|
||||
parent_de = dir_hash_create_dir(dh, parentcase, parentname);
|
||||
free(parentname);
|
||||
free(parentcase);
|
||||
|
||||
/* See the remark above */
|
||||
if (!*case_name)
|
||||
{
|
||||
free(case_name);
|
||||
return parent_de;
|
||||
}
|
||||
|
||||
/* Now create the directory */
|
||||
de = calloc(1, sizeof(*de));
|
||||
de->parent = parent_de;
|
||||
de->normalized_name = strdup(targetnorm);
|
||||
de->case_name = case_name;
|
||||
de->hashcode = djb_hash(targetnorm);
|
||||
|
||||
de->next = parent_de->child;
|
||||
parent_de->child = de;
|
||||
|
||||
ent = &dh->buckets[de->hashcode % NUM_DIR_HASH_BUCKETS];
|
||||
while (*ent)
|
||||
ent = &(*ent)->next_dir_hash_entry;
|
||||
*ent = de;
|
||||
|
||||
return de;
|
||||
}
|
||||
|
||||
struct target_file *
|
||||
dir_hash_add_file(struct target_dir_hash *dh, const char *source, const char *target)
|
||||
{
|
||||
struct target_file *tf;
|
||||
struct target_dir_entry *de;
|
||||
char *targetdir = NULL;
|
||||
char *targetfile = NULL;
|
||||
char *targetnorm;
|
||||
|
||||
/* First create the directory; check whether the file name is valid and bail out if not */
|
||||
split_path(target, &targetdir, &targetfile);
|
||||
if (!*targetfile)
|
||||
{
|
||||
free(targetdir);
|
||||
free(targetfile);
|
||||
return NULL;
|
||||
}
|
||||
targetnorm = strdup(targetdir);
|
||||
normalize_dirname(targetnorm);
|
||||
de = dir_hash_create_dir(dh, targetdir, targetnorm);
|
||||
free(targetnorm);
|
||||
free(targetdir);
|
||||
|
||||
/* Now add the file */
|
||||
tf = calloc(1, sizeof(*tf));
|
||||
tf->next = de->head;
|
||||
de->head = tf;
|
||||
tf->source_name = strdup(source);
|
||||
tf->target_name = targetfile;
|
||||
|
||||
return tf;
|
||||
}
|
||||
|
||||
static void
|
||||
dir_hash_destroy_dir(struct target_dir_hash *dh, struct target_dir_entry *de)
|
||||
{
|
||||
struct target_file *tf;
|
||||
struct target_dir_entry *te;
|
||||
|
||||
while ((te = de->child))
|
||||
{
|
||||
de->child = te->next;
|
||||
dir_hash_destroy_dir(dh, te);
|
||||
free(te);
|
||||
}
|
||||
while ((tf = de->head))
|
||||
{
|
||||
de->head = tf->next;
|
||||
free(tf->source_name);
|
||||
free(tf->target_name);
|
||||
free(tf);
|
||||
}
|
||||
|
||||
delete_entry(dh, de);
|
||||
free(de->normalized_name);
|
||||
free(de->case_name);
|
||||
}
|
||||
|
||||
void dir_hash_destroy(struct target_dir_hash *dh)
|
||||
{
|
||||
dir_hash_destroy_dir(dh, &dh->root);
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS CD-ROM Maker
|
||||
* FILE: tools/cdmake/dirhash.h
|
||||
* PURPOSE: CD-ROM Premastering Utility - Directory names hashing
|
||||
* PROGRAMMERS: Art Yerkes
|
||||
*/
|
||||
|
||||
#ifndef _DIRHASH_H_
|
||||
#define _DIRHASH_H_
|
||||
|
||||
#define NUM_DIR_HASH_BUCKETS 1024
|
||||
|
||||
struct target_file
|
||||
{
|
||||
struct target_file *next;
|
||||
char *source_name;
|
||||
char *target_name;
|
||||
};
|
||||
|
||||
struct target_dir_entry
|
||||
{
|
||||
unsigned int hashcode;
|
||||
struct target_dir_entry *next_dir_hash_entry;
|
||||
|
||||
struct target_dir_entry *next;
|
||||
struct target_dir_entry *parent;
|
||||
struct target_dir_entry *child;
|
||||
struct target_file *head;
|
||||
char *normalized_name;
|
||||
char *case_name;
|
||||
};
|
||||
|
||||
struct target_dir_hash
|
||||
{
|
||||
struct target_dir_entry *buckets[NUM_DIR_HASH_BUCKETS];
|
||||
struct target_dir_entry root;
|
||||
};
|
||||
|
||||
void normalize_dirname(char *filename);
|
||||
|
||||
struct target_dir_entry *
|
||||
dir_hash_create_dir(struct target_dir_hash *dh, const char *casename, const char *targetnorm);
|
||||
|
||||
struct target_file *
|
||||
dir_hash_add_file(struct target_dir_hash *dh, const char *source, const char *target);
|
||||
|
||||
void dir_hash_destroy(struct target_dir_hash *dh);
|
||||
|
||||
#endif // _DIRHASH_H_
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* A Linked-List Memory Sort
|
||||
* by Philip J. Erdelsky
|
||||
* pje@acm.org
|
||||
* pje@efgh.com
|
||||
* http://alumnus.caltech.edu/~pje/
|
||||
*
|
||||
* Version taken from:
|
||||
* http://alumnus.caltech.edu/~pje/cdmake.txt
|
||||
*
|
||||
* An extended version can be found at:
|
||||
* http://alumnus.caltech.edu/~pje/llmsort.html
|
||||
* http://www.efgh.com/software/llmsort.htm
|
||||
*
|
||||
* Public domain; no restrictions on use.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void *sort_linked_list(void *p, unsigned index, int (*compare)(void *, void *))
|
||||
{
|
||||
unsigned base;
|
||||
unsigned long block_size;
|
||||
|
||||
struct record
|
||||
{
|
||||
struct record *next[1];
|
||||
/* other members not directly accessed by this function */
|
||||
};
|
||||
|
||||
struct tape
|
||||
{
|
||||
struct record *first, *last;
|
||||
unsigned long count;
|
||||
} tape[4];
|
||||
|
||||
/* Distribute the records alternately to tape[0] and tape[1]. */
|
||||
|
||||
tape[0].count = tape[1].count = 0L;
|
||||
tape[0].first = NULL;
|
||||
base = 0;
|
||||
while (p != NULL)
|
||||
{
|
||||
struct record *next = ((struct record *)p)->next[index];
|
||||
((struct record *)p)->next[index] = tape[base].first;
|
||||
tape[base].first = ((struct record *)p);
|
||||
tape[base].count++;
|
||||
p = next;
|
||||
base ^= 1;
|
||||
}
|
||||
|
||||
/* If the list is empty or contains only a single record, then */
|
||||
/* tape[1].count == 0L and this part is vacuous. */
|
||||
|
||||
for (base = 0, block_size = 1L; tape[base+1].count != 0L;
|
||||
base ^= 2, block_size <<= 1)
|
||||
{
|
||||
int dest;
|
||||
struct tape *tape0, *tape1;
|
||||
tape0 = tape + base;
|
||||
tape1 = tape + base + 1;
|
||||
dest = base ^ 2;
|
||||
tape[dest].count = tape[dest+1].count = 0;
|
||||
for (; tape0->count != 0; dest ^= 1)
|
||||
{
|
||||
unsigned long n0, n1;
|
||||
struct tape *output_tape = tape + dest;
|
||||
n0 = n1 = block_size;
|
||||
while (1)
|
||||
{
|
||||
struct record *chosen_record;
|
||||
struct tape *chosen_tape;
|
||||
if (n0 == 0 || tape0->count == 0)
|
||||
{
|
||||
if (n1 == 0 || tape1->count == 0)
|
||||
break;
|
||||
chosen_tape = tape1;
|
||||
n1--;
|
||||
}
|
||||
else if (n1 == 0 || tape1->count == 0)
|
||||
{
|
||||
chosen_tape = tape0;
|
||||
n0--;
|
||||
}
|
||||
else if ((*compare)(tape0->first, tape1->first) > 0)
|
||||
{
|
||||
chosen_tape = tape1;
|
||||
n1--;
|
||||
}
|
||||
else
|
||||
{
|
||||
chosen_tape = tape0;
|
||||
n0--;
|
||||
}
|
||||
chosen_tape->count--;
|
||||
chosen_record = chosen_tape->first;
|
||||
chosen_tape->first = chosen_record->next[index];
|
||||
if (output_tape->count == 0)
|
||||
output_tape->first = chosen_record;
|
||||
else
|
||||
output_tape->last->next[index] = chosen_record;
|
||||
output_tape->last = chosen_record;
|
||||
output_tape->count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tape[base].count > 1L)
|
||||
tape[base].last->next[index] = NULL;
|
||||
return tape[base].first;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,96 +0,0 @@
|
|||
CD-ROM Maker
|
||||
Philip J. Erdelsky
|
||||
|
||||
The CDMAKE utility converts files from DOS/Windows format to ISO9660
|
||||
(CD-ROM) format.
|
||||
|
||||
First, gather all the files to be converted and put them into a single
|
||||
base directory and its subdirectories, arranged just the way you want
|
||||
them on the CD-ROM. Remember that ISO9660 allows subdirectories to be
|
||||
nested only eight levels deep. Therefore, if the base directory is
|
||||
C:\CDROM,
|
||||
|
||||
C:\CDROM\D2\D3\D4\D5\D6\D7\D8\FOO.TXT is permitted, but
|
||||
|
||||
C:\CDROM\D2\D3\D4\D5\D6\D7\D8\D9\FOO.TXT is forbidden.
|
||||
|
||||
Also, ISO9660 does not allow directories to have extensions, although
|
||||
DOS does.
|
||||
|
||||
Finally, the characters in file and directory names and file extensions
|
||||
must be letters, digits or underscores. Other punctuation marks
|
||||
permitted by DOS/Windows are forbidden by ISO9660. You can use the -c
|
||||
option to override this restriction, but the resulting CD-ROM may not be
|
||||
readable on systems other than DOS/Windows.
|
||||
|
||||
Files in the base directory will be written to the root directory of the
|
||||
CD-ROM image. All subdirectories of the base directory will appear as
|
||||
subdirectories of the root directory of the CD-ROM image. Their
|
||||
contents, and the contents of their subdirectories, down to the eighth
|
||||
level, will be faithfully copied to the CD-ROM image.
|
||||
|
||||
System files will not be written to the CD-ROM image. Hidden files will
|
||||
be written to the CD-ROM image, and will retain their hidden attributes.
|
||||
Read-only files will be written, and will remain read-only on the
|
||||
CD-ROM, but this does not distinguish them in any way, because on a
|
||||
CD-ROM all files are read-only. The archive attribute will be lost.
|
||||
|
||||
File and directory date and time stamps will be preserved in the CD-ROM
|
||||
image.
|
||||
|
||||
The utility is called up by a command line of the following form:
|
||||
|
||||
CDMAKE [-q] [-v] [-p] [-s N] [-m] [-j] [-b bootimage] source volume image
|
||||
|
||||
source specifications of base directory containing all files to
|
||||
be written to CD-ROM image
|
||||
|
||||
volume volume label
|
||||
|
||||
image image file or device
|
||||
|
||||
-q quiet mode - display nothing but error messages
|
||||
|
||||
-v verbose mode - display file information as files are
|
||||
scanned and written - overrides -p option
|
||||
|
||||
-p show progress while writing
|
||||
|
||||
-s N abort operation before beginning write if image will be
|
||||
larger than N megabytes (i.e. 1024*1024*N bytes)
|
||||
|
||||
-m accept punctuation marks other than underscores in
|
||||
names and extensions
|
||||
|
||||
-j generates Joliet filename records
|
||||
|
||||
-b bootimage create bootable ElTorito CD-ROM using 'no emulation' mode
|
||||
|
||||
|
||||
The utility makes three passes over the source files:
|
||||
|
||||
(1) The scanning pass, in which the names and extensions are
|
||||
checked for validity, and the names, extensions, sizes, dates,
|
||||
times and attributes are recorded internally. The files are not
|
||||
actually read during this pass.
|
||||
|
||||
(2) The layout pass, in which the sizes and positions of
|
||||
directories, files and other items in the CD-ROM image are
|
||||
determined.
|
||||
|
||||
(3) The writing pass, in which the files are actually read and the
|
||||
CD-ROM image is actually written to the specified file or
|
||||
device. The image is always written sequentially.
|
||||
|
||||
If neither the -q nor the -v option is used, CDMAKE will display the
|
||||
volume label, size, number of files and directories and the total bytes
|
||||
in each at the end of the layout pass.
|
||||
|
||||
If the -p option is used, and is not overridden by the -v option, then
|
||||
during the writing pass, CDMAKE will display the number of bytes still
|
||||
to be written to the CD-ROM image, updating it frequently. The number
|
||||
will decrease as the operation progresses, and will reach zero when the
|
||||
operation is complete.
|
||||
|
||||
The operation of CDMAKE can be aborted by typing Ctrl-C when the utility
|
||||
is displaying text of any kind.
|
Loading…
Reference in a new issue