Wrapper for Clustal Omega.
[jabaws.git] / binaries / src / clustalo / src / clustal / util.h
1 /*********************************************************************
2  * Clustal Omega - Multiple sequence alignment
3  *
4  * Copyright (C) 2010 University College Dublin
5  *
6  * Clustal-Omega is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This file is part of Clustal-Omega.
12  *
13  ********************************************************************/
14
15 /*
16  *  RCS $Id: util.h 230 2011-04-09 15:37:50Z andreas $
17  */
18
19 #include <limits.h>
20 #include <string.h>
21 #include <strings.h>
22 #include <stdarg.h>
23 #include <stdbool.h>
24
25 #ifndef CLUSTALO_UTIL_H
26 #define CLUSTALO_UTIL_H
27
28
29 #define CKMALLOC(b) CkMalloc((b), __FUNCTION__, __LINE__)
30 #define CKCALLOC(c, s) CkCalloc((c), (s), __FUNCTION__, __LINE__)
31 #define CKREALLOC(p, b) CkRealloc((p), (b), __FUNCTION__, __LINE__)
32 #define CKFREE(b) ((b)=CkFree((b), __FUNCTION__, __LINE__))
33
34 #ifndef MAX
35 #define MAX(a,b) ((a)>(b)?(a):(b))
36 #endif
37 #ifndef MIN
38 #define MIN(a,b) ((a)<(b)?(a):(b))
39 #endif
40
41 /* STR_EQ: strings are equal, case sensitive */
42 #define STR_EQ(a,b)         (strcmp((a),(b)) == 0)
43 /*  STR_NC_EQ: strings are equal, ignoring case */
44 #define STR_NC_EQ(a,b)      (strcasecmp((a),(b)) == 0)
45
46
47 /* type boolean and false and true defined in stdbool.h */
48 #ifndef TRUE
49 #define TRUE true
50 #endif
51 #ifndef FALSE
52 #define FALSE false
53 #endif
54
55 /* clashes with hhalign
56 #define FAIL -1
57 #define OK 0
58 */
59
60
61
62 /* don't use the following directly; use macros provided above instead
63  */
64 void *CkMalloc(size_t size, const char *function, const int line);
65 void *CkCalloc(size_t count, size_t size, const char *function, const int line);
66 void *CkRealloc(void *ptr, size_t bytes, const char *function, const int line);
67 void *CkFree(void *ptr, const char *function, const int line);
68 char *CkStrdup(const char *s);
69 void PermutationArray(int **array, const int len);
70 void RandomUniqueIntArray(int *array, const int array_len, const int max_value);
71 int IntCmp(const void *a, const void *b);
72 bool FileIsWritable(char *pcFileName);
73 void QSortAndTrackIndex(int *piSortedIndices, int *piArrayToSort,
74                         const int uArrayLen, const char cOrder, const bool bOverwriteArrayToSort);
75
76 #endif