Clustal Omega  1.0.3
src/clustal/util.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Clustal Omega - Multiple sequence alignment
00003  *
00004  * Copyright (C) 2010 University College Dublin
00005  *
00006  * Clustal-Omega is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This file is part of Clustal-Omega.
00012  *
00013  ********************************************************************/
00014 
00015 /*
00016  *  RCS $Id: util.h 230 2011-04-09 15:37:50Z andreas $
00017  */
00018 
00019 #include <limits.h>
00020 #include <string.h>
00021 #include <strings.h>
00022 #include <stdarg.h>
00023 #include <stdbool.h>
00024 
00025 #ifndef CLUSTALO_UTIL_H
00026 #define CLUSTALO_UTIL_H
00027 
00028 
00029 #define CKMALLOC(b) CkMalloc((b), __FUNCTION__, __LINE__)
00030 #define CKCALLOC(c, s) CkCalloc((c), (s), __FUNCTION__, __LINE__)
00031 #define CKREALLOC(p, b) CkRealloc((p), (b), __FUNCTION__, __LINE__)
00032 #define CKFREE(b) ((b)=CkFree((b), __FUNCTION__, __LINE__))
00033 
00034 #ifndef MAX
00035 #define MAX(a,b) ((a)>(b)?(a):(b))
00036 #endif
00037 #ifndef MIN
00038 #define MIN(a,b) ((a)<(b)?(a):(b))
00039 #endif
00040 
00041 /* STR_EQ: strings are equal, case sensitive */
00042 #define STR_EQ(a,b)         (strcmp((a),(b)) == 0)
00043 /*  STR_NC_EQ: strings are equal, ignoring case */
00044 #define STR_NC_EQ(a,b)      (strcasecmp((a),(b)) == 0)
00045 
00046 
00047 /* type boolean and false and true defined in stdbool.h */
00048 #ifndef TRUE
00049 #define TRUE true
00050 #endif
00051 #ifndef FALSE
00052 #define FALSE false
00053 #endif
00054 
00055 /* clashes with hhalign
00056 #define FAIL -1
00057 #define OK 0
00058 */
00059 
00060 
00061 
00062 /* don't use the following directly; use macros provided above instead
00063  */
00064 void *CkMalloc(size_t size, const char *function, const int line);
00065 void *CkCalloc(size_t count, size_t size, const char *function, const int line);
00066 void *CkRealloc(void *ptr, size_t bytes, const char *function, const int line);
00067 void *CkFree(void *ptr, const char *function, const int line);
00068 char *CkStrdup(const char *s);
00069 void PermutationArray(int **array, const int len);
00070 void RandomUniqueIntArray(int *array, const int array_len, const int max_value);
00071 int IntCmp(const void *a, const void *b);
00072 bool FileIsWritable(char *pcFileName);
00073 void QSortAndTrackIndex(int *piSortedIndices, int *piArrayToSort,
00074                         const int uArrayLen, const char cOrder, const bool bOverwriteArrayToSort);
00075 
00076 #endif