| 1 | /* |
| 2 | Copyright (C) 2019 Genome Research Ltd. |
| 3 | |
| 4 | Author: Petr Danecek <[email protected]> |
| 5 | |
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | of this software and associated documentation files (the "Software"), to deal |
| 8 | in the Software without restriction, including without limitation the rights |
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | copies of the Software, and to permit persons to whom the Software is |
| 11 | furnished to do so, subject to the following conditions: |
| 12 | |
| 13 | The above copyright notice and this permission notice shall be included in |
| 14 | all copies or substantial portions of the Software. |
| 15 | |
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #ifndef __COLS_H__ |
| 26 | #define __COLS_H__ |
| 27 | |
| 28 | #include <stdlib.h> |
| 29 | |
| 30 | typedef struct |
| 31 | { |
| 32 | int n,m; |
| 33 | char **off, *rmme; |
| 34 | } |
| 35 | cols_t; |
| 36 | |
| 37 | /* |
| 38 | cols_split() can be called repeatedly to split new strings, memory is allocated |
| 39 | and deallocated automatically |
| 40 | */ |
| 41 | cols_t *cols_split(const char *line, cols_t *cols, char delim); |
| 42 | |
| 43 | /* |
| 44 | Although cols_append() can be combined with cols_split(), it is much slower and |
| 45 | the string must exist throughout the life of cols unless initialized with cols_split(). |
| 46 | */ |
| 47 | void cols_append(cols_t *cols, char *str); |
| 48 | void cols_clear(cols_t *cols); |
| 49 | void cols_destroy(cols_t *cols); |
| 50 | |
| 51 | #endif |