Redefine the default boolean type to gmx_bool.
[alexxy/gromacs.git] / include / string2.h
1 /*
2  * 
3  *                This source code is part of
4  * 
5  *                 G   R   O   M   A   C   S
6  * 
7  *          GROningen MAchine for Chemical Simulations
8  * 
9  *                        VERSION 3.2.0
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  * 
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  * 
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  * 
30  * For more info, check our website at http://www.gromacs.org
31  * 
32  * And Hey:
33  * Gromacs Runs On Most of All Computer Systems
34  */
35 /*! \file
36  * \brief Generic string handling functions.
37  */
38 #ifndef _string2_h
39 #define _string2_h
40
41 /*
42  *
43  * string2.h
44  * David van der Spoel
45  *
46  */
47
48
49 #include <string.h>
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <ctype.h>
53 #include <time.h>
54 #include <errno.h>
55
56 /*#include "typedefs.h"*/
57 #include "types/simple.h"
58
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 #define CONTINUE    '\\'
65 #define COMMENTSIGN ';'
66
67 int continuing(char *s);
68
69 char *fgets2(char *s, int n, FILE *stream);
70
71 void strip_comment (char *line);
72
73 int break_line (char *line,
74                        char *variable,
75                        char *value);
76
77 void upstring (char *str);
78
79 void ltrim (char *str);
80
81 void rtrim (char *str);
82
83 void trim (char *str);
84
85 void nice_header (FILE *out,const char *fn);
86
87 int gmx_strcasecmp_min(const char *str1, const char *str2);
88 int gmx_strncasecmp_min(const char *str1, const char *str2, int n);
89 /* This funny version of strcasecmp, is not only case-insensitive,
90  * but also ignores '-' and '_'.
91  */
92
93 int gmx_strcasecmp(const char *str1, const char *str2);
94 int gmx_strncasecmp(const char *str1, const char *str2, int n);
95
96 char *gmx_strdup(const char *src);
97 char *gmx_strndup(const char *src, int n);
98     
99 /** Pattern matcing with wildcards. */
100 int gmx_wcmatch(const char *pattern, const char *src);
101
102 /** Return value for gmx_wcmatch() when there is no match. */
103 #define GMX_NO_WCMATCH 1
104
105
106 /* this is our implementation of strsep, the thread-safe replacement for
107    strtok */
108 char *gmx_strsep(char **stringp, const char *delim);
109
110
111 char *wrap_lines(const char *buf,int line_width, int indent,
112                         gmx_bool bIndentFirst);
113 /* wraps lines at 'linewidth', indenting all following
114  * lines by 'indent' spaces. A temp buffer is allocated and returned,
115  * which can be disposed of if no longer needed.
116  * If !bIndentFirst, then the first line will not be indented, only 
117  * the lines that are created due to wapping.
118  */
119
120
121 char **split(char sep,char *str);
122 /* Implementation of the well-known Perl function split */
123
124 gmx_large_int_t str_to_large_int_t(const char *str, char **endptr);
125
126 #ifdef __cplusplus
127 }
128 #endif
129
130 #endif  /* _string2_h */