extras/ignorecase.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 11 Aug 2017 01:39:58 -0400
changeset 1556 1399fe45e5b9
parent 1544 7f6020ee746c
child 1631 1aec60db9326
child 1637 f83d05e87212
permissions -rw-r--r--
ignorecase.c: use PHYSFS_utf8stricmp() now.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/** \file ignorecase.c */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
#include <stdio.h>
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
#include <stdlib.h>
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
#include <string.h>
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
#include <ctype.h>
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
#include "physfs.h"
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
#include "ignorecase.h"
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
/**
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
 * Please see ignorecase.h for details.
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
 *
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
 * License: this code is public domain. I make no warranty that it is useful,
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
 *  correct, harmless, or environmentally safe.
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
 *
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
 * This particular file may be used however you like, including copying it
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
 *  verbatim into a closed-source project, exploiting it commercially, and
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
 *  removing any trace of my name from the source (although I hope you won't
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
 *  do that). I welcome enhancements and corrections to this file, but I do
576
5da65f8e9a50 Switched to zlib license.
Ryan C. Gordon <icculus@icculus.org>
parents: 555
diff changeset
    21
 *  not require you to send me patches if you make changes. This code has
5da65f8e9a50 Switched to zlib license.
Ryan C. Gordon <icculus@icculus.org>
parents: 555
diff changeset
    22
 *  NO WARRANTY.
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
 *
576
5da65f8e9a50 Switched to zlib license.
Ryan C. Gordon <icculus@icculus.org>
parents: 555
diff changeset
    24
 * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
809
116b8fe30371 Renamed LICENSE to LICENSE.txt
Ryan C. Gordon <icculus@icculus.org>
parents: 654
diff changeset
    25
 *  Please see LICENSE.txt in the root of the source tree.
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
 *
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
 *  \author Ryan C. Gordon.
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
 */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
static int locateOneElement(char *buf)
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
{
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
    char *ptr;
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
    char **rc;
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
    char **i;
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
    if (PHYSFS_exists(buf))
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    37
        return 1;  /* quick rejection: exists in current case. */
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
    ptr = strrchr(buf, '/');  /* find entry at end of path. */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
    if (ptr == NULL)
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
        rc = PHYSFS_enumerateFiles("/");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
        ptr = buf;
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
    } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
    else
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
        *ptr = '\0';
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
        rc = PHYSFS_enumerateFiles(buf);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
        *ptr = '/';
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
        ptr++;  /* point past dirsep to entry itself. */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    } /* else */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
    for (i = rc; *i != NULL; i++)
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
    {
1556
1399fe45e5b9 ignorecase.c: use PHYSFS_utf8stricmp() now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1544
diff changeset
    55
        if (PHYSFS_utf8stricmp(*i, ptr) == 0)
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
        {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
            strcpy(ptr, *i); /* found a match. Overwrite with this case. */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
            PHYSFS_freeList(rc);
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    59
            return 1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
        } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
    } /* for */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
    /* no match at all... */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
    PHYSFS_freeList(rc);
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    65
    return 0;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
} /* locateOneElement */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
int PHYSFSEXT_locateCorrectCase(char *buf)
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
{
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
    int rc;
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
    char *ptr;
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
    while (*buf == '/')  /* skip any '/' at start of string... */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
        buf++;
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
1385
146019d5d747 Removed unused variable in extras/ignorecase.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 1194
diff changeset
    77
    ptr = buf;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
    if (*ptr == '\0')
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    79
        return 0;  /* Uh...I guess that's success. */
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
1194
b3f242b55333 Fixed a compiler warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 1056
diff changeset
    81
    while ( (ptr = strchr(ptr + 1, '/')) != NULL )
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
        *ptr = '\0';  /* block this path section off */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
        rc = locateOneElement(buf);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
        *ptr = '/'; /* restore path separator */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
        if (!rc)
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    87
            return -2;  /* missing element in path. */
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    } /* while */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
    /* check final element... */
