1 /* 2 * Copyright (C) 2014 Christian Heckendorf <heckendorfc@gmail.com> 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (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, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef BUILD_H 19 #define BUILD_H 20 21 #include <string.h> 22 #include <stdlib.h> 23 #include <stdio.h> 24 #include <fcntl.h> 25 26 #define WORD_DEFAULT 1 27 #define WORD_SQUOT 2 28 #define WORD_DQUOT 4 29 30 #define COM_ARG_LITERAL 1 31 #define COM_ARG_SELECTOR 2 32 33 #define COM_SEL 1 34 #define COM_ACT 2 35 36 typedef struct wordchain_t{ 37 char *word; 38 int flags; 39 struct wordchain_t *next; 40 }wordchain_t; 41 42 typedef struct wordlist_t{ 43 char *word; 44 int flag; 45 struct wordlist_t *next; 46 }wordlist_t; 47 48 typedef struct arglist_t{ 49 wordlist_t *words; 50 int flags; 51 int tlid; 52 int tltype; 53 struct arglist_t *next; 54 }arglist_t; 55 56 typedef struct command_t{ 57 wordlist_t *cmd; 58 arglist_t *args; 59 int flags; 60 int tlid; 61 int tltype; 62 struct command_t *next; 63 }command_t; 64 65 typedef struct commandline_t{ 66 command_t *selector; 67 command_t *actions; 68 }commandline_t; 69 70 void free_wordchain(wordchain_t *w); 71 void free_wordlist(wordlist_t *w); 72 void free_arglist(arglist_t *a); 73 void free_commands(command_t *c); 74 wordchain_t* make_word(wordchain_t *word, char *piece, int flags); 75 wordlist_t* make_word_list(wordlist_t *wl, wordchain_t *word); 76 wordlist_t* append_wordlist(wordlist_t *a, wordlist_t *b); 77 wordlist_t* concat_wordlist(wordlist_t *a, wordlist_t *b); 78 //arglist_t* make_com_arg(wordlist_t *wl, int flag); 79 arglist_t* make_com_arg(void *data, int flag); 80 arglist_t* append_com_arg(arglist_t *a, arglist_t *b); 81 command_t* com_set_args(command_t *c, arglist_t *a, int flag); 82 command_t* make_command(wordlist_t *wl); 83 commandline_t* make_commandline(command_t *sel, command_t *act); 84 command_t* append_command(command_t *a, command_t *b); 85 void append_command_flags(command_t *a, const int flags); 86 87 #endif 88