123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /* Copyright Yann Weber <asmsh@yannweb.net>
- This file is part of asmsh.
-
- asmsh is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or any later version.
-
- asmsh is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along
- with asmsh. If not, see <https://www.gnu.org/licenses/>.
- */
- #ifndef ASMSH_SHELL_ENV_H
- #define ASMSH_SHELL_ENV_H
- #include "config.h"
-
- #include <unistd.h>
- #include <stdlib.h>
- #include <string.h>
-
- #define ASMSH_VARNAME_MAX 256
- #define ASMSH_SYMALLOC 64
-
- /** The symbol prefixing a label */
- #define ASMSH_LABEL_SYM '@'
-
- typedef struct asmsh_sym_s asmsh_sym_t;
- typedef struct asmsh_symtable_s asmsh_symtable_t;
-
- struct asmsh_sym_s
- {
- char name[ASMSH_VARNAME_MAX + 1];
- unsigned long addr;
- };
-
- /** Stores the list of symbols associated with their address/value
- *
- * @note Symboles are ordered by name, ascending
- */
- struct asmsh_symtable_s
- {
- asmsh_sym_t *syms;
- size_t syms_sz;
- size_t alloc;
- };
-
- /** if freeval value given to add are freed on clean */
- int asmsh_symtable_init(asmsh_symtable_t *table);
- void asmsh_symtable_clean(asmsh_symtable_t *table);
-
- /**
- * @return 1 on update 0 on added -1 on error */
- int asmsh_symtable_add(asmsh_symtable_t *table, const char *name, unsigned long val);
- /**
- * @return 0 on deleted, 1 on not found, -1 on error */
- int asmsh_symtable_del(asmsh_symtable_t *table, const char *name);
- /**
- * @return NULL on error or not found else a ref */
- const asmsh_sym_t *asmsh_symtable_get(asmsh_symtable_t *table, const char *name);
-
- #include "shell.h"
-
- #endif
|