1056
5db207d5cb58 Fixed logic bug (thanks, Dan!).
Ryan C. Gordon <icculus@icculus.org>
parents: 1016
diff changeset
    91
    return locateOneElement(buf) ? 0 : -1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
} /* PHYSFSEXT_locateCorrectCase */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
#ifdef TEST_PHYSFSEXT_LOCATECORRECTCASE
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
int main(int argc, char **argv)
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
{
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
    int rc;
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
    char buf[128];
654
c0ae01de361d Changed PHYSFS_file to PHYSFS_File to match rest of API's naming
Ryan C. Gordon <icculus@icculus.org>
parents: 576
diff changeset
   100
    PHYSFS_File *f;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
    if (!PHYSFS_init(argv[0]))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
        fprintf(stderr, "PHYSFS_init(): %s\n", PHYSFS_getLastError());
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   105
        return 1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
    } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
    if (!PHYSFS_addToSearchPath(".", 1))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
        fprintf(stderr, "PHYSFS_addToSearchPath(): %s\n", PHYSFS_getLastError());
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
        PHYSFS_deinit();
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   112
        return 1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
    } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
    if (!PHYSFS_setWriteDir("."))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
        fprintf(stderr, "PHYSFS_setWriteDir(): %s\n", PHYSFS_getLastError());
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
        PHYSFS_deinit();
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   119
        return 1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
    } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
    if (!PHYSFS_mkdir("/a/b/c"))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
        fprintf(stderr, "PHYSFS_mkdir(): %s\n", PHYSFS_getLastError());
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
        PHYSFS_deinit();
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   126
        return 1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
    } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
    if (!PHYSFS_mkdir("/a/b/C"))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
        fprintf(stderr, "PHYSFS_mkdir(): %s\n", PHYSFS_getLastError());
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
        PHYSFS_deinit();
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   133
        return 1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
    } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
    f = PHYSFS_openWrite("/a/b/c/x.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
    PHYSFS_close(f);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
    if (f == NULL)
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
        fprintf(stderr, "PHYSFS_openWrite(): %s\n", PHYSFS_getLastError());
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
        PHYSFS_deinit();
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   142
        return 1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
    } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
    f = PHYSFS_openWrite("/a/b/C/X.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
    PHYSFS_close(f);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
    if (f == NULL)
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
    {
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
        fprintf(stderr, "PHYSFS_openWrite(): %s\n", PHYSFS_getLastError());
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
        PHYSFS_deinit();
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   151
        return 1;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
    } /* if */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
    strcpy(buf, "/a/b/c/x.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
    rc = PHYSFSEXT_locateCorrectCase(buf);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
    if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
        printf("test 1 failed\n");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
    strcpy(buf, "/a/B/c/x.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
    rc = PHYSFSEXT_locateCorrectCase(buf);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
    if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
        printf("test 2 failed\n");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
    strcpy(buf, "/a/b/C/x.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
    rc = PHYSFSEXT_locateCorrectCase(buf);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
    if ((rc != 0) || (strcmp(buf, "/a/b/C/X.txt") != 0))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
        printf("test 3 failed\n");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
    strcpy(buf, "/a/b/c/X.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
    rc = PHYSFSEXT_locateCorrectCase(buf);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
    if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
        printf("test 4 failed\n");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
    strcpy(buf, "/a/b/c/z.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
    rc = PHYSFSEXT_locateCorrectCase(buf);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
    if ((rc != -1) || (strcmp(buf, "/a/b/c/z.txt") != 0))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
        printf("test 5 failed\n");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
    strcpy(buf, "/A/B/Z/z.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
    rc = PHYSFSEXT_locateCorrectCase(buf);
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
    if ((rc != -2) || (strcmp(buf, "/a/b/Z/z.txt") != 0))
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
        printf("test 6 failed\n");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
    printf("Testing completed.\n");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
    printf("  If no errors were reported, you're good to go.\n");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
    PHYSFS_delete("/a/b/c/x.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
    PHYSFS_delete("/a/b/C/X.txt");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
    PHYSFS_delete("/a/b/c");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
    PHYSFS_delete("/a/b/C");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
    PHYSFS_delete("/a/b");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
    PHYSFS_delete("/a");
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
    PHYSFS_deinit();
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   194
    return 0;
555
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
} /* main */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
#endif
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
/* end of ignorecase.c ... */
cb2a2f1202f1 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199