Hackfut Security File Manager
Current Path:
/opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/oj-3.7.12/ext/oj
opt
/
td-agent
/
embedded
/
lib
/
ruby
/
gems
/
2.4.0
/
gems
/
oj-3.7.12
/
ext
/
oj
/
📁
..
📄
.sitearchdir.-.oj.time
(0 B)
📄
Makefile
(9.43 KB)
📄
buf.h
(3.07 KB)
📄
cache8.c
(2.11 KB)
📄
cache8.h
(1.93 KB)
📄
circarray.c
(1.25 KB)
📄
circarray.h
(579 B)
📄
code.c
(5.2 KB)
📄
code.h
(974 B)
📄
compat.c
(8.35 KB)
📄
custom.c
(31.7 KB)
📄
dump.c
(29.51 KB)
📄
dump.h
(2.8 KB)
📄
dump_compat.c
(26.02 KB)
📄
dump_leaf.c
(5.47 KB)
📄
dump_object.c
(20.4 KB)
📄
dump_strict.c
(11.08 KB)
📄
encode.h
(1.78 KB)
📄
err.c
(1.24 KB)
📄
err.h
(2.53 KB)
📄
extconf.rb
(1.19 KB)
📄
fast.c
(42.43 KB)
📄
hash.c
(4.11 KB)
📄
hash.h
(1.9 KB)
📄
hash_test.c
(16.02 KB)
📄
mimic_json.c
(25.65 KB)
📄
object.c
(19.56 KB)
📄
odd.c
(5.37 KB)
📄
odd.h
(1.08 KB)
📄
oj.c
(69.29 KB)
📄
oj.h
(9.93 KB)
📄
oj.so
(1.08 MB)
📄
parse.c
(27.28 KB)
📄
parse.h
(3 KB)
📄
rails.c
(38.54 KB)
📄
rails.h
(392 B)
📄
reader.c
(6.06 KB)
📄
reader.h
(2.84 KB)
📄
resolve.c
(2.35 KB)
📄
resolve.h
(351 B)
📄
rxclass.c
(2.96 KB)
📄
rxclass.h
(653 B)
📄
saj.c
(17.11 KB)
📄
scp.c
(5.54 KB)
📄
sparse.c
(22.78 KB)
📄
stream_writer.c
(10.16 KB)
📄
strict.c
(5.4 KB)
📄
string_writer.c
(13.4 KB)
📄
trace.c
(2.08 KB)
📄
trace.h
(838 B)
📄
util.c
(3.37 KB)
📄
util.h
(313 B)
📄
val_stack.c
(3.63 KB)
📄
val_stack.h
(4.79 KB)
📄
wab.c
(15.25 KB)
Editing: rxclass.c
/* rxclass.c * Copyright (c) 2017, Peter Ohler * All rights reserved. */ #include <sys/types.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <stdio.h> #if !IS_WINDOWS #include <regex.h> #endif #include "rxclass.h" typedef struct _rxC { struct _rxC *next; VALUE rrx; #if !IS_WINDOWS regex_t rx; #endif VALUE clas; char src[256]; } *RxC; void oj_rxclass_init(RxClass rc) { *rc->err = '\0'; rc->head = NULL; rc->tail = NULL; } void oj_rxclass_cleanup(RxClass rc) { RxC rxc; while (NULL != (rxc = rc->head)) { rc->head = rc->head->next; #if !IS_WINDOWS if (Qnil == rxc->rrx) { regfree(&rxc->rx); } xfree(rxc); #endif } } void oj_rxclass_rappend(RxClass rc, VALUE rx, VALUE clas) { RxC rxc = ALLOC_N(struct _rxC, 1); memset(rxc, 0, sizeof(struct _rxC)); rxc->rrx = rx; rxc->clas = clas; if (NULL == rc->tail) { rc->head = rxc; } else { rc->tail->next = rxc; } rc->tail = rxc; } // Attempt to compile the expression. If it fails populate the error code.. int oj_rxclass_append(RxClass rc, const char *expr, VALUE clas) { RxC rxc; #if !IS_WINDOWS int err; int flags = 0; #endif if (sizeof(rxc->src) <= strlen(expr)) { snprintf(rc->err, sizeof(rc->err), "expressions must be less than %lu characters", (unsigned long)sizeof(rxc->src)); return EINVAL; } rxc = ALLOC_N(struct _rxC, 1); rxc->next = 0; rxc->clas = clas; #if IS_WINDOWS rxc->rrx = rb_funcall(rb_cRegexp, rb_intern("new"), 1, rb_str_new2(expr)); #else rxc->rrx = Qnil; if (0 != (err = regcomp(&rxc->rx, expr, flags))) { regerror(err, &rxc->rx, rc->err, sizeof(rc->err)); free(rxc); return err; } #endif if (NULL == rc->tail) { rc->head = rxc; } else { rc->tail->next = rxc; } rc->tail = rxc; return 0; } VALUE oj_rxclass_match(RxClass rc, const char *str, int len) { RxC rxc; char buf[4096]; for (rxc = rc->head; NULL != rxc; rxc = rxc->next) { if (Qnil != rxc->rrx) { // Must use a valiabel for this to work. volatile VALUE rstr = rb_str_new(str, len); //if (Qtrue == rb_funcall(rxc->rrx, rb_intern("match?"), 1, rstr)) { if (Qnil != rb_funcall(rxc->rrx, rb_intern("match"), 1, rstr)) { return rxc->clas; } } else if (len < (int)sizeof(buf)) { #if !IS_WINDOWS // string is not \0 terminated so copy and atempt a match memcpy(buf, str, len); buf[len] = '\0'; if (0 == regexec(&rxc->rx, buf, 0, NULL, 0)) { // match return rxc->clas; } #endif } else { // TBD allocate a larger buffer and attempt } } return Qnil; } void oj_rxclass_copy(RxClass src, RxClass dest) { dest->head = NULL; dest->tail = NULL; if (NULL != src->head) { RxC rxc; for (rxc = src->head; NULL != rxc; rxc = rxc->next) { if (Qnil != rxc->rrx) { oj_rxclass_rappend(dest, rxc->rrx, rxc->clas); } else { #if !IS_WINDOWS oj_rxclass_append(dest, rxc->src, rxc->clas); #endif } } } }
Upload File
Create Folder