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

1.1     ! root        1: /* $Id: tmesh-impl.h,v 1.1 2003/05/16 21:48:16 fredette Exp $ */
        !             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>
        !            40: _TME_RCSID("$Id: tmesh-impl.h,v 1.1 2003/05/16 21:48:16 fredette Exp $");
        !            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)
        !            61: 
        !            62: /* directory entry types: */
        !            63: #define TMESH_FS_DIRENT_DIR    (0)
        !            64: #define TMESH_FS_DIRENT_ELEMENT        (1)
        !            65: 
        !            66: /* lookup/find flags: */
        !            67: #define TMESH_SEARCH_NORMAL            (0)
        !            68: #define TMESH_SEARCH_LAST_PART_OK      TME_BIT(0)
        !            69: #define TMESH_SEARCH_NO_RECURSE                TME_BIT(1)
        !            70: 
        !            71: /* memory allocation: */
        !            72: #define _tmesh_gc_new(s, t, x)         ((t *) _tmesh_gc_malloc(s, sizeof(t) * (x)))
        !            73: #define _tmesh_gc_renew(s, t, m, x)    ((t *) _tmesh_gc_realloc(s, m, sizeof(t) * (x)))
        !            74: 
        !            75: /* a garbage collection record: */
        !            76: struct tmesh_gc_record {
        !            77: 
        !            78:   /* the next and previous records on the list: */
        !            79:   struct tmesh_gc_record *tmesh_gc_record_next;
        !            80:   struct tmesh_gc_record **tmesh_gc_record_prev;
        !            81: 
        !            82:   /* the memory to garbage collect: */
        !            83:   void *tmesh_gc_record_mem;
        !            84: };
        !            85: 
        !            86: /* a stack of ios: */
        !            87: struct tmesh_io_stack {
        !            88: 
        !            89:   /* the next io on the stack: */
        !            90:   struct tmesh_io_stack *tmesh_io_stack_next;
        !            91: 
        !            92:   /* the io itself: */
        !            93:   struct tmesh_io tmesh_io_stack_io;
        !            94: };
        !            95: 
        !            96: /* the scanner state: */
        !            97: struct tmesh_scanner {
        !            98: 
        !            99:   /* nonzero iff we need to increment the line number: */
        !           100:   unsigned int tmesh_scanner_next_line;
        !           101: 
        !           102:   /* any next token to return: */
        !           103:   int tmesh_scanner_token_next;
        !           104: 
        !           105:   /* any next character to get: */
        !           106:   int tmesh_scanner_c_next;
        !           107: 
        !           108:   /* nonzero iff we are inside a comment: */
        !           109:   int tmesh_scanner_in_comment;
        !           110: 
        !           111:   /* nonzero iff we are inside quotes: */
        !           112:   int tmesh_scanner_in_quotes;
        !           113: 
        !           114:   /* nonzero iff we are in arguments: */
        !           115:   int tmesh_scanner_in_args;
        !           116: 
        !           117:   /* the collected token: */
        !           118:   char *tmesh_scanner_token_string;
        !           119:   unsigned int tmesh_scanner_token_string_len;
        !           120:   unsigned int tmesh_scanner_token_string_size;
        !           121: };
        !           122: 
        !           123: /* a parser argv: */
        !           124: struct tmesh_parser_argv {
        !           125: 
        !           126:   /* the argument count: */
        !           127:   unsigned int tmesh_parser_argv_argc;
        !           128: 
        !           129:   /* the size of the argument vector: */
        !           130:   unsigned int tmesh_parser_argv_size;
        !           131: 
        !           132:   /* the argument vector: */
        !           133:   char **tmesh_parser_argv_argv;
        !           134: };
        !           135: 
        !           136: /* the parser value structure: */
        !           137: struct tmesh_parser_value {
        !           138:   
        !           139:   /* a token: */
        !           140:   int tmesh_parser_value_token;
        !           141: #define tmesh_parser_value_command tmesh_parser_value_token
        !           142: 
        !           143:   /* up to two strings: */
        !           144:   char *tmesh_parser_value_strings[2];
        !           145: #define tmesh_parser_value_pathname0 tmesh_parser_value_strings[0]
        !           146: #define tmesh_parser_value_pathname1 tmesh_parser_value_strings[1]
        !           147: #define tmesh_parser_value_arg tmesh_parser_value_strings[0]
        !           148: 
        !           149:   /* up to three argument vectors: */
        !           150:   struct tmesh_parser_argv tmesh_parser_value_argvs[3];
        !           151: };
        !           152: 
        !           153: /* a directory entry: */
        !           154: struct tmesh_fs_dirent {
        !           155: 
        !           156:   /* the next and previous entries in this directory: */
        !           157:   struct tmesh_fs_dirent *tmesh_fs_dirent_next;
        !           158:   struct tmesh_fs_dirent **tmesh_fs_dirent_prev;
        !           159: 
        !           160:   /* the type of this directory entry: */
        !           161:   int tmesh_fs_dirent_type;
        !           162: 
        !           163:   /* the name in this directory entry: */
        !           164:   char *tmesh_fs_dirent_name;
        !           165: 
        !           166:   /* the value in this directory entry: */
        !           167:   void *tmesh_fs_dirent_value;
        !           168: };
        !           169: 
        !           170: /* an element: */
        !           171: struct tmesh_fs_element {
        !           172: 
        !           173:   /* the parent directory of this element: */
        !           174:   struct tmesh_fs_dirent *tmesh_fs_element_parent;
        !           175: 
        !           176:   /* the real element: */
        !           177:   struct tme_element tmesh_fs_element_element;
        !           178: 
        !           179:   /* the generation number of this element: */
        !           180:   unsigned long tmesh_fs_element_gen;
        !           181: 
        !           182:   /* the arguments for this element: */
        !           183:   struct tmesh_parser_argv tmesh_fs_element_argv;
        !           184: 
        !           185:   /* the element connections: */
        !           186:   struct tmesh_fs_element_conn {
        !           187: 
        !           188:     /* the next element connection: */
        !           189:     struct tmesh_fs_element_conn *tmesh_fs_element_conn_next;
        !           190:     
        !           191:     /* backpointer to the element: */
        !           192:     struct tmesh_fs_element *tmesh_fs_element_conn_element;
        !           193:     
        !           194:     /* the generation number of this connection: */
        !           195:     unsigned long tmesh_fs_element_conn_gen;
        !           196:     
        !           197:     /* the other side of this element connection: */
        !           198:     struct tmesh_fs_element_conn *tmesh_fs_element_conn_other;
        !           199:     
        !           200:     /* the arguments for this side of the connection: */
        !           201:     struct tmesh_parser_argv tmesh_fs_element_conn_argv;
        !           202:   } *tmesh_fs_element_conns;
        !           203: };
        !           204: 
        !           205: /* the tmesh structure: */
        !           206: struct tmesh {
        !           207: 
        !           208:   /* the stack of ios: */
        !           209:   struct tmesh_io_stack *tmesh_io_stack;
        !           210: 
        !           211:   /* the scanner: */
        !           212:   struct tmesh_scanner tmesh_scanner;
        !           213: 
        !           214:   /* the root directory: */
        !           215:   struct tmesh_fs_dirent *tmesh_root;
        !           216: 
        !           217:   /* the current working directory: */
        !           218:   struct tmesh_fs_dirent *tmesh_cwd;
        !           219: 
        !           220:   /* garbage-collectable memory: */
        !           221:   struct tmesh_gc_record *tmesh_gc_record;
        !           222:   
        !           223:   /* the last generation number: */
        !           224:   unsigned long tmesh_gen_last;
        !           225: 
        !           226:   /* the support: */
        !           227:   struct tmesh_support tmesh_support;
        !           228: };
        !           229: 
        !           230: /* prototypes: */
        !           231: int _tmesh_yyparse _TME_P((struct tmesh *, struct tmesh_parser_value *, char **, int *));
        !           232: void _tmesh_io_collect_output _TME_P((char **, const char *));
        !           233: void _tmesh_io_collect_outputn _TME_P((char **, const char *, unsigned int));
        !           234: int _tmesh_fs_lookup _TME_P((struct tmesh *, char **, struct tmesh_fs_dirent **, struct tmesh_fs_dirent **, char **, int));
        !           235: struct tmesh_fs_dirent * _tmesh_fs_link _TME_P((struct tmesh_fs_dirent *, char *, int, void *));
        !           236: void _tmesh_fs_unlink _TME_P((struct tmesh_fs_dirent *));
        !           237: struct tmesh_fs_dirent * _tmesh_fs_mkdir _TME_P((struct tmesh_fs_dirent *, char *));
        !           238: void _tmesh_fs_pathname_dir _TME_P((struct tmesh_fs_dirent *, char **, struct tmesh_fs_dirent *));
        !           239: void _tmesh_fs_pathname_element _TME_P((struct tmesh_fs_element *, char **, struct tmesh_fs_dirent *));
        !           240: void *_tmesh_gc_malloc _TME_P((struct tmesh *, unsigned int));
        !           241: void *_tmesh_gc_realloc _TME_P((struct tmesh *, void *, unsigned int));
        !           242: void _tmesh_gc_free _TME_P((struct tmesh *, void *));
        !           243: void _tmesh_gc_release _TME_P((struct tmesh *, void *));
        !           244: void _tmesh_gc_release_argv _TME_P((struct tmesh *, struct tmesh_parser_argv *));
        !           245: void _tmesh_gc_gc _TME_P((struct tmesh *));
        !           246: 
        !           247: #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.