Annotation of tme/tmesh/tmesh-impl.h, revision 1.1.1.2

1.1.1.2 ! root        1: /* $Id: tmesh-impl.h,v 1.2 2003/07/29 18:32:31 fredette Exp $ */
1.1       root        2: 
                      3: /* tmesh/tmesh-impl.h - private header file for the tmesh implementation: */
                      4: 
                      5: /*
                      6:  * Copyright (c) 2003 Matt Fredette
                      7:  * All rights reserved.
                      8:  *
                      9:  * Redistribution and use in source and binary forms, with or without
                     10:  * modification, are permitted provided that the following conditions
                     11:  * are met:
                     12:  * 1. Redistributions of source code must retain the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer.
                     14:  * 2. Redistributions in binary form must reproduce the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer in the
                     16:  *    documentation and/or other materials provided with the distribution.
                     17:  * 3. All advertising materials mentioning features or use of this software
                     18:  *    must display the following acknowledgement:
                     19:  *      This product includes software developed by Matt Fredette.
                     20:  * 4. The name of the author may not be used to endorse or promote products
                     21:  *    derived from this software without specific prior written permission.
                     22:  *
                     23:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     24:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     25:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     26:  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
                     27:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     28:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     29:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     30:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     31:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
                     32:  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     33:  * POSSIBILITY OF SUCH DAMAGE.
                     34:  */
                     35: 
                     36: #ifndef _TMESH_IMPL_H
                     37: #define _TMESH_IMPL_H
                     38: 
                     39: #include <tme/common.h>
1.1.1.2 ! root       40: _TME_RCSID("$Id: tmesh-impl.h,v 1.2 2003/07/29 18:32:31 fredette Exp $");
1.1       root       41: 
                     42: /* includes: */
                     43: #include <tme/element.h>
                     44: #include <tme/tmesh.h>
                     45: #include <errno.h>
                     46: 
                     47: /* macros: */
                     48: 
                     49: /* commands: */
                     50: #define TMESH_COMMAND_NOP      (0)
                     51: #define TMESH_COMMAND_SOURCE   (1)
                     52: #define TMESH_COMMAND_MKDIR    (2)
                     53: #define TMESH_COMMAND_RMDIR    (3)
                     54: #define TMESH_COMMAND_CD       (4)
                     55: #define TMESH_COMMAND_PWD      (5)
                     56: #define TMESH_COMMAND_LS       (6)
                     57: #define TMESH_COMMAND_CONNECT  (7)
                     58: #define TMESH_COMMAND_RM       (8)
                     59: #define TMESH_COMMAND_MV       (9)
                     60: #define TMESH_COMMAND_COMMAND  (10)
