Graphviz  2.29.20120524.0446
lib/common/strncasecmp.c
Go to the documentation of this file.
00001 /* $Id$ $Revision$ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /*************************************************************************
00005  * Copyright (c) 2011 AT&T Intellectual Property 
00006  * All rights reserved. This program and the accompanying materials
00007  * are made available under the terms of the Eclipse Public License v1.0
00008  * which accompanies this distribution, and is available at
00009  * http://www.eclipse.org/legal/epl-v10.html
00010  *
00011  * Contributors: See CVS logs. Details at http://www.graphviz.org/
00012  *************************************************************************/
00013 
00014 #ifdef HAVE_CONFIG_H
00015 #include "config.h"
00016 #endif
00017 
00018 
00019 #include <string.h>
00020 #include <ctype.h>
00021 
00022 int strncasecmp(const char *s1, const char *s2, unsigned int n)
00023 {
00024     if (n == 0)
00025         return 0;
00026 
00027     while ((n-- != 0)
00028            && (tolower(*(unsigned char *) s1) ==
00029                tolower(*(unsigned char *) s2))) {
00030         if (n == 0 || *s1 == '\0' || *s2 == '\0')
00031             return 0;
00032         s1++;
00033         s2++;
00034     }
00035 
00036     return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
00037 }
00038