2000-05-23 01:55:31 +00:00
|
|
|
/*
|
Distinguish Unicode and Mac OS Roman strings
NufxLib has historically made no effort to distinguish between
the character set used for filenames on the local disk, and for
filenames stored within the archive. Now all Unicode filename
strings use the UNICHAR type and have "UNI" in the name, and all
Mac OS Roman strings have "MOR" in the name. (The naming
convention makes it obvious when you're assigning the wrong thing;
on Linux both formats are char*, so the compiler won't tell you
if you get it wrong.)
The distinction is necessary because filesystems generally support
Unicode these days, but on Windows you need to use a separate
set of wide-character file I/O functions. (On Linux it all works
with "narrow" strings, and the UTF-8 encoding is interpreted by
applications.) The character set used for NuFX archive filenames
is MOR, matching what GS/OS + HFS supported, and we want to be able
to convert back and forth between MOR and a Unicode representation.
This change updates the various character types and string names,
adds conversion functions, and updates NuLib2 for proper execution
on Linux. It does not include the (probably extensive) changes
required for Windows UTF-16 support. Instead, the conversion
functions are no-ops, which should result in NuLib2 for Windows
continuing to behave in the same slightly broken way.
This adds "test-names", which exercises Unicode filenames a bit.
It will not pass on Win32.
Also, tweaked the Linux makefiles to have explicit dependencies,
rather than empty space and an expectation that "makedepend" exists.
Also, minor source code cleanups.
While this probably doesn't affect binary compatibility -- it's
mainly a matter of naming and string interpretation -- there's
enough going on that it should be considered an API revision, so
this updates the version to 3.0.0.
2014-12-24 19:14:32 +00:00
|
|
|
* NuLib2
|
2007-02-19 23:11:55 +00:00
|
|
|
* Copyright (C) 2000-2007 by Andy McFadden, All Rights Reserved.
|
2000-05-23 01:55:31 +00:00
|
|
|
* This is free software; you can redistribute it and/or modify it under the
|
2007-02-19 23:11:55 +00:00
|
|
|
* terms of the BSD License, see the file COPYING.
|
2000-05-23 01:55:31 +00:00
|
|
|
*/
|
2014-12-23 00:06:55 +00:00
|
|
|
#ifndef NULIB2_NULIB2_H
|
|
|
|
#define NULIB2_NULIB2_H
|
2000-05-23 01:55:31 +00:00
|
|
|
|
2002-09-21 00:59:25 +00:00
|
|
|
#include "SysDefs.h" /* system-dependent defs; must come first */
|
2000-05-23 01:55:31 +00:00
|
|
|
#include <NufxLib.h>
|
|
|
|
#include "State.h"
|
|
|
|
#include "MiscStuff.h"
|
|
|
|
|
|
|
|
#ifdef USE_DMALLOC
|
|
|
|
/* enable with something like "dmalloc -l logfile -i 100 medium" */
|
|
|
|
# include "dmalloc.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* replace unsupported chars with '%xx' */
|
2002-09-21 00:59:25 +00:00
|
|
|
#define kForeignIndic '%'
|
2000-05-23 01:55:31 +00:00
|
|
|
|
2003-02-08 22:35:31 +00:00
|
|
|
/* use this to separate path components in stored filenames */
|
|
|
|
#define kStorageFssep ':'
|
|
|
|
|
2000-05-23 01:55:31 +00:00
|
|
|
/* make our one-line comments this big */
|
2002-09-21 00:59:25 +00:00
|
|
|
#define kDefaultCommentLen 200
|
2000-05-23 01:55:31 +00:00
|
|
|
|
2002-10-09 00:15:24 +00:00
|
|
|
/* for use with FormatDateShort() */
|
|
|
|
#define kDateOutputLen 64
|
2000-05-23 01:55:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function prototypes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Add.c */
|
|
|
|
NuError DoAdd(NulibState* pState);
|
|
|
|
|
|
|
|
/* ArcUtils.c */
|
|
|
|
char* GetSimpleComment(NulibState* pState, const char* pathname, int maxLen);
|
|
|
|
Boolean IsFilenameStdin(const char* archiveName);
|
|
|
|
Boolean IsSpecified(NulibState* pState, const NuRecord* pRecord);
|
|
|
|
NuError OpenArchiveReadOnly(NulibState* pState);
|
|
|
|
NuError OpenArchiveReadWrite(NulibState* pState);
|
2014-12-22 02:35:09 +00:00
|
|
|
const NuThread* GetThread(const NuRecord* pRecord, uint32_t idx);
|
2000-05-23 01:55:31 +00:00
|
|
|
Boolean IsRecordReadOnly(const NuRecord* pRecord);
|
|
|
|
|
2002-10-09 00:15:24 +00:00
|
|
|
/* Binary2.c */
|
|
|
|
NuError BNYDoExtract(NulibState* pState);
|
|
|
|
NuError BNYDoTest(NulibState* pState);
|
|
|
|
NuError BNYDoListShort(NulibState* pState);
|
|
|
|
NuError BNYDoListVerbose(NulibState* pState);
|
|
|
|
NuError BNYDoListDebug(NulibState* pState);
|
|
|
|
|
2000-05-23 01:55:31 +00:00
|
|
|
/* Delete.c */
|
|
|
|
NuError DoDelete(NulibState* pState);
|
|
|
|
|
|
|
|
/* Extract.c */
|
|
|
|
NuError DoExtract(NulibState* pState);
|
|
|
|
NuError DoExtractToPipe(NulibState* pState);
|
|
|
|
NuError DoTest(NulibState* pState);
|
|
|
|
|
|
|
|
/* Filename.c */
|
2014-12-22 02:35:09 +00:00
|
|
|
const char* GetFileTypeString(uint32_t fileType);
|
2000-05-23 01:55:31 +00:00
|
|
|
const char* NormalizePath(NulibState* pState, NuPathnameProposal* pathProposal);
|
|
|
|
void InterpretExtension(NulibState* pState, const char* pathName,
|
2014-12-22 02:35:09 +00:00
|
|
|
uint32_t* pFileType, uint32_t* pAuxType);
|
2000-05-23 01:55:31 +00:00
|
|
|
Boolean ExtractPreservationString(NulibState* pState, char* pathname,
|
2014-12-22 02:35:09 +00:00
|
|
|
uint32_t* pFileType, uint32_t* pAuxType, NuThreadID* pThreadID);
|
2000-05-23 01:55:31 +00:00
|
|
|
void DenormalizePath(NulibState* pState, char* pathBuf);
|
|
|
|
const char* FilenameOnly(NulibState* pState, const char* pathname);
|
|
|
|
const char* FindExtension(NulibState* pState, const char* pathname);
|
|
|
|
|
|
|
|
/* List.c */
|
|
|
|
NuError DoListShort(NulibState* pState);
|
|
|
|
NuError DoListVerbose(NulibState* pState);
|
|
|
|
NuError DoListDebug(NulibState* pState);
|
2002-10-09 00:15:24 +00:00
|
|
|
char* FormatDateShort(const NuDateTime* pDateTime, char* buffer);
|
2000-05-23 01:55:31 +00:00
|
|
|
|
|
|
|
/* Main.c */
|
|
|
|
extern const char* gProgName;
|
|
|
|
|
|
|
|
/* MiscUtils.c */
|
|
|
|
void ReportError(NuError err, const char* format, ...)
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
__attribute__ ((format(printf, 2, 3)))
|
|
|
|
#endif
|
|
|
|
;
|
2002-09-21 00:59:25 +00:00
|
|
|
#ifdef USE_DMALLOC /* want file and line numbers for calls */
|
2000-05-23 01:55:31 +00:00
|
|
|
# define Malloc(size) malloc(size)
|
|
|
|
# define Calloc(size) calloc(1, size)
|
|
|
|
# define Realloc(ptr, size) realloc(ptr, size)
|
2014-12-22 02:17:23 +00:00
|
|
|
# define Free(ptr) (ptr != NULL ? free(ptr) : (void)0)
|
2000-05-23 01:55:31 +00:00
|
|
|
#else
|
|
|
|
void* Malloc(size_t size);
|
|
|
|
void* Calloc(size_t size);
|
|
|
|
void* Realloc(void* ptr, size_t size);
|
|
|
|
void Free(void* ptr);
|
|
|
|
#endif
|
2003-02-09 01:56:05 +00:00
|
|
|
NuResult FreeCallback(NuArchive* pArchive, void* args);
|
Distinguish Unicode and Mac OS Roman strings
NufxLib has historically made no effort to distinguish between
the character set used for filenames on the local disk, and for
filenames stored within the archive. Now all Unicode filename
strings use the UNICHAR type and have "UNI" in the name, and all
Mac OS Roman strings have "MOR" in the name. (The naming
convention makes it obvious when you're assigning the wrong thing;
on Linux both formats are char*, so the compiler won't tell you
if you get it wrong.)
The distinction is necessary because filesystems generally support
Unicode these days, but on Windows you need to use a separate
set of wide-character file I/O functions. (On Linux it all works
with "narrow" strings, and the UTF-8 encoding is interpreted by
applications.) The character set used for NuFX archive filenames
is MOR, matching what GS/OS + HFS supported, and we want to be able
to convert back and forth between MOR and a Unicode representation.
This change updates the various character types and string names,
adds conversion functions, and updates NuLib2 for proper execution
on Linux. It does not include the (probably extensive) changes
required for Windows UTF-16 support. Instead, the conversion
functions are no-ops, which should result in NuLib2 for Windows
continuing to behave in the same slightly broken way.
This adds "test-names", which exercises Unicode filenames a bit.
It will not pass on Win32.
Also, tweaked the Linux makefiles to have explicit dependencies,
rather than empty space and an expectation that "makedepend" exists.
Also, minor source code cleanups.
While this probably doesn't affect binary compatibility -- it's
mainly a matter of naming and string interpretation -- there's
enough going on that it should be considered an API revision, so
this updates the version to 3.0.0.
2014-12-24 19:14:32 +00:00
|
|
|
UNICHAR* CopyMORToUNI(const char* stringMOR);
|
2000-05-23 01:55:31 +00:00
|
|
|
|
|
|
|
/* SysUtils.c */
|
|
|
|
NuError NormalizeFileName(NulibState* pState, const char* srcp, long srcLen,
|
2002-09-21 00:59:25 +00:00
|
|
|
char fssep, char** pDstp, long dstLen);
|
2000-05-23 01:55:31 +00:00
|
|
|
NuError NormalizeDirectoryName(NulibState* pState, const char* srcp,
|
2002-09-21 00:59:25 +00:00
|
|
|
long srcLen, char fssep, char** pDstp, long dstLen);
|
2000-05-23 01:55:31 +00:00
|
|
|
char* MakeTempArchiveName(NulibState* pState);
|
2015-01-03 23:15:05 +00:00
|
|
|
NuError SetFinderInfo(int fd, uint8_t proType, uint16_t proAux);
|
2000-05-23 01:55:31 +00:00
|
|
|
NuError AddFile(NulibState* pState, NuArchive* pArchive,
|
2002-09-21 00:59:25 +00:00
|
|
|
const char* pathname);
|
2002-10-09 00:15:24 +00:00
|
|
|
NuError Mkdir(const char* dir);
|
|
|
|
NuError TestFileExistence(const char* fileName, Boolean* pIsDir);
|
2000-05-23 01:55:31 +00:00
|
|
|
|
2014-12-23 00:06:55 +00:00
|
|
|
#endif /*NULIB2_NULIB2_H*/
|