Changeset 3456

Show
Ignore:
Timestamp:
08/09/07 15:18:23 (1 year ago)
Author:
tg
Message:

fix

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/common-nfo/tools/nfotiser/nfotiser.h

    r3455 r3456  
    1111 
    1212#include <sys/queue.h> 
     13#include "nfohelpr.h" 
    1314 
    1415struct categories { 
  • branches/common-nfo/tools/nfotiser/parser.c

    r3455 r3456  
    8989        struct parser_res *entry; 
    9090        const struct parser_keywords *kwp; 
    91         char ch, *cp, *t, *tp, *buf, *buf_base; 
     91        char *cp, *t, *tp, *buf, *buf_base; 
    9292        size_t len, n; 
    9393        struct stat sb; 
     
    152152                ++t; 
    153153        t = str_nsave(buf, t - buf + /* NL */ 1); 
    154  loop_addline: 
    155154        if (cp != NULL) { 
    156155                if (*(tp = cp + strlen(cp) - 2) == '\\') 
     
    207206                        if (zp == np) 
    208207                                errx(1, "syntax error: iterator expected"); 
    209                         if (*zp != kwp->kwtype == KWT_ITERATED ? '\0' : '_') 
     208                        if (*zp != (char)(kwp->kwtype == KWT_ITERATED ? 
     209                            '\0' : '_')) 
    210210                                errx(1, "syntax error: %s expected," 
    211211                                    " got 0x%02X", kwp->kwtype == KWT_ITERATED ? 
     
    256256 
    257257void 
    258 nfo_parser_dump(struct parser_res *entry, const struct parser_keywords *kws) 
     258parser_dump(struct parser_res *entry, const struct parser_keywords *kws) 
    259259{ 
    260260        const struct parser_keywords *kwp; 
    261261 
     262        kwp = parser_getkwbynum(entry->keyword, kws); 
    262263        printf("keyword %s (type %s)", 
    263             (kwp = parser_getkwbynum(entry->keyword, kws)) == NULL ? 
    264             "<unknown>" : kwp->kwprefix, 
     264            kwp == NULL ? "<unknown>" : kwp->kwprefix, 
    265265            kwp == NULL ? "invalid" : 
    266266            kwp->kwtype == KWT_NORMAL ? "normal" : 
  • branches/common-nfo/tools/sqlite/dbif.h

    r3453 r3456  
    1 /* $FreeWRT: src/share/misc/licence.template,v 1.20 2006/12/11 21:04:56 tg Rel $ */ 
    2  
    31/*- 
    4  * Copyright (c) 2007 
    5  *      Thorsten Glaser <tg@mirbsd.de> 
    6  * 
    7  * Provided that these terms and disclaimer and all copyright notices 
    8  * are retained or reproduced in an accompanying document, permission 
    9  * is granted to deal in this work without restriction, including un- 
    10  * limited rights to use, publicly perform, distribute, sell, modify, 
    11  * merge, give away, or sublicence. 
    12  * 
    13  * Advertising materials mentioning features or use of this work must 
    14  * display the following acknowledgement: 
    15  *      This product includes material provided by Thorsten Glaser. 
    16  * This acknowledgement does not need to be reprinted if this work is 
    17  * linked into a bigger work whose licence does not allow such clause 
    18  * and the author of this work is given due credit in the bigger work 
    19  * or its accompanying documents, where such information is generally 
    20  * kept, provided that said credits are retained. 
    21  * 
    22  * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 
    23  * the utmost extent permitted by applicable law, neither express nor 
    24  * implied; without malicious intent or gross negligence. In no event 
    25  * may a licensor, author or contributor be held liable for indirect, 
    26  * direct, other damage, loss, or other issues arising in any way out 
    27  * of dealing in the work, even if advised of the possibility of such 
    28  * damage or existence of a defect, except proven that it results out 
    29  * of said person's immediate fault when using the work as intended. 
     2 * $FreeWRT$ 
     3 *- 
     4 * This file is part of the FreeWRT project. FreeWRT is copyrighted 
     5 * material, please see the LICENCE file in the top-level directory 
     6 * or at http://www.freewrt.org/licence for details. 
    307 */ 
    318 
     
    3411 
    3512#include "sqlite3.h" 
    36  
    37 /* stolen from mksh's sh.h */ 
    38 #ifdef EXTERN 
    39 # define I__(i) = i 
    40 #else 
    41 # define I__(i) 
    42 # define EXTERN extern 
    43 # define EXTERN_DEFINED 
    44 #endif 
    45  
    46 /* debugging */ 
    47 #define D(level, fmt, ...) do {                         \ 
    48         if (debug >= (level))                           \ 
    49                 fprintf(stderr, (fmt), ##__VA_ARGS__);  \ 
    50 } while (0) 
     13#include "nfohelpr.h" 
    5114 
    5215__BEGIN_DECLS 
    53 EXTERN int debug I__(0); 
    5416EXTERN sqlite3 *db I__(NULL); 
    5517 
     
    7032                dberr(1, et ? et : "processing SQL stmt");      \ 
    7133} while (0) 
    72  
    73 #ifdef NFOTISER 
    74 #ifdef __GLIBC__ 
    75 /* fgetln.c */ 
    76 char *fgetln(FILE *, size_t *); 
    77 /* strlfun.c */ 
    78 size_t strlcat(char *, const char *, size_t); 
    79 size_t strlcpy(char *, const char *, size_t); 
    80 #endif 
    81 #endif 
    8234__END_DECLS 
    8335 
    84 /* useful stuff */ 
    85 #define xmalloc(size) ({                                \ 
    86         void *xmalloc_ptr;                              \ 
    87         size_t xmalloc_sz = (size);                     \ 
    88                                                         \ 
    89         if ((xmalloc_ptr = malloc(xmalloc_sz)) == NULL) \ 
    90                 err(255, "cannot allocate %zu bytes",   \ 
    91                     xmalloc_sz);                        \ 
    92         (xmalloc_ptr);                                  \ 
    93 }) 
    94  
    95 #define xrealloc(ptr, size) ({                          \ 
    96         void *xrealloc_newptr;                          \ 
    97         size_t xrealloc_sz = (size);                    \ 
    98                                                         \ 
    99         xrealloc_newptr = realloc((ptr), xrealloc_sz);  \ 
    100         if (xrealloc_newptr == NULL)                    \ 
    101                 err(255, "cannot realloc to %zu bytes", \ 
    102                     xrealloc_sz);                       \ 
    103         (xrealloc_newptr);                              \ 
    104 }) 
    105  
    106 #define str_save(s) ({                                  \ 
    107         const char *str_save_s = (s);                   \ 
    108                                                         \ 
    109         (str_nsave(str_save_s, strlen(str_save_s)));    \ 
    110 }) 
    111  
    112 #define str_nsave(s, n) ({                              \ 
    113         char *str_nsave_ptr;                            \ 
    114         size_t str_nsave_sz = (n);                      \ 
    115                                                         \ 
    116         str_nsave_ptr = xmalloc(str_nsave_sz + 1);      \ 
    117         memcpy(str_nsave_sz, (s), str_nsave_sz);        \ 
    118         str_nsave_ptr[str_nsave_sz] = '\0';             \ 
    119         (str_nsave_ptr);                                \ 
    120 }) 
    121  
    122 #define str_add(d, s) ({                                \ 
    123         const char *str_add_s = (s);                    \ 
    124                                                         \ 
    125         (str_nadd((d), str_add_s, strlen(str_add_s)));  \ 
    126 }) 
    127  
    128 #define str_nadd(d, s, n) ({                            \ 
    129         char *str_nadd_ptr = (d), *str_nadd_newptr;     \ 
    130         size_t str_nadd_sz, str_nadd_addsz = (n);       \ 
    131                                                         \ 
    132         str_nadd_sz = str_nadd_ptr ?                    \ 
    133             strlen(str_nadd_ptr) : 0;                   \ 
    134         str_nadd_newptr = str_nadd_ptr ?                \ 
    135             xrealloc(str_nadd_ptr,                      \ 
    136             str_nadd_sz + str_nadd_addsz + 1) :         \ 
    137             xmalloc(str_nadd_addsz + 1);                \ 
    138         str_nadd_ptr = str_nadd_newptr + str_nadd_sz;   \ 
    139         memcpy(str_nadd_ptr, (s), str_nadd_addsz);      \ 
    140         str_nadd_ptr[str_nadd_addsz] = '\0';            \ 
    141         (str_nadd_newptr);                              \ 
    142 }) 
    143  
    14436#endif 
  • branches/common-nfo/tools/sqlite/nfohelpr.h

    r3453 r3456  
    3030 */ 
    3131 
    32 #ifndef DBIF_H 
    33 #define DBIF_H 
    34  
    35 #include "sqlite3.h" 
     32#ifndef NFOHELPR_H 
     33#define NFOHELPR_H 
    3634 
    3735/* stolen from mksh's sh.h */ 
     
    5250__BEGIN_DECLS 
    5351EXTERN int debug I__(0); 
    54 EXTERN sqlite3 *db I__(NULL); 
    55  
    56 /* dbif.c */ 
    57 void dberr(int, const char *, ...) 
    58     __attribute__((format (printf, 2, 3))) 
    59     __attribute__((noreturn)); 
    60 #define dbexecv(cb, cbarg, sqlfmt, ...) dbexecv_(__FILE__, __LINE__, \ 
    61             __func__, (cb), (cbarg), (sqlfmt), __VA_ARGS__) 
    62 int dbexecv_(const char *, unsigned, const char *, sqlite3_callback, 
    63     void *, const char *, ...) 
    64     __attribute__((nonnull (6))) 
    65     __attribute__((format (printf, 6, 7))); 
    66  
    67 #define xdbexecv(et, cb, cbarg, sqlfmt, ...) do {               \ 
    68         if (dbexecv_(__FILE__, __LINE__, __func__,              \ 
    69             (cb), (cbarg), (sqlfmt), __VA_ARGS__))              \ 
    70                 dberr(1, et ? et : "processing SQL stmt");      \ 
    71 } while (0) 
    7252 
    7353#ifdef NFOTISER 
     
    11595                                                        \ 
    11696        str_nsave_ptr = xmalloc(str_nsave_sz + 1);      \ 
    117         memcpy(str_nsave_sz, (s), str_nsave_sz);      \ 
     97        memcpy(str_nsave_ptr, (s), str_nsave_sz);     \ 
    11898        str_nsave_ptr[str_nsave_sz] = '\0';             \ 
    11999        (str_nsave_ptr);                                \