diff options
-rw-r--r-- | ConfigureChecks.cmake | 2 | ||||
-rw-r--r-- | config.h.cmake | 17 | ||||
-rw-r--r-- | src/libical/icalrecur.c | 2 | ||||
-rw-r--r-- | src/libical/icaltimezone.c | 16 | ||||
-rw-r--r-- | src/libicalss/icalcalendar.c | 54 |
5 files changed, 45 insertions, 46 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 048aa099..72923c50 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -33,7 +33,9 @@ check_function_exists(_snprintf HAVE__SNPRINTF) #Windows <stdio.h> check_function_exists(stat HAVE_STAT) check_function_exists(_stat HAVE__STAT) check_function_exists(strcasecmp HAVE_STRCASECMP) +check_function_exists(strncasecmp HAVE_STRNCASECMP) check_function_exists(stricmp HAVE_STRICMP) +check_function_exists(strnicmp HAVE_STRNICMP) check_function_exists(strdup HAVE_STRDUP) #Unix <string.h> check_function_exists(_strdup HAVE__STRDUP) #Windows <string.h> check_function_exists(unsetenv HAVE_UNSETENV) diff --git a/config.h.cmake b/config.h.cmake index 78212a9e..7befde5e 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -66,9 +66,15 @@ /* Define to 1 if you have the `strcasecmp' function. */ #cmakedefine HAVE_STRCASECMP 1 +/* Define to 1 if you have the `strncasecmp' function. */ +#cmakedefine HAVE_STRNCASECMP 1 + /* Define to 1 if you have the `stricmp' function. */ #cmakedefine HAVE_STRICMP 1 +/* Define to 1 if you have the `strnicmp' function. */ +#cmakedefine HAVE_STRNICMP 1 + /* Define to 1 if you have the `strdup' function. */ #cmakedefine HAVE_STRDUP 1 @@ -221,6 +227,17 @@ typedef int pid_t; #include <strings.h> #endif +/* strncasecmp: String compare, case independent, size limited */ +#if !defined(HAVE_STRNCASECMP) +#if defined(HAVE_STRNICMP) +#define strncasecmp strnicmp +#else +#error "No case independent string compare size limited function available" +#endif +#else +#include <strings.h> +#endif + /* snprintf: size limited sprintf */ #if defined(HAVE__SNPRINTF) #define snprintf _snprintf diff --git a/src/libical/icalrecur.c b/src/libical/icalrecur.c index 5544c8be..9c2e600f 100644 --- a/src/libical/icalrecur.c +++ b/src/libical/icalrecur.c @@ -137,6 +137,7 @@ #include "icaltimezone.h" #include <ctype.h> +#include <stddef.h> /* For offsetof() macro */ #include <stdlib.h> #ifdef HAVE_LIBICU @@ -173,7 +174,6 @@ typedef long intptr_t; #include <errno.h> /* for errno */ #include <string.h> /* for strdup and strchr*/ #include <assert.h> -#include <stddef.h> /* For offsetof() macro */ #ifdef HAVE_INTTYPES_H #include <inttypes.h> #endif diff --git a/src/libical/icaltimezone.c b/src/libical/icaltimezone.c index b4dba956..5311d92a 100644 --- a/src/libical/icaltimezone.c +++ b/src/libical/icaltimezone.c @@ -45,16 +45,6 @@ static pthread_mutex_t builtin_mutex = PTHREAD_MUTEX_INITIALIZER; #endif - -#ifdef UNCLEAN -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "icalproperty.h" - -#include <sys/stat.h> - #ifdef WIN32 #ifndef _WIN32_WCE #include <mbstring.h> @@ -72,12 +62,6 @@ static pthread_mutex_t builtin_mutex = PTHREAD_MUTEX_INITIALIZER; #ifndef S_ISDIR #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) #endif -#endif - -#if defined(_MSC_VER) -#define snprintf _snprintf -#define strcasecmp stricmp -#endif #endif diff --git a/src/libicalss/icalcalendar.c b/src/libicalss/icalcalendar.c index eb9d0fc3..9131f783 100644 --- a/src/libicalss/icalcalendar.c +++ b/src/libicalss/icalcalendar.c @@ -42,10 +42,6 @@ #include <unistd.h> /* For mkdir, stat */ #endif -#ifndef PATH_MAX -#define PATH_MAX 512 -#endif - #include <string.h> /* for strcat */ #ifdef WIN32 @@ -75,17 +71,17 @@ struct icalcalendar_impl* icalcalendar_new_impl(void) icalerrorenum icalcalendar_create(struct icalcalendar_impl* impl) { - char path[PATH_MAX]; + char path[MAXPATHLEN]; struct stat sbuf; int r; icalerror_check_arg_re((impl != 0),"impl",ICAL_BADARG_ERROR); path[0] = '\0'; - strncpy(path,impl->dir,PATH_MAX-1); - strncat(path,"/",PATH_MAX-strlen(path)-1); - strncat(path,BOOKED_DIR,PATH_MAX-strlen(path)-1); - path[PATH_MAX-1] = '\0'; + strncpy(path,impl->dir,MAXPATHLEN-1); + strncat(path,"/",MAXPATHLEN-strlen(path)-1); + strncat(path,BOOKED_DIR,MAXPATHLEN-strlen(path)-1); + path[MAXPATHLEN-1] = '\0'; r = stat(path,&sbuf); @@ -185,15 +181,15 @@ int icalcalendar_ownlock(icalcalendar* impl) icalset* icalcalendar_get_booked(icalcalendar* impl) { - char dir[PATH_MAX]; + char dir[MAXPATHLEN]; icalerror_check_arg_rz((impl != 0),"impl"); dir[0] = '\0'; - strncpy(dir,impl->dir,PATH_MAX-1); - strncat(dir,"/",PATH_MAX-strlen(dir)-1); - strncat(dir,BOOKED_DIR,PATH_MAX-strlen(dir)-1); - dir[PATH_MAX-1] = '\0'; + strncpy(dir,impl->dir,MAXPATHLEN-1); + strncat(dir,"/",MAXPATHLEN-strlen(dir)-1); + strncat(dir,BOOKED_DIR,MAXPATHLEN-strlen(dir)-1); + dir[MAXPATHLEN-1] = '\0'; if (impl->booked == 0){ icalerror_clear_errno(); @@ -207,14 +203,14 @@ icalset* icalcalendar_get_booked(icalcalendar* impl) icalset* icalcalendar_get_incoming(icalcalendar* impl) { - char path[PATH_MAX]; + char path[MAXPATHLEN]; icalerror_check_arg_rz((impl != 0),"impl"); path[0] = '\0'; - strncpy(path,impl->dir,PATH_MAX-1); - strncat(path,"/",PATH_MAX-strlen(path)-1); - strncat(path,INCOMING_FILE,PATH_MAX-strlen(path)-1); - path[PATH_MAX-1] = '\0'; + strncpy(path,impl->dir,MAXPATHLEN-1); + strncat(path,"/",MAXPATHLEN-strlen(path)-1); + strncat(path,INCOMING_FILE,MAXPATHLEN-strlen(path)-1); + path[MAXPATHLEN-1] = '\0'; if (impl->properties == 0){ impl->properties = icalfileset_new(path); @@ -225,14 +221,14 @@ icalset* icalcalendar_get_incoming(icalcalendar* impl) icalset* icalcalendar_get_properties(icalcalendar* impl) { - char path[PATH_MAX]; + char path[MAXPATHLEN]; icalerror_check_arg_rz((impl != 0),"impl"); path[0] = '\0'; - strncpy(path,impl->dir,PATH_MAX-1); - strncat(path,"/",PATH_MAX-strlen(path)-1); - strncat(path,PROP_FILE,PATH_MAX-strlen(path)-1); - path[PATH_MAX-1] = '\0'; + strncpy(path,impl->dir,MAXPATHLEN-1); + strncat(path,"/",MAXPATHLEN-strlen(path)-1); + strncat(path,PROP_FILE,MAXPATHLEN-strlen(path)-1); + path[MAXPATHLEN-1] = '\0'; if (impl->properties == 0){ impl->properties = icalfileset_new(path); @@ -243,14 +239,14 @@ icalset* icalcalendar_get_properties(icalcalendar* impl) icalset* icalcalendar_get_freebusy(icalcalendar* impl) { - char path[PATH_MAX]; + char path[MAXPATHLEN]; icalerror_check_arg_rz((impl != 0),"impl"); path[0] = '\0'; - strncpy(path,impl->dir,PATH_MAX-1); - strncat(path,"/",PATH_MAX-strlen(path)-1); - strncat(path,FBLIST_FILE,PATH_MAX-strlen(path)-1); - path[PATH_MAX-1] = '\0'; + strncpy(path,impl->dir,MAXPATHLEN-1); + strncat(path,"/",MAXPATHLEN-strlen(path)-1); + strncat(path,FBLIST_FILE,MAXPATHLEN-strlen(path)-1); + path[MAXPATHLEN-1] = '\0'; if (impl->freebusy == 0){ impl->freebusy = icalfileset_new(path); |