1.1.1.2 ! root       61: #define TMESH_COMMAND_LOG      (11)
1.1       root       62: 
                     63: /* directory entry types: */
                     64: #define TMESH_FS_DIRENT_DIR    (0)
                     65: #define TMESH_FS_DIRENT_ELEMENT        (1)
                     66: 
                     67: /* lookup/find flags: */
                     68: #define TMESH_SEARCH_NORMAL            (0)
                     69: #define TMESH_SEARCH_LAST_PART_OK      TME_BIT(0)
                     70: #define TMESH_SEARCH_NO_RECURSE                TME_BIT(1)
                     71: 
                     72: /* memory allocation: */
                     73: #define _tmesh_gc_new(s, t, x)         ((t *) _tmesh_gc_malloc(s, sizeof(t) * (x)))
                     74: #define _tmesh_gc_renew(s, t, m, x)    ((t *) _tmesh_gc_realloc(s, m, sizeof(t) * (x)))
                     75: 
                     76: /* a garbage collection record: */
                     77: struct tmesh_gc_record {
                     78: 
                     79:   /* the next and previous records on the list: */
                     80:   struct tmesh_gc_record *tmesh_gc_record_next;
                     81:   struct tmesh_gc_record **tmesh_gc_record_prev;
                     82: 
                     83:   /* the memory to garbage collect: */
                     84:   void *tmesh_gc_record_mem;
                     85: };
                     86: 
                     87: /* a stack of ios: */
                     88: struct tmesh_io_stack {
                     89: 
                     90:   /* the next io on the stack: */
                     91:   struct tmesh_io_stack *tmesh_io_stack_next;
                     92: 
                     93:   /* the io itself: */
                     94:   struct tmesh_io tmesh_io_stack_io;
                     95: };
                     96: 
                     97: /* the scanner state: */
                     98: struct tmesh_scanner {
                     99: 
                    100:   /* nonzero iff we need to increment the line number: */
                    101:   unsigned int tmesh_scanner_next_line;
                    102: 
                    103:   /* any next token to return: */
                    104:   int tmesh_scanner_token_next;
                    105: 
                    106:   /* any next character to get: */
                    107:   int tmesh_scanner_c_next;
                    108: 
                    109:   /* nonzero iff we are inside a comment: */
                    110:   int tmesh_scanner_in_comment;
                    111: 
                    112:   /* nonzero iff we are inside quotes: */
                    113:   int tmesh_scanner_in_quotes;
                    114: 
                    115:   /* nonzero iff we are in arguments: */
                    116:   int tmesh_scanner_in_args;
                    117: 
                    118:   /* the collected token: */
                    119:   char *tmesh_scanner_token_string;
                    120:   unsigned int tmesh_scanner_token_string_len;
                    121:   unsigned int tmesh_scanner_token_string_size;
                    122: };
                    123: 
                    124: /* a parser argv: */
                    125: struct tmesh_parser_argv {
                    126: 
                    127:   /* the argument count: */
                    128:   unsigned int tmesh_parser_argv_argc;
                    129: 
                    130:   /* the size of the argument vector: */
                    131:   unsigned int tmesh_parser_argv_size;
                    132: 
                    133:   /* the argument vector: */
                    134:   char **tmesh_parser_argv_argv;
                    135: };
                    136: 
                    137: /* the parser value structure: */
                    138: struct tmesh_parser_value {
                    139:   
                    140:   /* a token: */
                    141:   int tmesh_parser_value_token;
                    142: #define tmesh_parser_value_command tmesh_parser_value_token
                    143: 
                    144:   /* up to two strings: */
                    145:   char *tmesh_parser_value_strings[2];
                    146: #define tmesh_parser_value_pathname0 tmesh_parser_value_strings[0]
                    147: #define tmesh_parser_value_pathname1 tmesh_parser_value_strings[1]
                    148: #define tmesh_parser_value_arg tmesh_parser_value_strings[0]
                    149: 
                    150:   /* up to three argument vectors: */
                    151:   struct tmesh_parser_argv tmesh_parser_value_argvs[3];
                    152: };
                    153: 
                    154: /* a directory entry: */
                    155: struct tmesh_fs_dirent {
                    156: 
                    157:   /* the next and previous entries in this directory: */
                    158:   struct tmesh_fs_dirent *tmesh_fs_dirent_next;
                    159:   struct tmesh_fs_dirent **tmesh_fs_dirent_prev;
                    160: 
                    161:   /* the type of this directory entry: */
                    162:   int tmesh_fs_dirent_type;
                    163: 
                    164:   /* the name in this directory entry: */
                    165:   char *tmesh_fs_dirent_name;
                    166: 
                    167:   /* the value in this directory entry: */
                    168:   void *tmesh_fs_dirent_value;
                    169: };
                    170: 
                    171: /* an element: */
                    172: struct tmesh_fs_element {
                    173: 
                    174:   /* the parent directory of this element: */
                    175:   struct tmesh_fs_dirent *tmesh_fs_element_parent;
                    176: 
                    177:   /* the real element: */
                    178:   struct tme_element tmesh_fs_element_element;
                    179: 
                    180:   /* the generation number of this element: */
                    181:   unsigned long tmesh_fs_element_gen;
                    182: 
                    183:   /* the arguments for this element: */
                    184:   struct tmesh_parser_argv tmesh_fs_element_argv;
                    185: 
                    186:   /* the element connections: */
                    187:   struct tmesh_fs_element_conn {
                    188: 
                    189:     /* the next element connection: */
                    190:     struct tmesh_fs_element_conn *tmesh_fs_element_conn_next;
                    191:     
                    192:     /* backpointer to the element: */
                    193:     struct tmesh_fs_element *tmesh_fs_element_conn_element;
                    194:     
                    195:     /* the generation number of this connection: */
                    196:     unsigned long tmesh_fs_element_conn_gen;
                    197:     
                    198:     /* the other side of this element connection: */
                    199:     struct tmesh_fs_element_conn *tmesh_fs_element_conn_other;
                    200:     
                    201:     /* the arguments for this side of the connection: */
                    202:     struct tmesh_parser_argv tmesh_fs_element_conn_argv;
                    203:   } *tmesh_fs_element_conns;
                    204: };
                    205: 
                    206: /* the tmesh structure: */
                    207: struct tmesh {
                    208: 
                    209:   /* the stack of ios: */
                    210:   struct tmesh_io_stack *tmesh_io_stack;
                    211: 
                    212:   /* the scanner: */
                    213:   struct tmesh_scanner tmesh_scanner;
                    214: 
                    215:   /* the root directory: */
                    216:   struct tmesh_fs_dirent *tmesh_root;
                    217: 
                    218:   /* the current working directory: */
                    219:   struct tmesh_fs_dirent *tmesh_cwd;
                    220: 
                    221:   /* garbage-collectable memory: */
                    222:   struct tmesh_gc_record *tmesh_gc_record;
                    223:   
                    224:   /* the last generation number: */
                    225:   unsigned long tmesh_gen_last;
                    226: 
                    227:   /* the support: */
                    228:   struct tmesh_support tmesh_support;
                    229: };
                    230: 
                    231: /* prototypes: */
                    232: int _tmesh_yyparse _TME_P((struct tmesh *, struct tmesh_parser_value *, char **, int *));
                    233: void _tmesh_io_collect_output _TME_P((char **, const char *));
                    234: void _tmesh_io_collect_outputn _TME_P((char **, const char *, unsigned int));
                    235: int _tmesh_fs_lookup _TME_P((struct tmesh *, char **, struct tmesh_fs_dirent **, struct tmesh_fs_dirent **, char **, int));
                    236: struct tmesh_fs_dirent * _tmesh_fs_link _TME_P((struct tmesh_fs_dirent *, char *, int, void *));
                    237: void _tmesh_fs_unlink _TME_P((struct tmesh_fs_dirent *));
                    238: struct tmesh_fs_dirent * _tmesh_fs_mkdir _TME_P((struct tmesh_fs_dirent *, char *));
                    239: void _tmesh_fs_pathname_dir _TME_P((struct tmesh_fs_dirent *, char **, struct tmesh_fs_dirent *));
                    240: void _tmesh_fs_pathname_element _TME_P((struct tmesh_fs_element *, char **, struct tmesh_fs_dirent *));
                    241: void *_tmesh_gc_malloc _TME_P((struct tmesh *, unsigned int));
                    242: void *_tmesh_gc_realloc _TME_P((struct tmesh *, void *, unsigned int));
                    243: void _tmesh_gc_free _TME_P((struct tmesh *, void *));
                    244: void _tmesh_gc_release _TME_P((struct tmesh *, void *));
                    245: void _tmesh_gc_release_argv _TME_P((struct tmesh *, struct tmesh_parser_argv *));
                    246: void _tmesh_gc_gc _TME_P((struct tmesh *));
                    247: 
                    248: #endif /* !_TMESH_IMPL_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.