Merge branch 'release-4-5-patches' of git@git.gromacs.org:gromacs into release-4...
[gromacs/rigid-bodies.git] / include / string2.h
blob4f1f49ab71d2b8a49c0be278795ecf3f2c54af80
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.
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.
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.
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.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
35 /*! \file
36 * \brief Generic string handling functions.
38 #ifndef _string2_h
39 #define _string2_h
43 * string2.h
44 * David van der Spoel
49 #include <string.h>
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <ctype.h>
53 #include <time.h>
54 #include <errno.h>
56 /*#include "typedefs.h"*/
57 #include "types/simple.h"
59 /* Suppress Cygwin compiler warnings from using newlib version of
60 * ctype.h */
61 #ifdef GMX_CYGWIN
62 #undef isdigit
63 #undef isstring
64 #undef isspace
65 #undef isalnum
66 #undef isalpha
67 #undef ispunct
68 #undef isxdigit
69 #undef isupper
70 #undef islower
71 #undef toupper
72 #undef tolower
73 #endif
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
79 #define CONTINUE '\\'
80 #define COMMENTSIGN ';'
82 int continuing(char *s);
84 char *fgets2(char *s, int n, FILE *stream);
86 void strip_comment (char *line);
88 int break_line (char *line,
89 char *variable,
90 char *value);
92 void upstring (char *str);
94 void ltrim (char *str);
96 void rtrim (char *str);
98 void trim (char *str);
100 void nice_header (FILE *out,const char *fn);
102 int gmx_strcasecmp_min(const char *str1, const char *str2);
103 int gmx_strncasecmp_min(const char *str1, const char *str2, int n);
104 /* This funny version of strcasecmp, is not only case-insensitive,
105 * but also ignores '-' and '_'.
108 int gmx_strcasecmp(const char *str1, const char *str2);
109 int gmx_strncasecmp(const char *str1, const char *str2, int n);
111 char *gmx_strdup(const char *src);
112 char *gmx_strndup(const char *src, int n);
114 /** Pattern matcing with wildcards. */
115 int gmx_wcmatch(const char *pattern, const char *src);
117 /** Return value for gmx_wcmatch() when there is no match. */
118 #define GMX_NO_WCMATCH 1
121 /* this is our implementation of strsep, the thread-safe replacement for
122 strtok */
123 char *gmx_strsep(char **stringp, const char *delim);
126 char *wrap_lines(const char *buf,int line_width, int indent,
127 gmx_bool bIndentFirst);
128 /* wraps lines at 'linewidth', indenting all following
129 * lines by 'indent' spaces. A temp buffer is allocated and returned,
130 * which can be disposed of if no longer needed.
131 * If !bIndentFirst, then the first line will not be indented, only
132 * the lines that are created due to wapping.
136 char **split(char sep,char *str);
137 /* Implementation of the well-known Perl function split */
139 gmx_large_int_t str_to_large_int_t(const char *str, char **endptr);
141 #if ((defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64) && !defined __CYGWIN__ && !defined __CYGWIN32__)
142 #define snprintf _snprintf
143 #endif
145 #ifdef __cplusplus
147 #endif
149 #endif /* _string2_h */