nulib2/nulib2/State.h

158 lines
6.0 KiB
C
Raw Normal View History

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
*/
#ifndef NULIB2_STATE_H
#define NULIB2_STATE_H
2000-05-23 01:55:31 +00:00
#include "MiscStuff.h"
#include "NufxLib.h"
/*
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
* Things you can tell NuLib2 to do.
2000-05-23 01:55:31 +00:00
*
* (Some debug code in NState_DebugDump() is sensitive to the order here.)
*/
typedef enum Command {
kCommandUnknown = 0,
kCommandAdd,
kCommandDelete,
kCommandExtract,
kCommandExtractToPipe,
kCommandListShort,
kCommandListVerbose,
kCommandListDebug,
kCommandTest,
kCommandHelp
2000-05-23 01:55:31 +00:00
} Command;
/*
* Program-wide state.
*/
typedef struct NulibState {
/* global goodness */
const char* programVersion;
2000-05-23 01:55:31 +00:00
/* system-specific values */
char systemPathSeparator;
char altSystemPathSeparator;
2000-05-23 01:55:31 +00:00
/* pointer to archive we're working with */
NuArchive* pArchive;
2000-05-23 01:55:31 +00:00
/* misc state */
Boolean suppressOutput;
Boolean inputUnavailable;
NuRecordIdx renameFromIdx;
char* renameToStr;
NuDataSink* pPipeSink;
NuDataSink* pCommentSink;
long matchCount;
long totalLen;
long totalCompLen;
2000-05-23 01:55:31 +00:00
/* temp storage */
long tempPathnameAlloc;
char* tempPathnameBuf;
2000-05-23 01:55:31 +00:00
/* command-line options */
Command command;
Boolean modUpdate;
Boolean modFreshen;
Boolean modRecurse;
Boolean modJunkPaths;
Boolean modNoCompression;
Boolean modCompressDeflate;
Boolean modCompressBzip2;
Boolean modComments;
Boolean modBinaryII;
Boolean modConvertText;
Boolean modConvertAll;
Boolean modOverwriteExisting;
Boolean modAddAsDisk;
Boolean modPreserveType;
Boolean modPreserveTypeExtended;
2000-05-23 01:55:31 +00:00
const char* archiveFilename;
char* const* filespecPointer;
long filespecCount;
2000-05-23 01:55:31 +00:00
} NulibState;
NuError NState_Init(NulibState** ppState);
NuError NState_ExtraInit(NulibState* pState);
void NState_Free(NulibState* pState);
#ifdef DEBUG_MSGS
void NState_DebugDump(const NulibState* pState);
#endif
char NState_GetSystemPathSeparator(const NulibState* pState);
char NState_GetAltSystemPathSeparator(const NulibState* pState);
2000-05-23 01:55:31 +00:00
const char* NState_GetProgramVersion(const NulibState* pState);
NuArchive* NState_GetNuArchive(const NulibState* pState);
void NState_SetNuArchive(NulibState* pState, NuArchive* pArchive);
Boolean NState_GetSuppressOutput(const NulibState* pState);
void NState_SetSuppressOutput(NulibState* pState, Boolean doSuppress);
Boolean NState_GetInputUnavailable(const NulibState* pState);
void NState_SetInputUnavailable(NulibState* pState, Boolean isUnavailable);
NuRecordIdx NState_GetRenameFromIdx(const NulibState* pState);
void NState_SetRenameFromIdx(NulibState* pState, NuRecordIdx recordIdx);
char* NState_GetRenameToStr(const NulibState* pState);
void NState_SetRenameToStr(NulibState* pState, char* str);
NuDataSink* NState_GetPipeSink(const NulibState* pState);
NuDataSink* NState_GetCommentSink(const NulibState* pState);
long NState_GetMatchCount(const NulibState* pState);
void NState_SetMatchCount(NulibState* pState, long count);
void NState_IncMatchCount(NulibState* pState);
void NState_AddToTotals(NulibState* pState, long len, long compLen);
void NState_GetTotals(NulibState* pState, long* pTotalLen, long* pTotalCompLen);
long NState_GetTempPathnameLen(NulibState* pState);
void NState_SetTempPathnameLen(NulibState* pState, long len);
char* NState_GetTempPathnameBuf(NulibState* pState);
Command NState_GetCommand(const NulibState* pState);
void NState_SetCommand(NulibState* pState, Command cmd);
const char* NState_GetArchiveFilename(const NulibState* pState);
void NState_SetArchiveFilename(NulibState* pState, const char* archiveFilename);
char* const* NState_GetFilespecPointer(const NulibState* pState);
void NState_SetFilespecPointer(NulibState* pState, char* const* filespec);
long NState_GetFilespecCount(const NulibState* pState);
void NState_SetFilespecCount(NulibState* pState, long filespecCount);
Boolean NState_GetModUpdate(const NulibState* pState);
void NState_SetModUpdate(NulibState* pState, Boolean val);
Boolean NState_GetModFreshen(const NulibState* pState);
void NState_SetModFreshen(NulibState* pState, Boolean val);
Boolean NState_GetModRecurse(const NulibState* pState);
void NState_SetModRecurse(NulibState* pState, Boolean val);
Boolean NState_GetModJunkPaths(const NulibState* pState);
void NState_SetModJunkPaths(NulibState* pState, Boolean val);
Boolean NState_GetModNoCompression(const NulibState* pState);
void NState_SetModNoCompression(NulibState* pState, Boolean val);
Boolean NState_GetModCompressDeflate(const NulibState* pState);
void NState_SetModCompressDeflate(NulibState* pState, Boolean val);
Boolean NState_GetModCompressBzip2(const NulibState* pState);
void NState_SetModCompressBzip2(NulibState* pState, Boolean val);
2000-05-23 01:55:31 +00:00
Boolean NState_GetModComments(const NulibState* pState);
void NState_SetModComments(NulibState* pState, Boolean val);
Boolean NState_GetModBinaryII(const NulibState* pState);
void NState_SetModBinaryII(NulibState* pState, Boolean val);
2000-05-23 01:55:31 +00:00
Boolean NState_GetModConvertText(const NulibState* pState);
void NState_SetModConvertText(NulibState* pState, Boolean val);
Boolean NState_GetModConvertAll(const NulibState* pState);
void NState_SetModConvertAll(NulibState* pState, Boolean val);
Boolean NState_GetModOverwriteExisting(const NulibState* pState);
void NState_SetModOverwriteExisting(NulibState* pState, Boolean val);
Boolean NState_GetModAddAsDisk(const NulibState* pState);
void NState_SetModAddAsDisk(NulibState* pState, Boolean val);
Boolean NState_GetModPreserveType(const NulibState* pState);
void NState_SetModPreserveType(NulibState* pState, Boolean val);
Boolean NState_GetModPreserveTypeExtended(const NulibState* pState);
void NState_SetModPreserveTypeExtended(NulibState* pState, Boolean val);
#endif /*NULIB2_STATE_H*/