Main Page Class Hierarchy Compound List File List Compound Members File Members Related Pages

# mac_string.c

    00001 /**********************************************************************
    00002  * $Id: mac_string_c-source.html,v 1.5 2002/12/21 19:13:13 warmerda Exp $
    00003  *
    00004  * Project:  CPL - Common Portability Library
    00005  * Purpose:  String functions for MacOS (pre MacOS X).
    00006  * Author:   Dennis Christopher, dennis@avenza.com
    00007  *
    00008  **********************************************************************
    00009  * Copyright (c) 2001, Avenza Systems, Inc.
    00010  *
    00011  * Permission is hereby granted, free of charge, to any person obtaining a
    00012  * copy of this software and associated documentation files (the "Software"),
    00013  * to deal in the Software without restriction, including without limitation
    00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00015  * and/or sell copies of the Software, and to permit persons to whom the
    00016  * Software is furnished to do so, subject to the following conditions:
    00017  *
    00018  * The above copyright notice and this permission notice shall be included
    00019  * in all copies or substantial portions of the Software.
    00020  *
    00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00022  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
    00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00027  * DEALINGS IN THE SOFTWARE.
    00028  **********************************************************************
    00029  *
    00030  * $Log: mac_string_c-source.html,v $
    00030  * Revision 1.5  2002/12/21 19:13:13  warmerda
    00030  * updated
    00030  *
    00031  * Revision 1.4  2002/03/05 14:26:57  warmerda
    00032  * expanded tabs
    00033  *
    00034  * Revision 1.3  2001/07/18 04:00:49  warmerda
    00035  * added CPL_CVSID
    00036  *
    00037  * Revision 1.2  2001/04/30 18:16:16  warmerda
    00038  * added big pre10 ifdef
    00039  *
    00040  * Revision 1.1  2001/04/30 18:15:39  warmerda
    00041  * New
    00042  *
    00043  *
    00044  **********************************************************************/
    00045
    00046 #include <string.h>
    00047 #include <ctype.h>
    00048 #include <stdlib.h>
    00049
    00050 #include "cpl_port.h"
    00051
    00052 #ifdef macos_pre10
    00053
    00054 CPL_CVSID("$Id: mac_string_c-source.html,v 1.5 2002/12/21 19:13:13 warmerda Exp $");
    00055
    00056 int strcasecmp(char * str1, char * str2)
    00057 {
    00058     int i;
    00059     char * temp1, *temp2;
    00060
    00061     for(i=0;str1[i]!='\0';i++)
    00062         temp1[i]=tolower(str1[i]);
    00063     temp1[i]='\0';
    00064
    00065     for(i=0;str2[i]!='\0';i++)
    00066         temp2[i]=tolower(str2[i]);
    00067     temp2[i]='\0';
    00068
    00069     return (strcmp( temp1, temp2) );
    00070
    00071
    00072 }
    00073
    00074 int strncasecmp(char * str1, char * str2, int len)
    00075 {
    00076     int i;
    00077     char * temp1, *temp2;
    00078
    00079     for(i=0;str1[i]!='\0';i++)
    00080         temp1[i]=tolower(str1[i]);
    00081     temp1[i]='\0';
    00082
    00083     for(i=0;str2[i]!='\0';i++)
    00084         temp2[i]=tolower(str2[i]);
    00085     temp2[i]='\0';
    00086
    00087     return (strncmp( temp1, temp2, len) );
    00088
    00089 }
    00090
    00091 char * strdup (char *instr)
    00092 {
    00093     char * temp = calloc(strlen(instr)+1, 1);
    00094
    00095     if (temp)
    00096     {
    00097         strcpy(temp, instr);
    00098     }
    00099
    00100     return temp;
    00101 }
    00102
    00103 #endif /* defined(macos_pre10) */