-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_parser.h
More file actions
39 lines (28 loc) · 906 Bytes
/
Copy pathstring_parser.h
File metadata and controls
39 lines (28 loc) · 906 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
31
32
33
34
35
36
37
38
39
/*
* string_parser.h
*
* Created on: Nov 8, 2020
* Author: gguan, Monil
*
* Purpose: The goal of this dynamic helper string struct is to reliably
* tokenize strings base on different delimeter. Following this structure
* would help to keep the code clean.
*
*/
#ifndef STRING_PARSER_H_
#define STRING_PARSER_H_
#define _GUN_SOURCE
typedef struct
{
char** command_list;
int num_token;
}command_line;
//this functions returns the number of tokens needed for the string array
//based on the delimeter
int count_token (char* buf, const char* delim);
//This functions can tokenize a string to token arrays base on a specified delimeter,
//it returns a struct variable
command_line str_filler (char* buf, const char* delim);
//this function safely free all the tokens within the array.
void free_command_line(command_line* command);
#endif /* STRING_PARSER_H_ */