• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

strigi/src/streams

compat.cpp

Go to the documentation of this file.
00001 /* This file is part of Strigi Desktop Search
00002  *
00003  * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public License
00016  * along with this library; see the file COPYING.LIB.  If not, write to
00017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifdef HAVE_CONFIG_H
00022 # include "config.h"
00023 #endif
00024 
00025 #include <string.h>
00026 #include <stdlib.h>
00027 #include <ctype.h>
00028 
00029 
00030 #ifndef HAVE_SETENV
00031 int setenv(const char *name, const char *value, int overwrite)
00032 {
00033     int i, iRet;
00034     char * a;
00035 
00036     if (!overwrite && getenv(name)) return 0;
00037 
00038     i = strlen(name) + strlen(value) + 2;
00039     a = (char*)malloc(i);
00040     if (!a) return 1;
00041 
00042     strcpy(a, name);
00043     strcat(a, "=");
00044     strcat(a, value);
00045 
00046     iRet = putenv(a);
00047     free(a);
00048     return iRet;
00049 }
00050 #endif
00051 
00052 #ifndef HAVE_STRCASECMP
00053 int strcasecmp(const char* sa, const char* sb){
00054     char ca,cb;
00055     if (sa == sb)
00056         return 0;
00057     int i=0;
00058 
00059     do{
00060         ca = tolower( (*(sa++)) );
00061         cb = tolower( (*(sb++)) );
00062 
00063         i++;
00064     } while ( ca != L'\0' && (ca == cb) );
00065 
00066     return (int)(ca - cb);
00067 }
00068 #endif
00069 
00070 #ifndef HAVE_STRNCASECMP
00071 int strncasecmp(const char* sa, const char* sb, int l){
00072     char ca,cb;
00073     if (sa == sb)
00074         return 0;
00075     int i=0;
00076 
00077     do{
00078         if ( i >= l )
00079             break;
00080 
00081         ca = tolower( (*(sa++)) );
00082         cb = tolower( (*(sb++)) );
00083 
00084         i++;
00085     } while ( ca != L'\0' && (ca == cb) );
00086 
00087     return (int)(ca - cb);
00088 }
00089 #endif
00090 
00091 #ifndef HAVE_STRCASESTR
00092 const char * strcasestr(const char *big, const char *little){
00093     char* tmp1 = strdup(big);
00094     char* tmp2 = strdup(little);
00095 #ifdef HAVE_STRLWR /* for windows */
00096     strlwr(tmp1);
00097     strlwr(tmp2);
00098 #else /* for solaris */
00099     char* t = tmp1;
00100     while (*t) {
00101         tolower(*t);
00102         ++t;
00103     }
00104     t = tmp2;
00105     while (*t) {
00106         tolower(*t);
00107         ++t;
00108     }
00109 #endif
00110 
00111     const char * ret = strstr(tmp1,tmp2);
00112 
00113     if ( ret != NULL ){
00114         ret = big + (ret-tmp1);
00115     }
00116 
00117     free(tmp1);
00118     free(tmp2);
00119 
00120     return ret;
00121 }
00122 #endif
00123 
00124 #ifndef HAVE_ISBLANK
00125 int isblank(char c){
00126     if ( c == ' ' || c == '\t' || c == '\n' || c == '\r' )
00127      return 1;
00128 
00129     return 0;
00130 }
00131 #endif
00132 
00133 #ifndef HAVE_MKSTEMP
00134 #ifdef _WIN32
00135  #include <fcntl.h>
00136  #include <sys/stat.h>
00137 #endif
00138 
00139 int mkstemp(char *tmpl)
00140 {
00141    mktemp(tmpl);
00142    return open(tmpl,O_RDWR|O_BINARY|O_CREAT|O_EXCL|_O_SHORT_LIVED, _S_IREAD|_S_IWRITE);
00143 }
00144 #endif

strigi/src/streams

Skip menu "strigi/src/streams"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal