Debian Codegraph @

src/common/util.h

raw symbols SCIP
1 /*
2 * Copyright (C) 1998,1999,2000 Ross Combs ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19
20 /*****/
21 #ifndef JUST_NEED_TYPES
22 #ifndef INCLUDED_UTIL_PROTOS
23 #define INCLUDED_UTIL_PROTOS
24
25 #include <cstdio>
26 #include <ctime>
27
28 namespace pvpgn
29 {
30
31 extern int strstart(char const * full, char const * part);
32 extern char * file_get_line(std::FILE * fp);
33 extern char * strreverse(char * str);
34 extern int str_to_uint(char const * str, unsigned int * num);
35 extern int str_to_ushort(char const * str, unsigned short * num);
36 extern int str_print_term(std::FILE * fp, char const * str, unsigned int len, int allow_nl);
37 extern int str_get_bool(char const * str);
38 extern char const * seconds_to_timestr(unsigned int totsecs); /* FIXME: can this be marked pure? */
39 extern int clockstr_to_seconds(char const * clockstr, unsigned int * totsecs);
40 extern char * escape_fs_chars(char const * in, unsigned int len);
41 extern char * escape_chars(char const * in, unsigned int len);
42 extern char * unescape_chars(char const * in);
43 extern void str_to_hex(char * target, char const * data, int datalen);
44 extern int hex_to_str(char const * source, char * data, int datalen);
45 extern int timestr_to_time(char const * timestr, std::time_t* ptime);
46
47 static inline char * str_skip_space(char *str)
48 {
49 for (; *str == ' ' || *str == '\t'; str++);
50 return str;
51 }
52
53 static inline char * str_skip_word(char *str)
54 {
55 for (; *str != ' ' && *str != '\t' && *str; str++);
56 return str;
57 }
58
59 }
60
61 #endif
62 #endif