#ifndef RUBY_EVAL_INTERN_H #define RUBY_EVAL_INTERN_H #define PASS_PASSED_BLOCK_TH(th) do { \ (th)->passed_block = GC_GUARDED_PTR_REF((rb_block_t *)(th)->cfp->lfp[0]); \ (th)->cfp->flag |= VM_FRAME_FLAG_PASSED; \ } while (0) #define PASS_PASSED_BLOCK() do { \ rb_thread_t * const __th__ = GET_THREAD(); \ PASS_PASSED_BLOCK_TH(__th__); \ } while (0) #include "ruby/ruby.h" #include "ruby/node.h" #include "ruby/util.h" #include "ruby/signal.h" #include "vm_core.h" #ifdef HAVE_STDLIB_H #include #endif #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE #define EXIT_FAILURE 1 #endif #include #include #include "ruby/st.h" #include "dln.h" #ifdef __APPLE__ #include #endif /* Make alloca work the best possible way. */ #ifdef __GNUC__ # ifndef atarist # ifndef alloca # define alloca __builtin_alloca # endif # endif /* atarist */ #else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ void *alloca(); # endif # endif /* AIX */ # endif /* HAVE_ALLOCA_H */ #endif /* __GNUC__ */ #ifdef HAVE_STDARG_PROTOTYPES #include #define va_init_list(a,b) va_start(a,b) #else #include #define va_init_list(a,b) va_start(a) #endif #ifndef HAVE_STRING_H char *strrchr(const char *, const char); #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_NET_SOCKET_H #include #endif #ifdef __MACOS__ #include "macruby_private.h" #endif #ifdef __VMS #include "vmsruby_private.h" #endif #define ruby_setjmp(env) RUBY_SETJMP(env) #define ruby_longjmp(env,val) RUBY_LONGJMP(env,val) #ifdef __CYGWIN__ int _setjmp(), _longjmp(); #endif #include #include #include #if defined(__VMS) #pragma nostandard #endif #ifdef HAVE_SYS_SELECT_H #include #endif /* Solaris sys/select.h switches select to select_large_fdset to support larger file descriptors if FD_SETSIZE is larger than 1024 on 32bit environment. But Ruby doesn't change FD_SETSIZE because fd_set is allocated dynamically. So following definition is required to use select_large_fdset. */ #ifdef HAVE_SELECT_LARGE_FDSET #define select(n, r, w, e, t) select_large_fdset(n, r, w, e, t) #endif #ifdef HAVE_SYS_PARAM_H #include #endif #include #define SAVE_ROOT_JMPBUF(th, stmt) do \ if (ruby_setjmp((th)->root_jmpbuf) == 0) { \ stmt; \ } \ else { \ rb_fiber_start(); \ } while (0) #define TH_PUSH_TAG(th) do { \ rb_thread_t * const _th = th; \ struct rb_vm_tag _tag; \ _tag.tag = 0; \ _tag.prev = _th->tag; \ _th->tag = &_tag; #define TH_POP_TAG() \ _th->tag = _tag.prev; \ } while (0) #define TH_POP_TAG2() \ _th->tag = _tag.prev #define PUSH_TAG() TH_PUSH_TAG(GET_THREAD()) #define POP_TAG() TH_POP_TAG() #define TH_EXEC_TAG() ruby_setjmp(_th->tag->buf) #define EXEC_TAG() \ TH_EXEC_TAG() #define TH_JUMP_TAG(th, st) do { \ ruby_longjmp(th->tag->buf,(st)); \ } while (0) #define JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), st) enum ruby_tag_type { RUBY_TAG_RETURN = 0x1, RUBY_TAG_BREAK = 0x2, RUBY_TAG_NEXT = 0x3, RUBY_TAG_RETRY = 0x4, RUBY_TAG_REDO = 0x5, RUBY_TAG_RAISE = 0x6, RUBY_TAG_THROW = 0x7, RUBY_TAG_FATAL = 0x8, RUBY_TAG_MASK = 0xf }; #define TAG_RETURN RUBY_TAG_RETURN #define TAG_BREAK RUBY_TAG_BREAK #define TAG_NEXT RUBY_TAG_NEXT #define TAG_RETRY RUBY_TAG_RETRY #define TAG_REDO RUBY_TAG_REDO #define TAG_RAISE RUBY_TAG_RAISE #define TAG_THROW RUBY_TAG_THROW #define TAG_FATAL RUBY_TAG_FATAL #define TAG_MASK RUBY_TAG_MASK #define NEW_THROW_OBJECT(val, pt, st) \ ((VALUE)NEW_NODE(NODE_LIT, (val), (pt), (st))) #define SET_THROWOBJ_CATCH_POINT(obj, val) \ (RNODE((obj))->u2.value = (val)) #define SET_THROWOBJ_STATE(obj, val) \ (RNODE((obj))->u3.value = (val)) #define GET_THROWOBJ_VAL(obj) ((VALUE)RNODE((obj))->u1.value) #define GET_THROWOBJ_CATCH_POINT(obj) ((VALUE*)RNODE((obj))->u2.value) #define GET_THROWOBJ_STATE(obj) ((int)RNODE((obj))->u3.value) #define SCOPE_TEST(f) (vm_cref()->nd_visi & (f)) #define SCOPE_CHECK(f) (vm_cref()->nd_visi == (f)) #define SCOPE_SET(f) (vm_cref()->nd_visi = (f)) #define CHECK_STACK_OVERFLOW(cfp, margin) do \ if (((VALUE *)(cfp)->sp) + (margin) + sizeof(rb_control_frame_t) >= ((VALUE *)cfp)) { \ rb_exc_raise(sysstack_error); \ } \ while (0) void rb_thread_cleanup(void); void rb_thread_wait_other_threads(void); enum { RAISED_EXCEPTION = 1, RAISED_STACKOVERFLOW = 2, RAISED_NOMEMORY = 4 }; int rb_thread_set_raised(rb_thread_t *th); int rb_thread_reset_raised(rb_thread_t *th); #define rb_thread_raised_set(th, f) ((th)->raised_flag |= (f)) #define rb_thread_raised_reset(th, f) ((th)->raised_flag &= ~(f)) #define rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0) #define rb_thread_raised_clear(th) ((th)->raised_flag = 0) VALUE rb_f_eval(int argc, VALUE *argv, VALUE self); VALUE rb_make_exception(int argc, VALUE *argv); NORETURN(void rb_fiber_start(void)); NORETURN(void rb_print_undef(VALUE, ID, int)); NORETURN(void vm_localjump_error(const char *,VALUE, int)); NORETURN(void vm_jump_tag_but_local_jump(int, VALUE)); VALUE vm_make_jump_tag_but_local_jump(int state, VALUE val); NODE *vm_cref(void); rb_control_frame_t *vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp); VALUE rb_obj_is_proc(VALUE); VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename); void rb_thread_terminate_all(void); VALUE rb_vm_top_self(); VALUE rb_vm_cbase(void); #endif /* RUBY_EVAL_INTERN_H */ 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
/** BEGIN COPYRIGHT BLOCK
 * Copyright 2001 Sun Microsystems, Inc.
 * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "libaccess/ava.h"

#include "base/session.h"
#include "base/pblock.h"
#include "frame/req.h"
#include "frame/log.h"

#include "libadmin/libadmin.h"
#include "libaccess/avapfile.h"

#define ALLOC_SIZE 20
#define SUCCESS 0

struct parsedStruct {
  char     *fileName;
  AVATable *avaTable; 
};

typedef struct parsedStruct Parsed;

/* globals for yy_error if needed */
Session *yy_sn = NULL;
Request *yy_rq = NULL;

