| 1 | /** |
| 2 | This software and ancillary information (herein called "SOFTWARE") |
| 3 | called Supermon is made available under the terms described |
| 4 | here. The SOFTWARE has been approved for release with associated |
| 5 | LA-CC Number LA-CC 99-51. |
| 6 | |
| 7 | Unless otherwise indicated, this SOFTWARE has been authored by an |
| 8 | employee or employees of the University of California, operator of the |
| 9 | Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with |
| 10 | the U.S. Department of Energy. The U.S. Government has rights to use, |
| 11 | reproduce, and distribute this SOFTWARE, and to allow others to do so. |
| 12 | The public may copy, distribute, prepare derivative works and publicly |
| 13 | display this SOFTWARE without charge, provided that this Notice and |
| 14 | any statement of authorship are reproduced on all copies. Neither the |
| 15 | Government nor the University makes any warranty, express or implied, |
| 16 | or assumes any liability or responsibility for the use of this |
| 17 | SOFTWARE. |
| 18 | |
| 19 | If SOFTWARE is modified to produce derivative works, such modified |
| 20 | SOFTWARE should be clearly marked, so as not to confuse it with the |
| 21 | version available from LANL. |
| 22 | **/ |
| 23 | /** NOTICE: This software is licensed under the GNU Public License, which |
| 24 | is included as LICENSE_GPL in this source distribution. **/ |
| 25 | /** NOTE: This library is part of the supermon project, hence the name |
| 26 | supermon above. **/ |
| 27 | /*** |
| 28 | * Matt's smaller s-expression parsing library |
| 29 | * |
| 30 | * Written by Matt Sottile ([email protected]), January 2002. |
| 31 | ***/ |
| 32 | |
| 33 | #include <fcntl.h> |
| 34 | #include <unistd.h> |
| 35 | #include <stdio.h> |
| 36 | #include <stdlib.h> |
| 37 | #include <string.h> |
| 38 | #include "sexp.h"cxx . . $ `<file>/src/sexpr/sexp.h`/ |
| 39 | #include <assert.h> |
| 40 | |
| 41 | static sexp_iowrap_tcxx . . $ sexp_iowrap_t# *_internal_iowcxx . . $ _internal_iow. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 42 | |
| 43 | /** |
| 44 | * |
| 45 | */ |
| 46 | int |
| 47 | cleanup_sexp_iocxx . . $ cleanup_sexp_io(d1b40a211a1a4e4c).() |
| 48 | { |
| 49 | if (_internal_iowcxx . . $ _internal_iow. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 50 | destroy_iowrapcxx . . $ destroy_iowrap(7ebb9b7c85c1e4b).(_internal_iowcxx . . $ _internal_iow.); |
| 51 | _internal_iowcxx . . $ _internal_iow. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 52 | |
| 53 | return 1; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * |
| 58 | */ |
| 59 | int |
| 60 | read_sexpcxx . . $ read_sexp(fa3df6d5de4c4541). (char *buf, int size, int f) |
| 61 | { |
| 62 | sexp_tcxx . . $ sexp_t# *sx; |
| 63 | |
| 64 | if (_internal_iowcxx . . $ _internal_iow. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 65 | _internal_iowcxx . . $ _internal_iow. = init_iowrapcxx . . $ init_iowrap(e0c0384cb6c5a594).(f); |
| 66 | if (_internal_iowcxx . . $ _internal_iow.->fdcxx . . $ sexp_iowrap#fd. != f) { |
| 67 | destroy_iowrapcxx . . $ destroy_iowrap(7ebb9b7c85c1e4b).(_internal_iowcxx . . $ _internal_iow.); |
| 68 | if (f > -1) _internal_iowcxx . . $ _internal_iow. = init_iowrapcxx . . $ init_iowrap(e0c0384cb6c5a594).(f); |
| 69 | else return 0; |
| 70 | } |
| 71 | |
| 72 | sx = read_one_sexpcxx . . $ read_one_sexp(639365aca6601bb3).(_internal_iowcxx . . $ _internal_iow.); |
| 73 | |
| 74 | if (sx == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return 0; |
| 75 | |
| 76 | print_sexpcxx . . $ print_sexp(7c024e49ab511bbb).(buf,size,sx); |
| 77 | |
| 78 | destroy_sexpcxx . . $ destroy_sexp(7420e001cc8f68ca).(sx); |
| 79 | |
| 80 | return 1; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * |
| 85 | */ |
| 86 | int |
| 87 | fread_sexpcxx . . $ fread_sexp(e41d332e68e0823d). (char *buf, int size, FILEcxx . . $ FILE# *fp) |
| 88 | { |
| 89 | return read_sexpcxx . . $ read_sexp(fa3df6d5de4c4541).(buf,size,filenocxx . . $ fileno(89bc1efcdac0ca22).(fp)); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * |
| 94 | */ |
| 95 | sexp_iowrap_tcxx . . $ sexp_iowrap_t# *init_iowrapcxx . . $ init_iowrap(e0c0384cb6c5a594).(int fd) { |
| 96 | sexp_iowrap_tcxx . . $ sexp_iowrap_t# *iow; |
| 97 | |
| 98 | iow = (sexp_iowrap_tcxx . . $ sexp_iowrap_t# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(sexp_iowrap_tcxx . . $ sexp_iowrap_t#)); |
| 99 | |
| 100 | iow->cccxx . . $ sexp_iowrap#cc. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 101 | iow->fdcxx . . $ sexp_iowrap#fd. = fd; |
| 102 | iow->cntcxx . . $ sexp_iowrap#cnt. = 0; |
| 103 | |
| 104 | return iow; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * |
| 109 | */ |
| 110 | void destroy_iowrapcxx . . $ destroy_iowrap(7ebb9b7c85c1e4b).(sexp_iowrap_tcxx . . $ sexp_iowrap_t# *iow) { |
| 111 | if (iow == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return; /* idiot */ |
| 112 | |
| 113 | destroy_continuationcxx . . $ destroy_continuation(4ab61756d5c8fbe4).(iow->cccxx . . $ sexp_iowrap#cc.); |
| 114 | freecxx . . $ free(5d22bdacc48458e8).(iow); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * |
| 119 | */ |
| 120 | sexp_tcxx . . $ sexp_t# *read_one_sexpcxx . . $ read_one_sexp(639365aca6601bb3).(sexp_iowrap_tcxx . . $ sexp_iowrap_t# *iow) { |
| 121 | sexp_tcxx . . $ sexp_t# *sx = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 122 | |
| 123 | if (iow->cntcxx . . $ sexp_iowrap#cnt. == 0) { |
| 124 | iow->cntcxx . . $ sexp_iowrap#cnt. = readcxx . . $ read(7e34d0a36f355389).(iow->fdcxx . . $ sexp_iowrap#fd.,iow->bufcxx . . $ sexp_iowrap#buf.,BUFSIZcxx . . $ `<external>/232824719582829767/stdio.h:100:9`!); |
| 125 | if (iow->cntcxx . . $ sexp_iowrap#cnt. == 0) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 126 | } |
| 127 | |
| 128 | iow->cccxx . . $ sexp_iowrap#cc. = cparse_sexpcxx . . $ cparse_sexp(a78678ab65c90ce8).(iow->bufcxx . . $ sexp_iowrap#buf.,iow->cntcxx . . $ sexp_iowrap#cnt.,iow->cccxx . . $ sexp_iowrap#cc.); |
| 129 | |
| 130 | while (iow->cccxx . . $ sexp_iowrap#cc.->last_sexpcxx . . $ pcont#last_sexp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 131 | if (iow->cccxx . . $ sexp_iowrap#cc.->errorcxx . . $ pcont#error. != 0) { |
| 132 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"ERROR\n"); |
| 133 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 134 | } |
| 135 | |
| 136 | iow->cntcxx . . $ sexp_iowrap#cnt. = readcxx . . $ read(7e34d0a36f355389).(iow->fdcxx . . $ sexp_iowrap#fd.,iow->bufcxx . . $ sexp_iowrap#buf.,BUFSIZcxx . . $ `<external>/232824719582829767/stdio.h:100:9`!); |
| 137 | |
| 138 | if (iow->cntcxx . . $ sexp_iowrap#cnt. == 0) |
| 139 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 140 | |
| 141 | iow->cccxx . . $ sexp_iowrap#cc. = cparse_sexpcxx . . $ cparse_sexp(a78678ab65c90ce8).(iow->bufcxx . . $ sexp_iowrap#buf.,iow->cntcxx . . $ sexp_iowrap#cnt.,iow->cccxx . . $ sexp_iowrap#cc.); |
| 142 | } |
| 143 | |
| 144 | sx = iow->cccxx . . $ sexp_iowrap#cc.->last_sexpcxx . . $ pcont#last_sexp.; |
| 145 | iow->cccxx . . $ sexp_iowrap#cc.->last_sexpcxx . . $ pcont#last_sexp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 146 | |
| 147 | return sx; |
| 148 | } |