bool AsciiProcessor::ins_polyline( const char * buf, int fref, BuilderBase * build, const char * & next ) { int id = 0, lay = 0, fil = 0; RGBcolor col( 0, 0, 0 ); if ( ! get_obj_attr( buf, id, lay, col, fil, next ) ) { return CMD_ERR; } int num = get_points( next, points, next ); if ( num < 2 ) { return CMD_ERR; } build->set_cmd_insert_polyline( fref, id, points.cur_size, points.tab, lay, col ); return CMD_OK; }
// Returns 0 if no match, 1 if a match static decision_t check_object(lnode *r, event_t *e) { unsigned int cnt = 0; while (cnt < r->o_count) { if (r->o[cnt].type != ALL_OBJ) { object_attr_t *obj = get_obj_attr(e, r->o[cnt].type); if (obj == NULL || obj->o == NULL) continue; // For directories (and unpackaged), we only do a // partial match. Any child dir would also match. if (r->o[cnt].type == ODIR) { int rc = obj_dir_test(&(r->o[cnt]), obj); if (rc == 0) return 0; } else if (r->o[cnt].type == PATH && strcasecmp(r->s[cnt].str, "unpackaged") == 0) { if (check_packaged_from_file(obj->o)) return 0; } else if (strcmp(obj->o, r->o[cnt].o)) return 0; } cnt++; } return 1; }
bool AsciiProcessor::ins_line( const char * buf, int fref, BuilderBase * build, const char * & next ) { int id = 0, lay = 0, fil = 0; RGBcolor col( 0, 0, 0 ); if ( ! get_obj_attr( buf, id, lay, col, fil, next ) ) { return CMD_ERR; } int num = get_lines( next, lines, next ); if ( num < 1 ) { return CMD_ERR; } if ( num == 1 ) { build->set_cmd_insert_line( fref, id, lines.tab[0], lay, col ); } else { build->set_cmd_insert_lines( fref, id, lines.cur_size, lines.tab, lay, col ); } return CMD_OK; }
static void log_it(unsigned int num, decision_t results, event_t *e) { subject_attr_t *subj, *subj2, *subj3; object_attr_t *obj; subj = get_subj_attr(e, EXE); subj2 = get_subj_attr(e, AUID); subj3 = get_subj_attr(e, PID); obj = get_obj_attr(e, PATH); msg(LOG_DEBUG, "rule:%u dec=%s auid=%d pid=%d exe=%s file=%s", num+1, dec_val_to_name(results), subj2->val, subj3->val, subj->str, obj->o); }
bool AsciiProcessor::ins_string_grid( const char * buf, int fref, BuilderBase * build, const char * & next ) { int id = 0, lay = 0, fil = 0; RGBcolor col( 0, 0, 0 ); if ( ! get_obj_attr( buf, id, lay, col, fil, next ) ) { return CMD_ERR; } while ( true ) { double p_x, p_y, v1_x, v1_y, v2_x, v2_y, d3, d4, d5; int num_v1 = 1, num_v2 = 1; if ( ! strskip( next, '(', next ) ) { return CMD_ERR; } if ( get_max5_tuple( next, 2, p_x, p_y, d3, d4, d5, next ) != 2 ) { return CMD_ERR; } if ( get_max5_tuple( next, 2, v1_x, v1_y, d3, d4, d5, next ) != 2 ) { return CMD_ERR; } if ( strskip( next, ':', next ) ) { if ( ! str2val( next, num_v1, next ) ) { return CMD_ERR; } } if ( get_max5_tuple( next, 2, v2_x, v2_y, d3, d4, d5, next ) != 2 ) { return CMD_ERR; } if ( strskip( next, ':', next ) ) { if ( ! str2val( next, num_v2, next ) ) { return CMD_ERR; } } const double d1 = 1.0 / double( num_v1 ); const double d2 = 1.0 / double( num_v2 ); bool early_stop = false; for ( int i = 0; i < num_v2; ++i ) { Point2d point; point.x = p_x + i * v2_x * d2 ; point.y = p_y + i * v2_y * d2 ; for ( int j = 0; j < num_v1; j++ ) { int offset; if ( strskip( next, ')', next ) ) { early_stop = true; break; } buf = next; int res = get_string( buf, offset, next ); if ( res < 0 ) { return CMD_ERR; } VisualObject2d * string2d = new VisualString2d( id, lay, col, point, res, buf + offset ); build->set_cmd_insert_visobject( fref, string2d ); point.x += v1_x * d1; point.y += v1_y * d1; } if ( early_stop ) { break; } } if ( ! early_stop ) { if ( ! strskip( next, ')', next ) ) { return CMD_ERR; } } if ( strskip( next, DELIMITER_CHAR, next ) ) { break; } } return CMD_OK; }
bool AsciiProcessor::ins_grid( const char * buf, int fref, BuilderBase * build, const char * & next ) { int id = 0, lay = 0, fil = 0; RGBcolor col( 0, 0, 0 ); if ( ! get_obj_attr( buf, id, lay, col, fil, next ) ) { return CMD_ERR; } int idx = 0; while ( true ) //accept more then one grid! { double p_x, p_y, v1_x, v1_y, v2_x, v2_y, d3, d4, d5; int num_v1 = 1, num_v2 = 1; if ( ! strskip( next, '(', next ) ) { return CMD_ERR; } if ( get_max5_tuple( next, 2, p_x, p_y, d3, d4, d5, next ) != 2 ) { return CMD_ERR; } if ( get_max5_tuple( next, 2, v1_x, v1_y, d3, d4, d5, next ) != 2 ) { return CMD_ERR; } if ( strskip( next, ':', next ) ) { if ( ! str2val( next, num_v1, next ) ) { return CMD_ERR; } } if ( get_max5_tuple( next, 2, v2_x, v2_y, d3, d4, d5, next ) != 2 ) { return CMD_ERR; } if ( strskip( next, ':', next ) ) { if ( ! str2val( next, num_v2, next ) ) { return CMD_ERR; } } if ( ! strskip( next, ')', next ) ) { return CMD_ERR; } lines.set_cur_size( idx ); lines.set_max_size_and_preserve_cur_size( idx + num_v1 + num_v2 + 2 ); const double d1 = 1.0 / double( num_v1 ); const double d2 = 1.0 / double( num_v2 ); for ( int i = 0; i < num_v2 + 1; ++i ) { Line2d & l = lines.tab[idx]; l.p1.x = p_x + i * v2_x * d2 ; l.p1.y = p_y + i * v2_y * d2 ; l.p2.x = l.p1.x + v1_x; l.p2.y = l.p1.y + v1_y; idx++; } for ( int i = 0; i < num_v1 + 1; ++i ) { Line2d & l = lines.tab[idx]; l.p1.x = p_x + i * v1_x * d1 ; l.p1.y = p_y + i * v1_y * d1 ; l.p2.x = l.p1.x + v2_x; l.p2.y = l.p1.y + v2_y; idx++; } if ( strskip( next, DELIMITER_CHAR, next ) ) { break; } } build->set_cmd_insert_lines( fref, id, idx, lines.tab, lay, col ); return CMD_OK; }
bool AsciiProcessor::ins_string( const char * buf, int fref, BuilderBase * build, const char * & next ) { int id = 0, lay = 0, fil = 0; RGBcolor col( 0, 0, 0 ); Point2d point; if ( ! get_obj_attr( buf, id, lay, col, fil, next ) ) { return CMD_ERR; } while ( true ) //accept more then one string! { if ( ! strskip( next, '(', next ) ) { return CMD_ERR; } if ( ! str2val( next, point.x, next ) ) { return CMD_ERR; } if ( ! strskip( next, ',', next ) ) { return CMD_ERR; } if ( ! str2val( next, point.y, next ) ) { return CMD_ERR; } if ( ! strskip( next, ',', next ) ) { return CMD_ERR; } buf = next; int offset; int res = get_string( buf, offset, next ); if ( res < 0 ) { return CMD_ERR; } if ( ! strskip( next, ')', next ) ) { return CMD_ERR; } VisualObject2d * string2d = new VisualString2d( id, lay, col, point, res, buf + offset ); build->set_cmd_insert_visobject( fref, string2d ); if ( strskip( next, DELIMITER_CHAR, next ) ) { break; } } return CMD_OK; }