-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenize.h
More file actions
30 lines (20 loc) · 912 Bytes
/
tokenize.h
File metadata and controls
30 lines (20 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef _TOKENIZE_H_
#define _TOKENIZE_H_
#include <stdlib.h>
#include <regex.h>
#include <stdbool.h>
#include <string.h>
#include "defs.h"
#include "print_message.h"
typedef char* Token_t;
u_int32_t count_tokens(char* command, char separator);
// Note, that each time tokens are created using these functions,
// they must be cleaned with clean_tokens() function
Token_t* tokenize_with_spaces(char* command, u_int32_t* tokens_len, const char separator);
// Will return list of tokens after separating the string by the separator character
// Preserves initial string in it's original state
Token_t* tokenize_limit(char* command, u_int32_t* tokens_len, const char separator, u_int32_t limit);
Token_t* tokenize(char* command, u_int32_t* tokens_len, const char separator);
Token_t nth_token(char* string, char separator, u_int32_t n);
void clean_tokens(Token_t* tokens, u_int32_t tokens_length);
#endif