コード例 #1
0
ファイル: TestSimple.c プロジェクト: rostamn739/ciderpress
/*
 * 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);
}
コード例 #2
0
ファイル: Exerciser.c プロジェクト: rostamn739/ciderpress
/*
 * Main entry point.
 *
 * We don't currently take any arguments, so this is pretty straightforward.
 */
int
main(void)
{
    NuError result;
    long majorVersion, minorVersion, bugVersion;
    const char* nufxLibDate;
    const char* nufxLibFlags;

    (void) NuGetVersion(&majorVersion, &minorVersion, &bugVersion,
            &nufxLibDate, &nufxLibFlags);
    printf("NufxLib exerciser, linked with NufxLib v%ld.%ld.%ld [%s]\n\n",
        majorVersion, minorVersion, bugVersion, nufxLibFlags);
    printf("Use 'h' or '?' for help, 'q' to quit.\n");

    /* stuff useful when debugging lots */
    if (unlink(kTempFile) == 0)
        fprintf(stderr, "NOTE: whacked exer-temp\n");
    if (unlink("new.shk") == 0)
        fprintf(stderr, "NOTE: whacked new.shk\n");

#if defined(HAS_MALLOC_CHECK_) && !defined(USE_DMALLOC)
    /*
     * This is really nice to have on Linux and any other system that
     * uses the GNU libc/malloc stuff.  It slows things down, but it
     * tells you when you do something dumb with malloc/realloc/free.
     * (Solaris 2.7 has a similar feature that is enabled by setting the
     * environment variable LD_PRELOAD to include watchmalloc.so.  Other
     * OSs and 3rd-party malloc packages may have similar features.)
     *
     * This environment variable must be set when the program is launched.
     * Tweaking the environment within the program has no effect.
     *
     * Now that the Linux world has "valgrind", this is probably
     * unnecessary.
     */
    {
        char* debugSet = getenv("MALLOC_CHECK_");
        if (debugSet == nil)
            printf("WARNING: MALLOC_CHECK_ not enabled\n\n");
    }
#endif

    result = CommandLoop();

    exit(result != kNuErrNone);
}
コード例 #3
0
ファイル: Main.c プロジェクト: iKarith/nulib2
/*
 * Entry point.
 */
int main(int argc, char** argv)
{
    NulibState* pState = NULL;
    int32_t majorVersion, minorVersion, bugVersion;
    int result = 0;

    (void) NuGetVersion(&majorVersion, &minorVersion, &bugVersion, NULL, NULL);
    if (majorVersion != kNuVersionMajor || minorVersion < kNuVersionMinor) {
        fprintf(stderr, "ERROR: wrong version of NufxLib --"
                        " wanted %d.%d.x, got %d.%d.%d.\n",
            kNuVersionMajor, kNuVersionMinor,
            majorVersion, minorVersion, bugVersion);
        goto bail;
    }

    #if 0
    extern NuResult ErrorMessageHandler(NuArchive* pArchive,
        void* vErrorMessage);
    NuSetGlobalErrorMessageHandler(ErrorMessageHandler);
    #endif

    if (NState_Init(&pState) != kNuErrNone) {
        fprintf(stderr, "ERROR: unable to initialize globals\n");
        exit(1);
    }

    gProgName = GetProgName(pState, argv[0]);

    if (ProcessOptions(pState, argc, argv) < 0) {
        result = 2;
        goto bail;
    }

    if (NState_ExtraInit(pState) != kNuErrNone) {
        fprintf(stderr, "ERROR: additional initialization failed\n");
        exit(1);
    }

    result = DoWork(pState);
    if (result)
        printf("Failed.\n");

bail:
    NState_Free(pState);
    exit(result);
}
コード例 #4
0
ファイル: Main.c プロジェクト: iKarith/nulib2
/*
 * Print program usage.
 */
static void Usage(const NulibState* pState)
{
    int32_t majorVersion, minorVersion, bugVersion;
    const char* nufxLibDate;
    const char* nufxLibFlags;

    (void) NuGetVersion(&majorVersion, &minorVersion, &bugVersion,
            &nufxLibDate, &nufxLibFlags);

    printf("\nNuLib2 v%s, linked with NufxLib v%d.%d.%d [%s]\n",
        NState_GetProgramVersion(pState),
        majorVersion, minorVersion, bugVersion, nufxLibFlags);
    printf("Copyright (C) 2000-2015, Andy McFadden.  All Rights Reserved.\n");
    printf("This software is distributed under terms of the BSD License.\n");
    printf("Visit http://www.nulib.com/ for source code and documentation.\n\n");
    printf("Usage: %s -command[modifiers] archive [filename-list]\n\n",
        gProgName);
    printf(
        "  -a  add files, create arc if needed   -x  extract files\n"
        "  -t  list files (short)                -v  list files (verbose)\n"
        "  -p  extract files to pipe, no msgs    -i  test archive integrity\n"
        "  -d  delete files from archive         -h  extended help message\n"
        "\n"
        " modifiers:\n"
        "  -u  update files (add + keep newest)  -f  freshen (update, no add)\n"
        "  -r  recurse into subdirs              -j  junk (don't record) directory names\n"
        "  -0  don't use compression             -c  add one-line comments\n");
    if (NuTestFeature(kNuFeatureCompressDeflate) == kNuErrNone)
        printf("  -z  use zlib 'deflate' compression    ");
    else
        printf("  -z  use zlib [not included]           ");
    if (NuTestFeature(kNuFeatureCompressBzip2) == kNuErrNone)
        printf("-zz use bzip2 BWT compression\n");
    else
        printf("-zz use bzip2 [not included]\n");
    printf(
        "  -l  auto-convert text files           -ll convert CR/LF on ALL files\n"
        "  -s  stomp existing files w/o asking   -k  store files as disk images\n"
        "  -e  preserve ProDOS file types        -ee preserve types and extend names\n"
        "  -b  force Binary II mode\n"
        );
}