| 1 |
/* |
| 2 |
* FCML - Free Code Manipulation Library. |
| 3 |
* Copyright (C) 2010-2020 Slawomir Wojtasiak |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef FCML_ENVIRONMENT_H_ |
| 21 |
#define FCML_ENVIRONMENT_H_ |
| 22 |
|
| 23 |
#include <stdarg.h> |
| 24 |
#include <fcml_env.h> |
| 25 |
|
| 26 |
#include "fcml_types.h" |
| 27 |
|
| 28 |
/* Memory. */ |
| 29 |
|
| 30 |
#define FCML_ENV_ALLOC_ST(str) (str*) \ |
| 31 |
fcml_fn_env_memory_alloc_clear(sizeof(str)); |
| 32 |
|
| 33 |
#define FCML_ENV_ALLOC_CLEAR(variable, type) type* variable = (type*) \ |
| 34 |
fcml_fn_env_memory_alloc_clear(sizeof(type)) |
| 35 |
|
| 36 |
/* Memory allocation. */ |
| 37 |
fcml_ptr fcml_fn_env_memory_alloc(fcml_usize size); |
| 38 |
|
| 39 |
fcml_ptr fcml_fn_env_memory_realloc(fcml_ptr ptr, fcml_usize size); |
| 40 |
|
| 41 |
fcml_ptr fcml_fn_env_memory_alloc_clear(fcml_usize size); |
| 42 |
|
| 43 |
void fcml_fn_env_memory_copy(fcml_ptr dest, const fcml_ptr src, fcml_usize len); |
| 44 |
|
| 45 |
void fcml_fn_env_memory_clear(fcml_ptr src, fcml_usize len); |
| 46 |
|
| 47 |
fcml_bool fcml_fn_env_memory_cmp(const fcml_ptr src1, const fcml_ptr src2, |
| 48 |
fcml_usize len); |
| 49 |
|
| 50 |
void fcml_fn_env_memory_free(fcml_ptr ptr); |
| 51 |
|
| 52 |
/* Strings. */ |
| 53 |
fcml_bool fcml_fn_env_str_strblank(const fcml_string str); |
| 54 |
|
| 55 |
fcml_usize fcml_fn_env_str_strlen(const fcml_string str); |
| 56 |
|
| 57 |
fcml_string fcml_fn_env_str_stralloc(fcml_usize len); |
| 58 |
|
| 59 |
fcml_string fcml_fn_env_str_strdup(const fcml_string str); |
| 60 |
|
| 61 |
void fcml_fn_env_str_strcpy( fcml_string src, const fcml_string dst); |
| 62 |
|
| 63 |
fcml_bool fcml_fn_env_str_strcmp(const fcml_string src1, |
| 64 |
const fcml_string src2); |
| 65 |
|
| 66 |
void fcml_fn_env_str_strncpy( fcml_string dst, const fcml_string src, |
| 67 |
fcml_usize len); |
| 68 |
|
| 69 |
void fcml_fn_env_str_strclr( fcml_string str); |
| 70 |
|
| 71 |
fcml_string fcml_fn_env_str_strldup(const fcml_string str, fcml_usize size); |
| 72 |
|
| 73 |
void fcml_fn_env_str_strfree( fcml_string str); |
| 74 |
|
| 75 |
void fcml_fn_env_str_vsnprintf( fcml_string buffer, fcml_usize maxlen, |
| 76 |
const fcml_string format, va_list args); |
| 77 |
|
| 78 |
void fcml_fn_env_str_snprintf( fcml_string buffer, fcml_usize maxlen, |
| 79 |
fcml_string format, ...); |
| 80 |
|
| 81 |
/* Characters. */ |
| 82 |
fcml_bool fcml_fn_env_is_alpha(fcml_char c); |
| 83 |
fcml_bool fcml_fn_env_is_digit(fcml_char c); |
| 84 |
|
| 85 |
#endif /* FCML_ENVIRONMENT_H_ */ |