/*This will be a dynamic array of parsedStruct*. Re-sizing if necessary.*/
struct ParsedTable {
  Parsed **parsedTable;
  int numEntries;
};

char *currFile;

static struct ParsedTable parsedFiles = {NULL, 0};

extern AVATable entryTable; /*Table where entries are stored*/
extern AVAEntry tempEntry;  /*Used to restore parser's state*/
extern linenum;

AVAEntry * AVAEntry_Dup(AVAEntry *entry) {
  int i;
  AVAEntry *newAVA = NULL;
/* copy the AVA entry */

  if (entry) {
    newAVA = (AVAEntry *) PERM_MALLOC(sizeof(AVAEntry));
    memset(newAVA,0, sizeof(AVAEntry));
    newAVA->userid = 0;
    newAVA->CNEntry = 0;
    newAVA->email = 0;
    newAVA->locality = 0;
    newAVA->state = 0;
    newAVA->country = 0;
    newAVA->company = 0;
    newAVA->organizations  = 0;
    newAVA->numOrgs = 0;
    if (entry->userid) newAVA->userid = PERM_STRDUP(entry->userid);
    if (entry->CNEntry) newAVA->CNEntry = PERM_STRDUP(entry->CNEntry);
    if (entry->email) newAVA->email = PERM_STRDUP(entry->email);
    if (entry->locality) newAVA->locality = PERM_STRDUP(entry->locality);
    if (entry->state) newAVA->state = PERM_STRDUP(entry->state);