mirror of
https://github.com/fadden/ciderpress.git
synced 2024-11-23 11:33:58 +00:00
51b5f00f5c
CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
106 lines
2.5 KiB
C
106 lines
2.5 KiB
C
/*
|
|
* NuFX archive manipulation library
|
|
* Copyright (C) 2000-2007 by Andy McFadden, All Rights Reserved.
|
|
* This is free software; you can redistribute it and/or modify it under the
|
|
* terms of the BSD License, see the file COPYING.LIB.
|
|
*
|
|
* Simple test program. Opens an archive, dumps the contents.
|
|
*
|
|
* If the first argument is "-", this will read from stdin. Otherwise,
|
|
* the first argument is taken to be an archive filename, and opened.
|
|
*/
|
|
#include <stdio.h>
|
|
#include "NufxLib.h"
|
|
#include "Common.h"
|
|
|
|
|
|
/*
|
|
* Callback function to display the contents of a single record.
|
|
*
|
|
* "pRecord->filename" is the record's filename, whether from the record
|
|
* header, a filename thread, or a default value ("UNKNOWN", stuffed in
|
|
* when a record has no filename at all).
|
|
*/
|
|
NuResult
|
|
ShowContents(NuArchive* pArchive, void* vpRecord)
|
|
{
|
|
const NuRecord* pRecord = (NuRecord*) vpRecord;
|
|
|
|
printf("*** Filename = '%s'\n", pRecord->filename);
|
|
|
|
return kNuOK;
|
|
}
|
|
|
|
|
|
/*
|
|
* Dump the contents from the streaming input.
|
|
*
|
|
* If we're not interested in handling an archive on stdin, we could just
|
|
* pass the filename in here and use NuOpenRO instead.
|
|
*/
|
|
int
|
|
DoStreamStuff(FILE* fp)
|
|
{
|
|
NuError err;
|
|
NuArchive* pArchive = nil;
|
|
|
|
err = NuStreamOpenRO(fp, &pArchive);
|
|
if (err != kNuErrNone) {
|
|
fprintf(stderr, "ERROR: unable to open stream archive (err=%d)\n", err);
|
|
goto bail;
|
|
}
|
|
|
|
printf("*** Streaming contents!\n");
|
|
|
|
err = NuContents(pArchive, ShowContents);
|
|
if (err != kNuErrNone) {
|
|
fprintf(stderr, "ERROR: NuContents failed (err=%d)\n", err);
|
|
goto bail;
|
|
}
|
|
|
|
bail:
|
|
if (pArchive != nil) {
|
|
NuError err2 = NuClose(pArchive);
|
|
if (err == kNuErrNone)
|
|
err = err2;
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
|
|
/*
|
|
* Grab the name of an archive to read. If "-" was given, use stdin.
|
|
*/
|
|
int
|
|
main(int argc, char** argv)
|
|
{
|
|
long major, minor, bug;
|
|
const char* pBuildDate;
|
|
FILE* infp = nil;
|
|
int cc;
|
|
|
|
(void) NuGetVersion(&major, &minor, &bug, &pBuildDate, nil);
|
|
printf("Using NuFX lib %ld.%ld.%ld built on or after %s\n",
|
|
major, minor, bug, pBuildDate);
|
|
|
|
if (argc != 2) {
|
|
fprintf(stderr, "Usage: %s (archive-name|-)\n", argv[0]);
|
|
exit(2);
|
|
}
|
|
|
|
if (strcmp(argv[1], "-") == 0)
|
|
infp = stdin;
|
|
else {
|
|
infp = fopen(argv[1], kNuFileOpenReadOnly);
|
|
if (infp == nil) {
|
|
fprintf(stderr, "ERROR: unable to open '%s'\n", argv[1]);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
cc = DoStreamStuff(infp);
|
|
exit(cc != 0);
|
|
}
|
|
|