void Init_FigureMaker(void) { /* called by Ruby when the extension is loaded */ /* this function has been modified by Vincent Fourmond for the splitting out of libraries more general than Tioga */ /* Init_Flate(); Init_Dvector(); Init_Dtable(); */ /* These functions don't belong here anymore, as they will be called by their respective modules. Instead, we require them */ rb_require("Dobjects/Dvector"); rb_require("Dobjects/Dtable"); rb_require("Flate"); OBJ_PTR mTioga = rb_define_module("Tioga"); /* and now, we need to import Dobjects and Flate modules*/ OBJ_PTR mDobjects = rb_define_module("Dobjects"); OBJ_PTR mFlate = rb_define_module("Flate"); rb_include_module(mTioga, mDobjects); rb_include_module(mTioga, mFlate); cFM = rb_define_class_under(mTioga, "FigureMaker", rb_cObject); /* This is necessary to get the tex preamble for the previews*/ rb_require("Tioga/TexPreamble.rb"); /* Inclusion of the external objects to get them easily */ rb_include_module(cFM, mDobjects); rb_include_module(cFM, mFlate); Init_IDs(); Init_Font_Dictionary(); rb_define_method(cFM, "private_make", FM_private_make, 2); rb_define_method(cFM, "get_save_filename", FM_get_save_filename, 1); rb_define_method(cFM, "private_make_portfolio", FM_private_make_portfolio, 3); rb_define_method(cFM, "private_init_fm_data", FM_private_init_fm_data, 1); /* page attribute accessors */ attr_reader(root_figure) attr_reader(in_subplot) attr_reader(scaling_factor) attr_reader(page_left) attr_reader(page_right) attr_reader(page_bottom) attr_reader(page_top) attr_reader(page_width) attr_reader(page_height) /* frame attribute accessors */ attr_reader(frame_left) attr_reader(frame_right) attr_reader(frame_bottom) attr_reader(frame_top) attr_reader(frame_width) attr_reader(frame_height) /* bounds attribute accessors */ attr_reader(bounds_left) attr_reader(bounds_right) attr_reader(bounds_bottom) attr_reader(bounds_top) attr_reader(bounds_width) attr_reader(bounds_height) attr_reader(bounds_xmin) attr_reader(bounds_xmax) attr_reader(bounds_ymin) attr_reader(bounds_ymax) attr_reader(xaxis_reversed) attr_reader(yaxis_reversed) /* text attribute accessors */ attr_reader(default_font_size) attr_reader(default_text_scale) attr_accessors(justification) attr_accessors(alignment) attr_reader(default_text_height_dx) attr_reader(default_text_height_dy) attr_accessors(label_left_margin) attr_accessors(label_right_margin) attr_accessors(label_top_margin) attr_accessors(label_bottom_margin) attr_accessors(text_shift_on_left) attr_accessors(text_shift_on_right) attr_accessors(text_shift_on_top) attr_accessors(text_shift_on_bottom) attr_accessors(text_shift_from_x_origin) attr_accessors(text_shift_from_y_origin) /* graphics attribute accessors */ attr_reader(default_line_scale) attr_accessors(stroke_color) attr_accessors(fill_color) attr_accessors(line_width) attr_accessors(line_cap) attr_accessors(line_join) rb_define_method(cFM, "line_type_set", FM_line_type_set, 1); attr_accessors(miter_limit) attr_accessors(stroke_opacity) attr_accessors(fill_opacity) /* croak on non ok */ attr_accessors(croak_on_nonok_numbers) /* methods */ rb_define_method(cFM, "pdf_gsave", FM_pdf_gsave, 0); rb_define_method(cFM, "pdf_grestore", FM_pdf_grestore, 0); rb_define_method(cFM, "private_set_bounds", FM_private_set_bounds, 4); rb_define_method(cFM, "private_set_subframe", FM_private_set_subframe, 4); rb_define_method(cFM, "doing_subfigure", FM_doing_subfigure, 0); /* colors */ rb_define_method(cFM, "hls_to_rgb", FM_hls_to_rgb, 1); rb_define_method(cFM, "rgb_to_hls", FM_rgb_to_hls, 1); rb_define_method(cFM, "string_hls_to_rgb!", FM_string_hls_to_rgb_bang, 1); rb_define_method(cFM, "string_rgb_to_hls!", FM_string_rgb_to_hls_bang, 1); /* We define them as class methods too, as they do not depend on a FigureMaker instance*/ rb_define_singleton_method(cFM, "hls_to_rgb", FM_hls_to_rgb, 1); rb_define_singleton_method(cFM, "rgb_to_hls", FM_rgb_to_hls, 1); rb_define_singleton_method(cFM, "string_hls_to_rgb!", FM_string_hls_to_rgb_bang, 1); rb_define_singleton_method(cFM, "string_rgb_to_hls!", FM_string_rgb_to_hls_bang, 1); /* coordinate system conversions */ rb_define_method(cFM, "convert_inches_to_output", FM_convert_inches_to_output, 1); rb_define_method(cFM, "convert_output_to_inches", FM_convert_output_to_inches, 1); rb_define_method(cFM, "convert_mm_to_output", FM_convert_mm_to_output, 1); rb_define_method(cFM, "convert_output_to_mm", FM_convert_output_to_mm, 1); rb_define_method(cFM, "convert_page_to_output_x", FM_convert_page_to_output_x, 1); rb_define_method(cFM, "convert_page_to_output_y", FM_convert_page_to_output_y, 1); rb_define_method(cFM, "convert_page_to_output_dx", FM_convert_page_to_output_dx, 1); rb_define_method(cFM, "convert_page_to_output_dy", FM_convert_page_to_output_dy, 1); rb_define_method(cFM, "convert_output_to_page_x", FM_convert_output_to_page_x, 1); rb_define_method(cFM, "convert_output_to_page_y", FM_convert_output_to_page_y, 1); rb_define_method(cFM, "convert_output_to_page_dx", FM_convert_output_to_page_dx, 1); rb_define_method(cFM, "convert_output_to_page_dy", FM_convert_output_to_page_dy, 1); rb_define_method(cFM, "convert_page_to_frame_x", FM_convert_page_to_frame_x, 1); rb_define_method(cFM, "convert_page_to_frame_y", FM_convert_page_to_frame_y, 1); rb_define_method(cFM, "convert_page_to_frame_dx", FM_convert_page_to_frame_dx, 1); rb_define_method(cFM, "convert_page_to_frame_dy", FM_convert_page_to_frame_dy, 1); rb_define_method(cFM, "convert_frame_to_page_x", FM_convert_frame_to_page_x, 1); rb_define_method(cFM, "convert_frame_to_page_y", FM_convert_frame_to_page_y, 1); rb_define_method(cFM, "convert_frame_to_page_dx", FM_convert_frame_to_page_dx, 1); rb_define_method(cFM, "convert_frame_to_page_dy", FM_convert_frame_to_page_dy, 1); rb_define_method(cFM, "convert_figure_to_frame_x", FM_convert_figure_to_frame_x, 1); rb_define_method(cFM, "convert_figure_to_frame_y", FM_convert_figure_to_frame_y, 1); rb_define_method(cFM, "convert_figure_to_frame_dx", FM_convert_figure_to_frame_dx, 1); rb_define_method(cFM, "convert_figure_to_frame_dy", FM_convert_figure_to_frame_dy, 1); rb_define_method(cFM, "convert_frame_to_figure_x", FM_convert_frame_to_figure_x, 1); rb_define_method(cFM, "convert_frame_to_figure_y", FM_convert_frame_to_figure_y, 1); rb_define_method(cFM, "convert_frame_to_figure_dx", FM_convert_frame_to_figure_dx, 1); rb_define_method(cFM, "convert_frame_to_figure_dy", FM_convert_frame_to_figure_dy, 1); rb_define_method(cFM, "convert_figure_to_output_x", FM_convert_figure_to_output_x, 1); rb_define_method(cFM, "convert_figure_to_output_y", FM_convert_figure_to_output_y, 1); rb_define_method(cFM, "convert_figure_to_output_dx", FM_convert_figure_to_output_dx, 1); rb_define_method(cFM, "convert_figure_to_output_dy", FM_convert_figure_to_output_dy, 1); rb_define_method(cFM, "convert_output_to_figure_x", FM_convert_output_to_figure_x, 1); rb_define_method(cFM, "convert_output_to_figure_y", FM_convert_output_to_figure_y, 1); rb_define_method(cFM, "convert_output_to_figure_dx", FM_convert_output_to_figure_dx, 1); rb_define_method(cFM, "convert_output_to_figure_dy", FM_convert_output_to_figure_dy, 1); rb_define_method(cFM, "convert_to_degrees", FM_convert_to_degrees, 2); /* text */ rb_define_method(cFM, "private_set_default_font_size", FM_private_set_default_font_size, 1); rb_define_method(cFM, "rescale_text", FM_rescale_text, 1); rb_define_method(cFM, "show_rotated_text", FM_show_rotated_text, 9); rb_define_method(cFM, "show_rotated_label", FM_show_rotated_label, 8); rb_define_method(cFM, "check_label_clip", FM_check_label_clip, 2); /* text measurements */ rb_define_method(cFM, "private_save_measure", FM_private_save_measure, 4); /* path construction */ rb_define_method(cFM, "move_to_point", FM_move_to_point, 2); rb_define_method(cFM, "append_point_to_path", FM_append_point_to_path, 2); rb_define_method(cFM, "bezier_control_points", FM_bezier_control_points, 6); rb_define_method(cFM, "append_curve_to_path", FM_append_curve_to_path, 6); rb_define_method(cFM, "close_path", FM_close_path, 0); rb_define_method(cFM, "append_points_to_path", FM_append_points_to_path, 2); rb_define_method(cFM, "private_append_points_with_gaps_to_path", FM_private_append_points_with_gaps_to_path, 4); rb_define_method(cFM, "append_arc_to_path", FM_append_arc_to_path, 8); rb_define_method(cFM, "append_rect_to_path", FM_append_rect_to_path, 4); rb_define_method(cFM, "append_rounded_rect_to_path", FM_append_rounded_rect_to_path, 6); rb_define_method(cFM, "append_circle_to_path", FM_append_circle_to_path, 3); rb_define_method(cFM, "append_oval_to_path", FM_append_oval_to_path, 5); rb_define_method(cFM, "append_frame_to_path", FM_append_frame_to_path, 0); rb_define_method(cFM, "update_bbox", FM_update_bbox, 2); rb_define_method(cFM, "bbox_left", FM_bbox_left, 0); rb_define_method(cFM, "bbox_right", FM_bbox_right, 0); rb_define_method(cFM, "bbox_top", FM_bbox_top, 0); rb_define_method(cFM, "bbox_bottom", FM_bbox_bottom, 0); /* path painting */ rb_define_method(cFM, "rescale_lines", FM_rescale_lines, 1); rb_define_method(cFM, "discard_path", FM_discard_path, 0); rb_define_method(cFM, "stroke", FM_stroke, 0); rb_define_method(cFM, "close_and_stroke", FM_close_and_stroke, 0); rb_define_method(cFM, "fill", FM_fill, 0); rb_define_method(cFM, "eofill", FM_eofill, 0); rb_define_method(cFM, "fill_and_stroke", FM_fill_and_stroke, 0); rb_define_method(cFM, "eofill_and_stroke", FM_eofill_and_stroke, 0); rb_define_method(cFM, "close_fill_and_stroke", FM_close_fill_and_stroke, 0); rb_define_method(cFM, "close_eofill_and_stroke", FM_close_eofill_and_stroke, 0); rb_define_method(cFM, "clip", FM_clip, 0); rb_define_method(cFM, "eoclip", FM_eoclip, 0); rb_define_method(cFM, "stroke_line", FM_stroke_line, 4); rb_define_method(cFM, "fill_rect", FM_fill_rect, 4); rb_define_method(cFM, "stroke_rect", FM_stroke_rect, 4); rb_define_method(cFM, "fill_and_stroke_rect", FM_fill_and_stroke_rect, 4); rb_define_method(cFM, "clip_rect", FM_clip_rect, 4); rb_define_method(cFM, "stroke_frame", FM_stroke_frame, 0); rb_define_method(cFM, "fill_frame", FM_fill_frame, 0); rb_define_method(cFM, "fill_and_stroke_frame", FM_fill_and_stroke_frame, 0); rb_define_method(cFM, "clip_circle", FM_clip_circle, 3); rb_define_method(cFM, "clip_to_frame", FM_clip_to_frame, 0); rb_define_method(cFM, "fill_circle", FM_fill_circle, 3); rb_define_method(cFM, "stroke_circle", FM_stroke_circle, 3); rb_define_method(cFM, "fill_and_stroke_circle", FM_fill_and_stroke_circle, 3); rb_define_method(cFM, "clip_oval", FM_clip_oval, 5); rb_define_method(cFM, "fill_oval", FM_fill_oval, 5); rb_define_method(cFM, "stroke_oval", FM_stroke_oval, 5); rb_define_method(cFM, "fill_and_stroke_oval", FM_fill_and_stroke_oval, 5); rb_define_method(cFM, "rounded_rect_oval", FM_clip_rounded_rect, 6); rb_define_method(cFM, "fill_rounded_rect", FM_fill_rounded_rect, 6); rb_define_method(cFM, "stroke_rounded_rect", FM_stroke_rounded_rect, 6); rb_define_method(cFM, "fill_and_stroke_rounded_rect", FM_fill_and_stroke_rounded_rect, 6); /* shading */ rb_define_method(cFM, "private_axial_shading", FM_private_axial_shading, 7); rb_define_method(cFM, "private_radial_shading", FM_private_radial_shading, 13); /* markers */ rb_define_method(cFM, "register_font", FM_register_font, 1); rb_define_method(cFM, "private_show_marker", FM_private_show_marker, 1); rb_define_method(cFM, "marker_string_info", FM_marker_string_info, 3); /* images */ rb_define_method(cFM, "private_register_jpg", FM_private_register_jpg, 4); rb_define_method(cFM, "jpg_info", FM_jpg_info, 1); rb_define_method(cFM, "private_register_rgb_image", FM_private_register_rgb_image, 7); rb_define_method(cFM, "private_register_hls_image", FM_private_register_hls_image, 7); rb_define_method(cFM, "private_register_cmyk_image", FM_private_register_cmyk_image, 7); rb_define_method(cFM, "private_register_grayscale_image", FM_private_register_grayscale_image, 7); rb_define_method(cFM, "private_register_monochrome_image", FM_private_register_monochrome_image, 7); rb_define_method(cFM, "private_register_image", FM_private_register_image, 11); rb_define_method(cFM, "private_show_image_from_ref", FM_private_show_image_from_ref, 7); rb_define_method(cFM, "private_create_image_data", FM_private_create_image_data, 10); rb_define_method(cFM, "private_create_monochrome_image_data", FM_private_create_monochrome_image_data, 7); /* colormaps */ rb_define_method(cFM, "private_create_colormap", FM_private_create_colormap, 6); rb_define_method(cFM, "convert_to_colormap", FM_convert_to_colormap, 3); rb_define_method(cFM, "get_color_from_colormap", FM_get_color_from_colormap, 2); /* plots */ rb_define_method(cFM, "set_frame_sides", FM_set_frame_sides, 4); rb_define_method(cFM, "set_device_pagesize", FM_set_device_pagesize, 2); rb_define_method(cFM, "doing_subplot", FM_doing_subplot, 0); rb_define_method(cFM, "show_axis", FM_show_axis, 1); rb_define_method(cFM, "show_edge", FM_show_edge, 1); rb_define_method(cFM, "axis_information", FM_axis_information, 1); rb_define_method(cFM, "no_title", FM_no_title, 0); rb_define_method(cFM, "no_xlabel", FM_no_xlabel, 0); rb_define_method(cFM, "no_ylabel", FM_no_ylabel, 0); rb_define_method(cFM, "no_xaxis", FM_no_xaxis, 0); rb_define_method(cFM, "no_yaxis", FM_no_yaxis, 0); rb_define_method(cFM, "no_left_edge", FM_no_left_edge, 0); rb_define_method(cFM, "no_right_edge", FM_no_right_edge, 0); rb_define_method(cFM, "no_top_edge", FM_no_top_edge, 0); rb_define_method(cFM, "no_bottom_edge", FM_no_bottom_edge, 0); /* makers */ rb_define_singleton_method(cFM, "private_make_contour", FM_private_make_contour, 7); rb_define_method(cFM, "private_make_spline_interpolated_points", FM_private_make_spline_interpolated_points, 5); rb_define_method(cFM, "private_make_steps", FM_private_make_steps, 6); /* Title */ attr_reader(title_visible) attr_accessors(title_side) attr_accessors(title_position) attr_accessors(title_scale) attr_accessors(title_shift) attr_accessors(title_angle) attr_accessors(title_alignment) attr_accessors(title_justification) attr_accessors(title_color) /* X label */ attr_reader(xlabel_visible) attr_accessors(xlabel_position) attr_accessors(xlabel_scale) attr_accessors(xlabel_shift) attr_accessors(xlabel_angle) attr_accessors(xlabel_side) attr_accessors(xlabel_alignment) attr_accessors(xlabel_justification) attr_accessors(xlabel_color) /* Y label */ attr_reader(ylabel_visible) attr_accessors(ylabel_position) attr_accessors(ylabel_scale) attr_accessors(ylabel_shift) attr_accessors(ylabel_angle) attr_accessors(ylabel_side) attr_accessors(ylabel_alignment) attr_accessors(ylabel_justification) attr_accessors(ylabel_color) /* X axis */ attr_reader(xaxis_visible) attr_accessors(xaxis_loc) attr_accessors(xaxis_type) attr_accessors(xaxis_line_width) attr_accessors(xaxis_stroke_color) attr_accessors(xaxis_labels_color) attr_accessors(xaxis_major_tick_width) attr_accessors(xaxis_minor_tick_width) attr_accessors(xaxis_major_tick_length) attr_accessors(xaxis_minor_tick_length) attr_accessors(xaxis_log_values) attr_accessors(xaxis_ticks_inside) attr_accessors(xaxis_ticks_outside) attr_accessors(xaxis_tick_interval) attr_accessors(xaxis_min_between_major_ticks) attr_accessors(xaxis_number_of_minor_intervals) attr_accessors(xaxis_use_fixed_pt) attr_accessors(xaxis_digits_max) attr_accessors(xaxis_numeric_label_decimal_digits) attr_accessors(xaxis_numeric_label_scale) attr_accessors(xaxis_numeric_label_shift) attr_accessors(xaxis_numeric_label_angle) attr_accessors(xaxis_numeric_label_alignment) attr_accessors(xaxis_numeric_label_justification) attr_accessors(xaxis_numeric_label_frequency) attr_accessors(xaxis_numeric_label_phase) attr_accessors(top_edge_type) attr_reader(top_edge_visible) attr_accessors(bottom_edge_type) attr_reader(bottom_edge_visible) /* Y axis */ attr_reader(yaxis_visible) attr_accessors(yaxis_loc) attr_accessors(yaxis_type) attr_accessors(yaxis_line_width) attr_accessors(yaxis_stroke_color) attr_accessors(yaxis_labels_color) attr_accessors(yaxis_major_tick_width) attr_accessors(yaxis_minor_tick_width) attr_accessors(yaxis_major_tick_length) attr_accessors(yaxis_minor_tick_length) attr_accessors(yaxis_log_values) attr_accessors(yaxis_ticks_inside) attr_accessors(yaxis_ticks_outside) attr_accessors(yaxis_tick_interval) attr_accessors(yaxis_min_between_major_ticks) attr_accessors(yaxis_number_of_minor_intervals) attr_accessors(yaxis_use_fixed_pt) attr_accessors(yaxis_digits_max) attr_accessors(yaxis_numeric_label_decimal_digits) attr_accessors(yaxis_numeric_label_scale) attr_accessors(yaxis_numeric_label_shift) attr_accessors(yaxis_numeric_label_angle) attr_accessors(yaxis_numeric_label_alignment) attr_accessors(yaxis_numeric_label_justification) attr_accessors(yaxis_numeric_label_frequency) attr_accessors(yaxis_numeric_label_phase) attr_accessors(left_edge_type) attr_reader(left_edge_visible) attr_accessors(right_edge_type) attr_reader(right_edge_visible) /* Major ticks algorithm */ attr_accessors(vincent_or_bill) attr_accessors(log_minor_ticks_limit) /* Legend */ attr_accessors(legend_text_width) attr_accessors(legend_line_x0) attr_accessors(legend_line_x1) attr_accessors(legend_line_dy) attr_accessors(legend_text_xstart) attr_accessors(legend_text_ystart) attr_accessors(legend_text_dy) attr_accessors(legend_line_width) attr_accessors(legend_scale) attr_accessors(legend_alignment) attr_accessors(legend_justification) /* Debugging */ attr_accessors(debug_verbosity_level) Set_fm_data_size(); // must set this before create a FigureMaker instance rb_require("Tioga/FigMkr.rb"); /* We now need to import the symbols */ /* imports from Dvector */ OBJ_PTR cDvector = rb_define_class_under(mDobjects, "Dvector", rb_cObject); RB_IMPORT_SYMBOL(cDvector, Dvector_Create); RB_IMPORT_SYMBOL(cDvector, Dvector_Data_Resize); RB_IMPORT_SYMBOL(cDvector, Dvector_Data_Replace); RB_IMPORT_SYMBOL(cDvector, isa_Dvector); RB_IMPORT_SYMBOL(cDvector, len_Dvector); RB_IMPORT_SYMBOL(cDvector, access_Dvector); RB_IMPORT_SYMBOL(cDvector, Dvector_Data_for_Read); RB_IMPORT_SYMBOL(cDvector, Dvector_Data_for_Write); RB_IMPORT_SYMBOL(cDvector, Dvector_Store_Double); RB_IMPORT_SYMBOL(cDvector, c_dvector_spline_interpolate); RB_IMPORT_SYMBOL(cDvector, c_dvector_linear_interpolate); RB_IMPORT_SYMBOL(cDvector, c_dvector_create_spline_interpolant); /* imports from Flate */ RB_IMPORT_SYMBOL(mFlate, flate_compress); RB_IMPORT_SYMBOL(mFlate, flate_expand); /* imports from Dtable */ OBJ_PTR cDtable = rb_define_class_under(mDobjects, "Dtable", rb_cObject); RB_IMPORT_SYMBOL(cDtable, Dtable_Ptr); RB_IMPORT_SYMBOL(cDtable, Read_Dtable); }
void Init_etcutils_group() { /* Define-const: Group * * The struct contains the following members: * * name:: * contains the name of the group as a String. * passwd:: * contains the encrypted password as a String. An 'x' is * returned if password access to the group is not available; an empty * string is returned if no password is needed to obtain membership of * the group. * gid:: * contains the group's numeric ID as an integer. * mem:: * is an Array of Strings containing the short login names of the * members of the group. */ #ifdef GROUP rb_define_attr(rb_cGroup, "name", 1, 1); rb_define_attr(rb_cGroup, "passwd", 1, 1); rb_define_attr(rb_cGroup, "gid", 1, 1); rb_define_attr(rb_cGroup, "members", 1, 1); rb_define_singleton_method(rb_cGroup,"get",eu_getgrent,0); rb_define_singleton_method(rb_cGroup,"find",eu_getgrp,1); rb_define_singleton_method(rb_cGroup,"parse",eu_sgetgrent,1); rb_define_singleton_method(rb_cGroup,"set",eu_setgrent,0); rb_define_singleton_method(rb_cGroup,"end",eu_endgrent,0); rb_define_singleton_method(rb_cGroup,"each",eu_getgrent,0); rb_define_method(rb_cGroup, "fputs", group_putgrent,1); rb_define_method(rb_cGroup, "to_entry", group_gr_entry,0); #endif #ifdef GSHADOW rb_define_attr(rb_cGshadow, "name", 1, 1); rb_define_attr(rb_cGshadow, "passwd", 1, 1); rb_define_attr(rb_cGshadow, "admins", 1, 1); rb_define_attr(rb_cGshadow, "members", 1, 1); rb_define_singleton_method(rb_cGshadow,"get",eu_getsgent,0); rb_define_singleton_method(rb_cGshadow,"find",eu_getsgrp,1); //getsgent, getsguid rb_define_singleton_method(rb_cGshadow,"parse",eu_sgetsgent,1); rb_define_singleton_method(rb_cGshadow,"set",eu_setsgent,0); rb_define_singleton_method(rb_cGshadow,"end",eu_endsgent,0); rb_define_singleton_method(rb_cGshadow,"each",eu_getsgent,0); rb_define_method(rb_cGshadow, "fputs", group_putsgent, 1); rb_define_method(rb_cGshadow, "to_entry", group_sg_entry,0); #endif }
static VALUE memprof_dump(int argc, VALUE *argv, VALUE self) { VALUE str; FILE *out = NULL; if (!track_objs) rb_raise(rb_eRuntimeError, "object tracking disabled, call Memprof.start first"); rb_scan_args(argc, argv, "01", &str); if (RTEST(str)) { out = fopen(StringValueCStr(str), "w"); if (!out) rb_raise(rb_eArgError, "unable to open output file"); } yajl_gen_config conf = { .beautify = 1, .indentString = " " }; yajl_gen gen = yajl_gen_alloc2((yajl_print_t)&json_print, &conf, NULL, (void*)out); track_objs = 0; yajl_gen_array_open(gen); st_foreach(objs, objs_each_dump, (st_data_t)gen); yajl_gen_array_close(gen); yajl_gen_free(gen); if (out) fclose(out); track_objs = 1; return Qnil; } static VALUE memprof_dump_all(int argc, VALUE *argv, VALUE self) { char *heaps = *(char**)bin_find_symbol("heaps",0); int heaps_used = *(int*)bin_find_symbol("heaps_used",0); #ifndef sizeof__RVALUE size_t sizeof__RVALUE = bin_type_size("RVALUE"); #endif #ifndef sizeof__heaps_slot size_t sizeof__heaps_slot = bin_type_size("heaps_slot"); #endif #ifndef offset__heaps_slot__limit int offset__heaps_slot__limit = bin_type_member_offset("heaps_slot", "limit"); #endif #ifndef offset__heaps_slot__slot int offset__heaps_slot__slot = bin_type_member_offset("heaps_slot", "slot"); #endif char *p, *pend; int i, limit; if (sizeof__RVALUE == 0 || sizeof__heaps_slot == 0) rb_raise(eUnsupported, "could not find internal heap"); VALUE str; FILE *out = NULL; rb_scan_args(argc, argv, "01", &str); if (RTEST(str)) { out = fopen(StringValueCStr(str), "w"); if (!out) rb_raise(rb_eArgError, "unable to open output file"); } yajl_gen_config conf = { .beautify = 0, .indentString = " " }; yajl_gen gen = yajl_gen_alloc2((yajl_print_t)&json_print, &conf, NULL, (void*)out); track_objs = 0; //yajl_gen_array_open(gen); for (i=0; i < heaps_used; i++) { p = *(char**)(heaps + (i * sizeof__heaps_slot) + offset__heaps_slot__slot); limit = *(int*)(heaps + (i * sizeof__heaps_slot) + offset__heaps_slot__limit); pend = p + (sizeof__RVALUE * limit); while (p < pend) { if (RBASIC(p)->flags) { obj_dump((VALUE)p, gen); // XXX ugh yajl_gen_clear(gen); yajl_gen_free(gen); gen = yajl_gen_alloc2((yajl_print_t)&json_print, &conf, NULL, (void*)out); while(fputc('\n', out ? out : stdout) == EOF); } p += sizeof__RVALUE; } } //yajl_gen_array_close(gen); yajl_gen_clear(gen); yajl_gen_free(gen); if (out) fclose(out); track_objs = 1; return Qnil; } void Init_memprof() { VALUE memprof = rb_define_module("Memprof"); eUnsupported = rb_define_class_under(memprof, "Unsupported", rb_eStandardError); rb_define_singleton_method(memprof, "start", memprof_start, 0); rb_define_singleton_method(memprof, "stop", memprof_stop, 0); rb_define_singleton_method(memprof, "stats", memprof_stats, -1); rb_define_singleton_method(memprof, "stats!", memprof_stats_bang, -1); rb_define_singleton_method(memprof, "track", memprof_track, -1); rb_define_singleton_method(memprof, "dump", memprof_dump, -1); rb_define_singleton_method(memprof, "dump_all", memprof_dump_all, -1); pagesize = getpagesize(); objs = st_init_numtable(); bin_init(); create_tramp_table(); gc_hook = Data_Wrap_Struct(rb_cObject, sourcefile_marker, NULL, NULL); rb_global_variable(&gc_hook); ptr_to_rb_mark_table_add_filename = bin_find_symbol("rb_mark_table_add_filename", NULL); rb_classname = bin_find_symbol("classname", 0); rb_add_freelist = bin_find_symbol("add_freelist", 0); insert_tramp("rb_newobj", newobj_tramp); insert_tramp("add_freelist", freelist_tramp); if (getenv("MEMPROF")) track_objs = 1; return; }
void Init_Collection (VALUE mXmms) { #if RDOC_CAN_PARSE_DOCUMENTATION mXmms= rb_define_module("Xmms"); #endif cColl = rb_define_class_under (mXmms, "Collection", rb_cObject); rb_define_alloc_func (cColl, c_alloc); rb_define_singleton_method (cColl, "universe", c_coll_universe, 0); rb_define_singleton_method (cColl, "parse", c_coll_parse, 1); rb_define_method (cColl, "initialize", c_coll_init, 1); /* type methods */ rb_define_method (cColl, "type", c_coll_type_get, 0); /* idlist methods */ rb_define_method (cColl, "idlist", c_coll_idlist_get, 0); rb_define_method (cColl, "idlist=", c_coll_idlist_set, 1); /* operand methods */ rb_define_method (cColl, "operands", c_coll_operands, 0); /* attribute methods */ rb_define_method (cColl, "attributes", c_coll_attributes, 0); rb_define_const (cColl, "NS_ALL", rb_str_new2 (XMMS_COLLECTION_NS_ALL)); rb_define_const (cColl, "NS_COLLECTIONS", rb_str_new2 (XMMS_COLLECTION_NS_COLLECTIONS)); rb_define_const (cColl, "NS_PLAYLISTS", rb_str_new2 (XMMS_COLLECTION_NS_PLAYLISTS)); rb_define_const (cColl, "TYPE_REFERENCE", INT2FIX (XMMS_COLLECTION_TYPE_REFERENCE)); rb_define_const (cColl, "TYPE_UNIVERSE", INT2FIX (XMMS_COLLECTION_TYPE_UNIVERSE)); rb_define_const (cColl, "TYPE_UNION", INT2FIX (XMMS_COLLECTION_TYPE_UNION)); rb_define_const (cColl, "TYPE_INTERSECTION", INT2FIX (XMMS_COLLECTION_TYPE_INTERSECTION)); rb_define_const (cColl, "TYPE_COMPLEMENT", INT2FIX (XMMS_COLLECTION_TYPE_COMPLEMENT)); rb_define_const (cColl, "TYPE_HAS", INT2FIX (XMMS_COLLECTION_TYPE_HAS)); rb_define_const (cColl, "TYPE_MATCH", INT2FIX (XMMS_COLLECTION_TYPE_MATCH)); rb_define_const (cColl, "TYPE_TOKEN", INT2FIX (XMMS_COLLECTION_TYPE_TOKEN)); rb_define_const (cColl, "TYPE_EQUALS", INT2FIX (XMMS_COLLECTION_TYPE_EQUALS)); rb_define_const (cColl, "TYPE_NOTEQUAL", INT2FIX (XMMS_COLLECTION_TYPE_NOTEQUAL)); rb_define_const (cColl, "TYPE_SMALLER", INT2FIX (XMMS_COLLECTION_TYPE_SMALLER)); rb_define_const (cColl, "TYPE_SMALLEREQ", INT2FIX (XMMS_COLLECTION_TYPE_SMALLEREQ)); rb_define_const (cColl, "TYPE_GREATER", INT2FIX (XMMS_COLLECTION_TYPE_GREATER)); rb_define_const (cColl, "TYPE_GREATEREQ", INT2FIX (XMMS_COLLECTION_TYPE_GREATEREQ)); rb_define_const (cColl, "TYPE_ORDER", INT2FIX (XMMS_COLLECTION_TYPE_ORDER)); rb_define_const (cColl, "TYPE_LIMIT", INT2FIX (XMMS_COLLECTION_TYPE_LIMIT)); rb_define_const (cColl, "TYPE_MEDIASET", INT2FIX (XMMS_COLLECTION_TYPE_MEDIASET)); rb_define_const (cColl, "TYPE_IDLIST", INT2FIX (XMMS_COLLECTION_TYPE_IDLIST)); rb_define_const (cColl, "ADD", INT2FIX (XMMS_COLLECTION_CHANGED_ADD)); rb_define_const (cColl, "UPDATE", INT2FIX (XMMS_COLLECTION_CHANGED_UPDATE)); rb_define_const (cColl, "RENAME", INT2FIX (XMMS_COLLECTION_CHANGED_RENAME)); rb_define_const (cColl, "REMOVE", INT2FIX (XMMS_COLLECTION_CHANGED_REMOVE)); ePatternError = rb_define_class_under (cColl, "PatternError", rb_eStandardError); eCollectionError = rb_define_class_under (cColl, "CollectionError", rb_eStandardError); eClientError = rb_define_class_under (cColl, "ClientError", rb_eStandardError); eDisconnectedError = rb_define_class_under (cColl, "DisconnectedError", eClientError); cAttributes = rb_define_class_under (cColl, "Attributes", rb_cObject); rb_define_method (cAttributes, "initialize", c_attrs_init, 1); #ifdef HAVE_RB_PROTECT_INSPECT rb_define_method (cAttributes, "inspect", c_attrs_inspect, 0); #endif /* HAVE_RB_PROTECT_INSPECT */ rb_define_method (cAttributes, "[]", c_attrs_aref, 1); rb_define_method (cAttributes, "[]=", c_attrs_aset, 2); rb_define_method (cAttributes, "has_key?", c_attrs_has_key, 1); rb_define_method (cAttributes, "delete", c_attrs_delete, 1); rb_define_method (cAttributes, "each", c_attrs_each, 0); rb_define_method (cAttributes, "each_key", c_attrs_each_key, 0); rb_define_method (cAttributes, "each_value", c_attrs_each_value, 0); rb_define_alias (cAttributes, "include?", "has_key?"); rb_define_alias (cAttributes, "key?", "has_key?"); rb_define_alias (cAttributes, "member?", "has_key?"); rb_define_alias (cAttributes, "each_pair", "each"); rb_include_module (cAttributes, rb_mEnumerable); cOperands = rb_define_class_under (cColl, "Operands", rb_cObject); rb_define_method (cOperands, "initialize", c_operands_init, 1); rb_define_method (cOperands, "push", c_operands_push, 1); rb_define_method (cOperands, "delete", c_operands_delete, 1); rb_define_method (cOperands, "each", c_operands_each, 0); rb_define_alias (cOperands, "<<", "push"); rb_include_module (cOperands, rb_mEnumerable); }
void Init_curb_core() { // TODO we need to call curl_global_cleanup at exit! curl_version_info_data *ver; VALUE curlver, curllongver, curlvernum; curl_global_init(CURL_GLOBAL_ALL); ver = curl_version_info(CURLVERSION_NOW); mCurl = rb_define_module("Curl"); curlver = rb_str_new2(ver->version); curllongver = rb_str_new2(curl_version()); curlvernum = LONG2NUM(LIBCURL_VERSION_NUM); rb_define_const(mCurl, "CURB_VERSION", rb_str_new2(CURB_VERSION)); rb_define_const(mCurl, "VERSION", curlver); rb_define_const(mCurl, "CURL_VERSION", curlver); rb_define_const(mCurl, "VERNUM", curlvernum); rb_define_const(mCurl, "CURL_VERNUM", curlvernum); rb_define_const(mCurl, "LONG_VERSION", curllongver); rb_define_const(mCurl, "CURL_LONG_VERSION", curllongver); /* Passed to on_debug handler to indicate that the data is informational text. */ rb_define_const(mCurl, "CURLINFO_TEXT", INT2FIX(CURLINFO_TEXT)); /* Passed to on_debug handler to indicate that the data is header (or header-like) data received from the peer. */ rb_define_const(mCurl, "CURLINFO_HEADER_IN", INT2FIX(CURLINFO_HEADER_IN)); /* Passed to on_debug handler to indicate that the data is header (or header-like) data sent to the peer. */ rb_define_const(mCurl, "CURLINFO_HEADER_OUT", INT2FIX(CURLINFO_HEADER_OUT)); /* Passed to on_debug handler to indicate that the data is protocol data received from the peer. */ rb_define_const(mCurl, "CURLINFO_DATA_IN", INT2FIX(CURLINFO_DATA_IN)); /* Passed to on_debug handler to indicate that the data is protocol data sent to the peer. */ rb_define_const(mCurl, "CURLINFO_DATA_OUT", INT2FIX(CURLINFO_DATA_OUT)); #ifdef HAVE_CURLFTPMETHOD_MULTICWD rb_define_const(mCurl, "CURL_MULTICWD", INT2FIX(CURLFTPMETHOD_MULTICWD)); #endif #ifdef HAVE_CURLFTPMETHOD_NOCWD rb_define_const(mCurl, "CURL_NOCWD", INT2FIX(CURLFTPMETHOD_NOCWD)); #endif #ifdef HAVE_CURLFTPMETHOD_SINGLECWD rb_define_const(mCurl, "CURL_SINGLECWD", INT2FIX(CURLFTPMETHOD_SINGLECWD)); #endif /* When passed to Curl::Easy#proxy_type , indicates that the proxy is an HTTP proxy. (libcurl >= 7.10) */ #ifdef HAVE_CURLPROXY_HTTP rb_define_const(mCurl, "CURLPROXY_HTTP", INT2FIX(CURLPROXY_HTTP)); #else rb_define_const(mCurl, "CURLPROXY_HTTP", INT2FIX(-1)); #endif #ifdef CURL_VERSION_SSL rb_define_const(mCurl, "CURL_SSLVERSION_DEFAULT", INT2FIX(CURL_SSLVERSION_DEFAULT)); rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1", INT2FIX(CURL_SSLVERSION_TLSv1)); rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2", INT2FIX(CURL_SSLVERSION_SSLv2)); rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3", INT2FIX(CURL_SSLVERSION_SSLv3)); rb_define_const(mCurl, "CURL_USESSL_CONTROL", INT2FIX(CURB_FTPSSL_CONTROL)); rb_define_const(mCurl, "CURL_USESSL_NONE", INT2FIX(CURB_FTPSSL_NONE)); rb_define_const(mCurl, "CURL_USESSL_TRY", INT2FIX(CURB_FTPSSL_TRY)); rb_define_const(mCurl, "CURL_USESSL_ALL", INT2FIX(CURB_FTPSSL_ALL)); #else rb_define_const(mCurl, "CURL_SSLVERSION_DEFAULT", INT2FIX(-1)); rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1", INT2FIX(-1)); rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2", INT2FIX(-1)); rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3", INT2FIX(-1)); rb_define_const(mCurl, "CURL_USESSL_CONTROL", INT2FIX(-1)); rb_define_const(mCurl, "CURL_USESSL_NONE", INT2FIX(-1)); rb_define_const(mCurl, "CURL_USESSL_TRY", INT2FIX(-1)); rb_define_const(mCurl, "CURL_USESSL_ALL", INT2FIX(-1)); #endif /* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS4 proxy. (libcurl >= 7.15.2) */ #ifdef HAVE_CURLPROXY_SOCKS4 rb_define_const(mCurl, "CURLPROXY_SOCKS4", INT2FIX(CURLPROXY_SOCKS4)); #else rb_define_const(mCurl, "CURLPROXY_SOCKS4", INT2FIX(-2)); #endif /* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS5 proxy. (libcurl >= 7.10) */ #ifdef HAVE_CURLPROXY_SOCKS5 rb_define_const(mCurl, "CURLPROXY_SOCKS5", INT2FIX(CURLPROXY_SOCKS5)); #else rb_define_const(mCurl, "CURLPROXY_SOCKS5", INT2FIX(-2)); #endif /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use Basic authentication. */ #ifdef HAVE_CURLAUTH_BASIC rb_define_const(mCurl, "CURLAUTH_BASIC", INT2FIX(CURLAUTH_BASIC)); #else rb_define_const(mCurl, "CURLAUTH_BASIC", INT2FIX(0)); #endif /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use Digest authentication. */ #ifdef HAVE_CURLAUTH_DIGEST rb_define_const(mCurl, "CURLAUTH_DIGEST", INT2FIX(CURLAUTH_DIGEST)); #else rb_define_const(mCurl, "CURLAUTH_DIGEST", INT2FIX(0)); #endif /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use GSS Negotiate authentication. Requires a suitable GSS-API library. */ #ifdef HAVE_CURLAUTH_GSSNEGOTIATE rb_define_const(mCurl, "CURLAUTH_GSSNEGOTIATE", INT2FIX(CURLAUTH_GSSNEGOTIATE)); #else rb_define_const(mCurl, "CURLAUTH_GSSNEGOTIATE", INT2FIX(0)); #endif /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use HTTP NTLM authentication. Requires MS Windows or OpenSSL support. */ #ifdef HAVE_CURLAUTH_NTLM rb_define_const(mCurl, "CURLAUTH_NTLM", INT2FIX(CURLAUTH_NTLM)); #else rb_define_const(mCurl, "CURLAUTH_NTLM", INT2FIX(0)); #endif /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, allows libcurl to select any suitable authentication method except basic. */ #ifdef HAVE_CURLAUTH_ANYSAFE rb_define_const(mCurl, "CURLAUTH_ANYSAFE", INT2FIX(CURLAUTH_ANYSAFE)); #else rb_define_const(mCurl, "CURLAUTH_ANYSAFE", INT2FIX(0)); #endif /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, allows libcurl to select any suitable authentication method. */ #ifdef HAVE_CURLAUTH_ANY rb_define_const(mCurl, "CURLAUTH_ANY", INT2FIX(CURLAUTH_ANY)); #else rb_define_const(mCurl, "CURLAUTH_ANY", INT2FIX(0)); #endif CURB_DEFINE(CURLOPT_VERBOSE); CURB_DEFINE(CURLOPT_HEADER); CURB_DEFINE(CURLOPT_NOPROGRESS); CURB_DEFINE(CURLOPT_NOSIGNAL); CURB_DEFINE(CURLOPT_WRITEFUNCTION); CURB_DEFINE(CURLOPT_WRITEDATA); CURB_DEFINE(CURLOPT_READFUNCTION); CURB_DEFINE(CURLOPT_READDATA); CURB_DEFINE(CURLOPT_IOCTLFUNCTION); CURB_DEFINE(CURLOPT_IOCTLDATA); CURB_DEFINE(CURLOPT_SEEKFUNCTION); CURB_DEFINE(CURLOPT_SEEKDATA); CURB_DEFINE(CURLOPT_SOCKOPTFUNCTION); CURB_DEFINE(CURLOPT_SOCKOPTDATA); CURB_DEFINE(CURLOPT_OPENSOCKETFUNCTION); CURB_DEFINE(CURLOPT_OPENSOCKETDATA); CURB_DEFINE(CURLOPT_PROGRESSFUNCTION); CURB_DEFINE(CURLOPT_PROGRESSDATA); CURB_DEFINE(CURLOPT_HEADERFUNCTION); CURB_DEFINE(CURLOPT_WRITEHEADER); CURB_DEFINE(CURLOPT_DEBUGFUNCTION); CURB_DEFINE(CURLOPT_DEBUGDATA); CURB_DEFINE(CURLOPT_SSL_CTX_FUNCTION); CURB_DEFINE(CURLOPT_SSL_CTX_DATA); CURB_DEFINE(CURLOPT_CONV_TO_NETWORK_FUNCTION); CURB_DEFINE(CURLOPT_CONV_FROM_NETWORK_FUNCTION); CURB_DEFINE(CURLOPT_CONV_FROM_UTF8_FUNCTION); #if HAVE_CURLOPT_INTERLEAVEFUNCTION CURB_DEFINE(CURLOPT_INTERLEAVEFUNCTION); #endif #if HAVE_CURLOPT_INTERLEAVEDATA CURB_DEFINE(CURLOPT_INTERLEAVEDATA); #endif #if HAVE_CURLOPT_CHUNK_BGN_FUNCTION CURB_DEFINE(CURLOPT_CHUNK_BGN_FUNCTION); #endif #if HAVE_CURLOPT_CHUNK_END_FUNCTION CURB_DEFINE(CURLOPT_CHUNK_END_FUNCTION); #endif #if HAVE_CURLOPT_CHUNK_DATA CURB_DEFINE(CURLOPT_CHUNK_DATA); #endif #if HAVE_CURLOPT_FNMATCH_FUNCTION CURB_DEFINE(CURLOPT_FNMATCH_FUNCTION); #endif #if HAVE_CURLOPT_FNMATCH_DATA CURB_DEFINE(CURLOPT_FNMATCH_DATA); #endif #if HAVE_CURLOPT_ERRORBUFFER CURB_DEFINE(CURLOPT_ERRORBUFFER); #endif #if HAVE_CURLOPT_STDERR CURB_DEFINE(CURLOPT_STDERR); #endif #if HAVE_CURLOPT_FAILONERROR CURB_DEFINE(CURLOPT_FAILONERROR); #endif CURB_DEFINE(CURLOPT_URL); CURB_DEFINE(CURLOPT_PROTOCOLS); CURB_DEFINE(CURLOPT_REDIR_PROTOCOLS); CURB_DEFINE(CURLOPT_PROXY); CURB_DEFINE(CURLOPT_PROXYPORT); #if HAVE_CURLOPT_PROXYTYPE CURB_DEFINE(CURLOPT_PROXYTYPE); #endif #if HAVE_CURLOPT_NOPROXY CURB_DEFINE(CURLOPT_NOPROXY); #endif CURB_DEFINE(CURLOPT_HTTPPROXYTUNNEL); #if HAVE_CURLOPT_SOCKS5_GSSAPI_SERVICE CURB_DEFINE(CURLOPT_SOCKS5_GSSAPI_SERVICE); #endif #if HAVE_CURLOPT_SOCKS5_GSSAPI_NEC CURB_DEFINE(CURLOPT_SOCKS5_GSSAPI_NEC); #endif CURB_DEFINE(CURLOPT_INTERFACE); #if HAVE_CURLOPT_LOCALPORT CURB_DEFINE(CURLOPT_LOCALPORT); #endif CURB_DEFINE(CURLOPT_DNS_CACHE_TIMEOUT); CURB_DEFINE(CURLOPT_DNS_USE_GLOBAL_CACHE); CURB_DEFINE(CURLOPT_BUFFERSIZE); CURB_DEFINE(CURLOPT_PORT); CURB_DEFINE(CURLOPT_TCP_NODELAY); #if HAVE_CURLOPT_ADDRESS_SCOPE CURB_DEFINE(CURLOPT_ADDRESS_SCOPE); #endif CURB_DEFINE(CURLOPT_NETRC); CURB_DEFINE(CURL_NETRC_OPTIONAL); CURB_DEFINE(CURL_NETRC_IGNORED); CURB_DEFINE(CURL_NETRC_REQUIRED); #if HAVE_CURLOPT_NETRC_FILE CURB_DEFINE(CURLOPT_NETRC_FILE); #endif CURB_DEFINE(CURLOPT_USERPWD); CURB_DEFINE(CURLOPT_PROXYUSERPWD); #if HAVE_CURLOPT_USERNAME CURB_DEFINE(CURLOPT_USERNAME); #endif #if HAVE_CURLOPT_PASSWORD CURB_DEFINE(CURLOPT_PASSWORD); #endif #if HAVE_CURLOPT_PROXYUSERNAME CURB_DEFINE(CURLOPT_PASSWORD); #endif #if HAVE_CURLOPT_PROXYPASSWORD CURB_DEFINE(CURLOPT_PASSWORD); #endif #if HAVE_CURLOPT_HTTPAUTH CURB_DEFINE(CURLOPT_HTTPAUTH); #endif #if HAVE_CURLAUTH_DIGEST_IE CURB_DEFINE(CURLAUTH_DIGEST_IE); #endif #if HAVE_CURLAUTH_ONLY CURB_DEFINE(CURLAUTH_ONLY); #endif #if HAVE_CURLOPT_TLSAUTH_TYPE CURB_DEFINE(CURLOPT_TLSAUTH_TYPE); #endif #if HAVE_CURLOPT_TLSAUTH_SRP CURB_DEFINE(CURLOPT_TLSAUTH_SRP); #endif #if HAVE_CURLOPT_TLSAUTH_USERNAME CURB_DEFINE(CURLOPT_TLSAUTH_USERNAME); #endif #if HAVE_CURLOPT_TLSAUTH_PASSWORD CURB_DEFINE(CURLOPT_TLSAUTH_PASSWORD); #endif #if HAVE_CURLOPT_PROXYAUTH CURB_DEFINE(CURLOPT_PROXYAUTH); #endif #if HAVE_CURLOPT_AUTOREFERER CURB_DEFINE(CURLOPT_AUTOREFERER); #endif #if HAVE_CURLOPT_ENCODING CURB_DEFINE(CURLOPT_ENCODING); #endif #if HAVE_CURLOPT_FOLLOWLOCATION CURB_DEFINE(CURLOPT_FOLLOWLOCATION); #endif #if HAVE_CURLOPT_UNRESTRICTED_AUTH CURB_DEFINE(CURLOPT_UNRESTRICTED_AUTH); #endif #if HAVE_CURLOPT_MAXREDIRS CURB_DEFINE(CURLOPT_MAXREDIRS); #endif #if HAVE_CURLOPT_POSTREDIR CURB_DEFINE(CURLOPT_POSTREDIR); #endif #if HAVE_CURLOPT_PUT CURB_DEFINE(CURLOPT_PUT); #endif #if HAVE_CURLOPT_POST CURB_DEFINE(CURLOPT_POST); #endif CURB_DEFINE(CURLOPT_POSTFIELDS); CURB_DEFINE(CURLOPT_POSTFIELDSIZE); #if HAVE_CURLOPT_POSTFIELDSIZE_LARGE CURB_DEFINE(CURLOPT_POSTFIELDSIZE_LARGE); #endif #if HAVE_CURLOPT_COPYPOSTFIELDS CURB_DEFINE(CURLOPT_COPYPOSTFIELDS); #endif #if HAVE_CURLOPT_HTTPPOST CURB_DEFINE(CURLOPT_HTTPPOST); #endif CURB_DEFINE(CURLOPT_REFERER); CURB_DEFINE(CURLOPT_USERAGENT); CURB_DEFINE(CURLOPT_HTTPHEADER); #if HAVE_CURLOPT_HTTP200ALIASES CURB_DEFINE(CURLOPT_HTTP200ALIASES); #endif CURB_DEFINE(CURLOPT_COOKIE); CURB_DEFINE(CURLOPT_COOKIEFILE); CURB_DEFINE(CURLOPT_COOKIEJAR); #if HAVE_CURLOPT_COOKIESESSION CURB_DEFINE(CURLOPT_COOKIESESSION); #endif #if HAVE_CURLOPT_COOKIELIST CURB_DEFINE(CURLOPT_COOKIELIST); #endif #if HAVE_CURLOPT_HTTPGET CURB_DEFINE(CURLOPT_HTTPGET); #endif CURB_DEFINE(CURLOPT_HTTP_VERSION); CURB_DEFINE(CURL_HTTP_VERSION_NONE); CURB_DEFINE(CURL_HTTP_VERSION_1_0); CURB_DEFINE(CURL_HTTP_VERSION_1_1); #if HAVE_CURLOPT_IGNORE_CONTENT_LENGTH CURB_DEFINE(CURLOPT_IGNORE_CONTENT_LENGTH); #endif #if HAVE_CURLOPT_HTTP_CONTENT_DECODING CURB_DEFINE(CURLOPT_HTTP_CONTENT_DECODING); #endif #if HAVE_CURLOPT_HTTP_TRANSFER_DECODING CURB_DEFINE(CURLOPT_HTTP_TRANSFER_DECODING); #endif #if HAVE_CURLOPT_MAIL_FROM CURB_DEFINE(CURLOPT_MAIL_FROM); #endif #if HAVE_CURLOPT_MAIL_RCPT CURB_DEFINE(CURLOPT_MAIL_RCPT); #endif #if HAVE_CURLOPT_TFTP_BLKSIZE CURB_DEFINE(CURLOPT_TFTP_BLKSIZE); #endif #if HAVE_CURLOPT_FTPPORT CURB_DEFINE(CURLOPT_FTPPORT); #endif #if HAVE_CURLOPT_QUOTE CURB_DEFINE(CURLOPT_QUOTE); #endif #if HAVE_CURLOPT_POSTQUOTE CURB_DEFINE(CURLOPT_POSTQUOTE); #endif #if HAVE_CURLOPT_PREQUOTE CURB_DEFINE(CURLOPT_PREQUOTE); #endif #if HAVE_CURLOPT_DIRLISTONLY CURB_DEFINE(CURLOPT_DIRLISTONLY); #endif #if HAVE_CURLOPT_APPEND CURB_DEFINE(CURLOPT_APPEND); #endif #if HAVE_CURLOPT_FTP_USE_EPRT CURB_DEFINE(CURLOPT_FTP_USE_EPRT); #endif #if HAVE_CURLOPT_FTP_USE_EPSV CURB_DEFINE(CURLOPT_FTP_USE_EPSV); #endif #if HAVE_CURLOPT_FTP_USE_PRET CURB_DEFINE(CURLOPT_FTP_USE_PRET); #endif #if HAVE_CURLOPT_FTP_CREATE_MISSING_DIRS CURB_DEFINE(CURLOPT_FTP_CREATE_MISSING_DIRS); #endif #if HAVE_CURLOPT_FTP_RESPONSE_TIMEOUT CURB_DEFINE(CURLOPT_FTP_RESPONSE_TIMEOUT); #endif #if HAVE_CURLOPT_FTP_ALTERNATIVE_TO_USER CURB_DEFINE(CURLOPT_FTP_ALTERNATIVE_TO_USER); #endif #if HAVE_CURLOPT_FTP_SKIP_PASV_IP CURB_DEFINE(CURLOPT_FTP_SKIP_PASV_IP); #endif #if HAVE_CURLOPT_FTPSSLAUTH CURB_DEFINE(CURLOPT_FTPSSLAUTH); #endif #if HAVE_CURLFTPAUTH_DEFAULT CURB_DEFINE(CURLFTPAUTH_DEFAULT); #endif #if HAVE_CURLFTPAUTH_SSL CURB_DEFINE(CURLFTPAUTH_SSL); #endif #if HAVE_CURLFTPAUTH_TLS CURB_DEFINE(CURLFTPAUTH_TLS); #endif #if HAVE_CURLOPT_FTP_SSL_CCC CURB_DEFINE(CURLOPT_FTP_SSL_CCC); #endif #if HAVE_CURLFTPSSL_CCC_NONE CURB_DEFINE(CURLFTPSSL_CCC_NONE); #endif #if HAVE_CURLFTPSSL_CCC_PASSIVE CURB_DEFINE(CURLFTPSSL_CCC_PASSIVE); #endif #if HAVE_CURLFTPSSL_CCC_ACTIVE CURB_DEFINE(CURLFTPSSL_CCC_ACTIVE); #endif #if HAVE_CURLOPT_FTP_ACCOUNT CURB_DEFINE(CURLOPT_FTP_ACCOUNT); #endif #if HAVE_CURLOPT_FTP_FILEMETHOD CURB_DEFINE(CURLOPT_FTP_FILEMETHOD); #endif #if HAVE_CURLFTPMETHOD_MULTICWD CURB_DEFINE(CURLFTPMETHOD_MULTICWD); #endif #if HAVE_CURLFTPMETHOD_NOCWD CURB_DEFINE(CURLFTPMETHOD_NOCWD); #endif #if HAVE_CURLFTPMETHOD_SINGLECWD CURB_DEFINE(CURLFTPMETHOD_SINGLECWD); #endif #if HAVE_CURLOPT_RTSP_REQUEST CURB_DEFINE(CURLOPT_RTSP_REQUEST); #endif #if HAVE_CURL_RTSPREQ_OPTIONS CURB_DEFINE(CURL_RTSPREQ_OPTIONS); #endif #if HAVE_CURL_RTSPREQ_DESCRIBE CURB_DEFINE(CURL_RTSPREQ_DESCRIBE); #endif #if HAVE_CURL_RTSPREQ_ANNOUNCE CURB_DEFINE(CURL_RTSPREQ_ANNOUNCE); #endif #if HAVE_CURL_RTSPREQ_SETUP CURB_DEFINE(CURL_RTSPREQ_SETUP); #endif #if HAVE_CURL_RTSPREQ_PLAY CURB_DEFINE(CURL_RTSPREQ_PLAY); #endif #if HAVE_CURL_RTSPREQ_PAUSE CURB_DEFINE(CURL_RTSPREQ_PAUSE); #endif #if HAVE_CURL_RTSPREQ_TEARDOWN CURB_DEFINE(CURL_RTSPREQ_TEARDOWN); #endif #if HAVE_CURL_RTSPREQ_GET_PARAMETER CURB_DEFINE(CURL_RTSPREQ_GET_PARAMETER); #endif #if HAVE_CURL_RTSPREQ_SET_PARAMETER CURB_DEFINE(CURL_RTSPREQ_SET_PARAMETER); #endif #if HAVE_CURL_RTSPREQ_RECORD CURB_DEFINE(CURL_RTSPREQ_RECORD); #endif #if HAVE_CURL_RTSPREQ_RECEIVE CURB_DEFINE(CURL_RTSPREQ_RECEIVE); #endif #if HAVE_CURLOPT_RTSP_SESSION_ID CURB_DEFINE(CURLOPT_RTSP_SESSION_ID); #endif #if HAVE_CURLOPT_RTSP_STREAM_URI CURB_DEFINE(CURLOPT_RTSP_STREAM_URI); #endif #if HAVE_CURLOPT_RTSP_TRANSPORT CURB_DEFINE(CURLOPT_RTSP_TRANSPORT); #endif #if HAVE_CURLOPT_RTSP_HEADER CURB_DEFINE(CURLOPT_RTSP_HEADER); #endif #if HAVE_CURLOPT_RTSP_CLIENT_CSEQ CURB_DEFINE(CURLOPT_RTSP_CLIENT_CSEQ); #endif #if HAVE_CURLOPT_RTSP_SERVER_CSEQ CURB_DEFINE(CURLOPT_RTSP_SERVER_CSEQ); #endif CURB_DEFINE(CURLOPT_TRANSFERTEXT); #if HAVE_CURLOPT_PROXY_TRANSFER_MODE CURB_DEFINE(CURLOPT_PROXY_TRANSFER_MODE); #endif #if HAVE_CURLOPT_CRLF CURB_DEFINE(CURLOPT_CRLF); #endif #if HAVE_CURLOPT_RANGE CURB_DEFINE(CURLOPT_RANGE); #endif #if HAVE_CURLOPT_RESUME_FROM CURB_DEFINE(CURLOPT_RESUME_FROM); #endif #if HAVE_CURLOPT_RESUME_FROM_LARGE CURB_DEFINE(CURLOPT_RESUME_FROM_LARGE); #endif #if HAVE_CURLOPT_CUSTOMREQUEST CURB_DEFINE(CURLOPT_CUSTOMREQUEST); #endif #if HAVE_CURLOPT_FILETIME CURB_DEFINE(CURLOPT_FILETIME); #endif #if HAVE_CURLOPT_NOBODY CURB_DEFINE(CURLOPT_NOBODY); #endif #if HAVE_CURLOPT_INFILESIZE CURB_DEFINE(CURLOPT_INFILESIZE); #endif #if HAVE_CURLOPT_INFILESIZE_LARGE CURB_DEFINE(CURLOPT_INFILESIZE_LARGE); #endif #if HAVE_CURLOPT_UPLOAD CURB_DEFINE(CURLOPT_UPLOAD); #endif #if HAVE_CURLOPT_MAXFILESIZE CURB_DEFINE(CURLOPT_MAXFILESIZE); #endif #if HAVE_CURLOPT_MAXFILESIZE_LARGE CURB_DEFINE(CURLOPT_MAXFILESIZE_LARGE); #endif #if HAVE_CURLOPT_TIMECONDITION CURB_DEFINE(CURLOPT_TIMECONDITION); #endif #if HAVE_CURLOPT_TIMEVALUE CURB_DEFINE(CURLOPT_TIMEVALUE); #endif #if HAVE_CURLOPT_TIMEOUT CURB_DEFINE(CURLOPT_TIMEOUT); #endif #if HAVE_CURLOPT_TIMEOUT_MS CURB_DEFINE(CURLOPT_TIMEOUT_MS); #endif #if HAVE_CURLOPT_LOW_SPEED_LIMIT CURB_DEFINE(CURLOPT_LOW_SPEED_LIMIT); #endif #if HAVE_CURLOPT_LOW_SPEED_TIME CURB_DEFINE(CURLOPT_LOW_SPEED_TIME); #endif #if HAVE_CURLOPT_MAX_SEND_SPEED_LARGE CURB_DEFINE(CURLOPT_MAX_SEND_SPEED_LARGE); #endif #if HAVE_CURLOPT_MAX_RECV_SPEED_LARGE CURB_DEFINE(CURLOPT_MAX_RECV_SPEED_LARGE); #endif #if HAVE_CURLOPT_MAXCONNECTS CURB_DEFINE(CURLOPT_MAXCONNECTS); #endif #if HAVE_CURLOPT_CLOSEPOLICY CURB_DEFINE(CURLOPT_CLOSEPOLICY); #endif #if HAVE_CURLOPT_FRESH_CONNECT CURB_DEFINE(CURLOPT_FRESH_CONNECT); #endif #if HAVE_CURLOPT_FORBID_REUSE CURB_DEFINE(CURLOPT_FORBID_REUSE); #endif #if HAVE_CURLOPT_CONNECTTIMEOUT CURB_DEFINE(CURLOPT_CONNECTTIMEOUT); #endif #if HAVE_CURLOPT_CONNECTTIMEOUT_MS CURB_DEFINE(CURLOPT_CONNECTTIMEOUT_MS); #endif #if HAVE_CURLOPT_IPRESOLVE CURB_DEFINE(CURLOPT_IPRESOLVE); #endif #if HAVE_CURL_IPRESOLVE_WHATEVER CURB_DEFINE(CURL_IPRESOLVE_WHATEVER); #endif #if HAVE_CURL_IPRESOLVE_V4 CURB_DEFINE(CURL_IPRESOLVE_V4); #endif #if HAVE_CURL_IPRESOLVE_V6 CURB_DEFINE(CURL_IPRESOLVE_V6); #endif #if HAVE_CURLOPT_CONNECT_ONLY CURB_DEFINE(CURLOPT_CONNECT_ONLY); #endif #if HAVE_CURLOPT_USE_SSL CURB_DEFINE(CURLOPT_USE_SSL); #endif #if HAVE_CURLUSESSL_NONE CURB_DEFINE(CURLUSESSL_NONE); #endif #if HAVE_CURLUSESSL_TRY CURB_DEFINE(CURLUSESSL_TRY); #endif #if HAVE_CURLUSESSL_CONTROL CURB_DEFINE(CURLUSESSL_CONTROL); #endif #if HAVE_CURLUSESSL_ALL CURB_DEFINE(CURLUSESSL_ALL); #endif #if HAVE_CURLOPT_RESOLVE CURB_DEFINE(CURLOPT_RESOLVE); #endif #if HAVE_CURLOPT_SSLCERT CURB_DEFINE(CURLOPT_SSLCERT); #endif #if HAVE_CURLOPT_SSLCERTTYPE CURB_DEFINE(CURLOPT_SSLCERTTYPE); #endif #if HAVE_CURLOPT_SSLKEY CURB_DEFINE(CURLOPT_SSLKEY); #endif #if HAVE_CURLOPT_SSLKEYTYPE CURB_DEFINE(CURLOPT_SSLKEYTYPE); #endif #if HAVE_CURLOPT_KEYPASSWD CURB_DEFINE(CURLOPT_KEYPASSWD); #endif #if HAVE_CURLOPT_SSLENGINE CURB_DEFINE(CURLOPT_SSLENGINE); #endif #if HAVE_CURLOPT_SSLENGINE_DEFAULT CURB_DEFINE(CURLOPT_SSLENGINE_DEFAULT); #endif #if HAVE_CURLOPT_SSLVERSION CURB_DEFINE(CURLOPT_SSLVERSION); #endif #if HAVE_CURL_SSLVERSION_DEFAULT CURB_DEFINE(CURL_SSLVERSION_DEFAULT); #endif #if HAVE_CURL_SSLVERSION_TLSv1 CURB_DEFINE(CURL_SSLVERSION_TLSv1); #endif #if HAVE_CURL_SSLVERSION_SSLv2 CURB_DEFINE(CURL_SSLVERSION_SSLv2); #endif #if HAVE_CURL_SSLVERSION_SSLv3 CURB_DEFINE(CURL_SSLVERSION_SSLv3); #endif #if HAVE_CURLOPT_SSL_VERIFYPEER CURB_DEFINE(CURLOPT_SSL_VERIFYPEER); #endif #if HAVE_CURLOPT_CAINFO CURB_DEFINE(CURLOPT_CAINFO); #endif #if HAVE_CURLOPT_ISSUERCERT CURB_DEFINE(CURLOPT_ISSUERCERT); #endif #if HAVE_CURLOPT_CAPATH CURB_DEFINE(CURLOPT_CAPATH); #endif #if HAVE_CURLOPT_CRLFILE CURB_DEFINE(CURLOPT_CRLFILE); #endif #if HAVE_CURLOPT_SSL_VERIFYHOST CURB_DEFINE(CURLOPT_SSL_VERIFYHOST); #endif #if HAVE_CURLOPT_CERTINFO CURB_DEFINE(CURLOPT_CERTINFO); #endif #if HAVE_CURLOPT_RANDOM_FILE CURB_DEFINE(CURLOPT_RANDOM_FILE); #endif #if HAVE_CURLOPT_EGDSOCKET CURB_DEFINE(CURLOPT_EGDSOCKET); #endif #if HAVE_CURLOPT_SSL_CIPHER_LIST CURB_DEFINE(CURLOPT_SSL_CIPHER_LIST); #endif #if HAVE_CURLOPT_SSL_SESSIONID_CACHE CURB_DEFINE(CURLOPT_SSL_SESSIONID_CACHE); #endif #if HAVE_CURLOPT_KRBLEVEL CURB_DEFINE(CURLOPT_KRBLEVEL); #endif #if HAVE_CURLOPT_SSH_AUTH_TYPES CURB_DEFINE(CURLOPT_SSH_AUTH_TYPES); #endif #if HAVE_CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 CURB_DEFINE(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5); #endif #if HAVE_CURLOPT_SSH_PUBLIC_KEYFILE CURB_DEFINE(CURLOPT_SSH_PUBLIC_KEYFILE); #endif #if HAVE_CURLOPT_SSH_PRIVATE_KEYFILE CURB_DEFINE(CURLOPT_SSH_PRIVATE_KEYFILE); #endif #if HAVE_CURLOPT_SSH_KNOWNHOSTS CURB_DEFINE(CURLOPT_SSH_KNOWNHOSTS); #endif #if HAVE_CURLOPT_SSH_KEYFUNCTION CURB_DEFINE(CURLOPT_SSH_KEYFUNCTION); #endif #if HAVE_CURLKHSTAT_FINE_ADD_TO_FILE CURB_DEFINE(CURLKHSTAT_FINE_ADD_TO_FILE); #endif #if HAVE_CURLKHSTAT_FINE CURB_DEFINE(CURLKHSTAT_FINE); #endif #if HAVE_CURLKHSTAT_REJECT CURB_DEFINE(CURLKHSTAT_REJECT); #endif #if HAVE_CURLKHSTAT_DEFER CURB_DEFINE(CURLKHSTAT_DEFER); #endif #if HAVE_CURLOPT_SSH_KEYDATA CURB_DEFINE(CURLOPT_SSH_KEYDATA); #endif #if HAVE_CURLOPT_PRIVATE CURB_DEFINE(CURLOPT_PRIVATE); #endif #if HAVE_CURLOPT_SHARE CURB_DEFINE(CURLOPT_SHARE); #endif #if HAVE_CURLOPT_NEW_FILE_PERMS CURB_DEFINE(CURLOPT_NEW_FILE_PERMS); #endif #if HAVE_CURLOPT_NEW_DIRECTORY_PERMS CURB_DEFINE(CURLOPT_NEW_DIRECTORY_PERMS); #endif #if HAVE_CURLOPT_TELNETOPTIONS CURB_DEFINE(CURLOPT_TELNETOPTIONS); #endif rb_define_const(mCurl, "HTTP_1_1", LONG2NUM(CURL_HTTP_VERSION_1_1)); rb_define_const(mCurl, "HTTP_1_0", LONG2NUM(CURL_HTTP_VERSION_1_0)); rb_define_const(mCurl, "HTTP_NONE", LONG2NUM(CURL_HTTP_VERSION_NONE)); rb_define_singleton_method(mCurl, "ipv6?", ruby_curl_ipv6_q, 0); rb_define_singleton_method(mCurl, "kerberos4?", ruby_curl_kerberos4_q, 0); rb_define_singleton_method(mCurl, "ssl?", ruby_curl_ssl_q, 0); rb_define_singleton_method(mCurl, "libz?", ruby_curl_libz_q, 0); rb_define_singleton_method(mCurl, "ntlm?", ruby_curl_ntlm_q, 0); rb_define_singleton_method(mCurl, "gssnegotiate?", ruby_curl_gssnegotiate_q, 0); rb_define_singleton_method(mCurl, "debug?", ruby_curl_debug_q, 0); rb_define_singleton_method(mCurl, "asyncdns?", ruby_curl_asyncdns_q, 0); rb_define_singleton_method(mCurl, "spnego?", ruby_curl_spnego_q, 0); rb_define_singleton_method(mCurl, "largefile?", ruby_curl_largefile_q, 0); rb_define_singleton_method(mCurl, "idn?", ruby_curl_idn_q, 0); rb_define_singleton_method(mCurl, "sspi?", ruby_curl_sspi_q, 0); rb_define_singleton_method(mCurl, "conv?", ruby_curl_conv_q, 0); init_curb_errors(); init_curb_easy(); init_curb_postfield(); init_curb_multi(); }
int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { struct t_plugin_script_init init; int ruby_error; char *weechat_ruby_code = { "$stdout = WeechatOutputs\n" "$stderr = WeechatOutputs\n" "begin" " if RUBY_VERSION.split('.')[0] == '1' and RUBY_VERSION.split('.')[1] <= '8'\n" " require 'rubygems'\n" " else\n" " require 'thread'\n" " class ::Mutex\n" " def synchronize(*args)\n" " yield\n" " end\n" " end\n" " require 'rubygems'\n" " end\n" "rescue LoadError\n" "end\n" "\n" "class Module\n" "\n" " def load_eval_file (file)\n" " lines = ''\n" " begin\n" " lines = File.read(file)\n" " rescue => e\n" " return 1\n" " end\n" "\n" " begin\n" " require 'enc/encdb.so'\n" " require 'enc/trans/transdb.so'\n" " module_eval(lines)\n" " rescue Exception => e\n" " @load_eval_file_error = e\n" " return 2\n" " end\n" "\n" " has_init = false\n" "\n" " instance_methods.each do |meth|\n" " if meth.to_s == 'weechat_init'\n" " has_init = true\n" " end\n" " module_eval('module_function :' + meth.to_s)\n" " end\n" "\n" " unless has_init\n" " return 3\n" " end\n" "\n" " return 0\n" " end\n" "end\n" }; weechat_ruby_plugin = plugin; ruby_error = 0; /* init stdout/stderr buffer */ ruby_buffer_output[0] = '\0'; #if (defined(RUBY_API_VERSION_MAJOR) && defined(RUBY_API_VERSION_MINOR)) && (RUBY_API_VERSION_MAJOR >= 2 || (RUBY_API_VERSION_MAJOR == 1 && RUBY_API_VERSION_MINOR >= 9)) RUBY_INIT_STACK; #endif ruby_init (); /* redirect stdin and stdout */ ruby_mWeechatOutputs = rb_define_module ("WeechatOutputs"); rb_define_singleton_method (ruby_mWeechatOutputs, "write", weechat_ruby_output, 1); rb_define_singleton_method (ruby_mWeechatOutputs, "puts", weechat_ruby_output, 1); rb_define_singleton_method (ruby_mWeechatOutputs, "p", weechat_ruby_output, 1); rb_define_singleton_method (ruby_mWeechatOutputs, "flush", weechat_ruby_output_flush, 0); ruby_script ("__weechat_plugin__"); ruby_mWeechat = rb_define_module ("Weechat"); weechat_ruby_api_init (ruby_mWeechat); rb_eval_string_protect (weechat_ruby_code, &ruby_error); if (ruby_error) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to eval WeeChat ruby " "internal code"), weechat_prefix ("error"), RUBY_PLUGIN_NAME); VALUE err = rb_gv_get ("$!"); weechat_ruby_print_exception (err); return WEECHAT_RC_ERROR; } ruby_init_loadpath (); init.callback_command = &weechat_ruby_command_cb; init.callback_completion = &weechat_ruby_completion_cb; init.callback_hdata = &weechat_ruby_hdata_cb; init.callback_infolist = &weechat_ruby_infolist_cb; init.callback_signal_debug_dump = &weechat_ruby_signal_debug_dump_cb; init.callback_signal_debug_libs = &weechat_ruby_signal_debug_libs_cb; init.callback_signal_script_action = &weechat_ruby_signal_script_action_cb; init.callback_load_file = &weechat_ruby_load_cb; ruby_quiet = 1; plugin_script_init (weechat_ruby_plugin, argc, argv, &init); ruby_quiet = 0; plugin_script_display_short_list (weechat_ruby_plugin, ruby_scripts); /* init OK */ return WEECHAT_RC_OK; }
void Init_hyperll_delta_bytes(void) { rb_cDeltaBytes = rb_define_class_under(rb_mHyperll, "DeltaBytes", rb_cObject); rb_define_singleton_method(rb_cDeltaBytes, "compress", rb_delta_bytes_compress, 1); rb_define_singleton_method(rb_cDeltaBytes, "uncompress", rb_delta_bytes_uncompress, 1); }
void Init_v8() { ruby_call_symbol = ID2SYM(rb_intern("call")); ruby_respond_to_ID = rb_intern("respond_to?"); ruby_proc_class = rb_eval_string("::Proc"); ruby_method_class = rb_eval_string("::Method"); rb_mModule = rb_define_module("V8"); rb_define_singleton_method(rb_mModule, "what_is_this?", (VALUE(*)(...)) v8_what_is_this, 1); V8_To = rb_define_module_under(rb_mModule, "To"); //native module setup VALUE rb_mNative = rb_define_module_under(rb_mModule, "C"); //native context V8_C_Context = rb_define_class_under(rb_mNative, "Context", rb_cObject); rb_define_singleton_method(V8_C_Context, "new", (VALUE(*)(...)) v8_Context_New, -1); rb_define_singleton_method(V8_C_Context, "InContext", (VALUE(*)(...)) v8_Context_InContext, 0); rb_define_singleton_method(V8_C_Context, "GetCurrent", (VALUE(*)(...)) v8_Context_GetCurrent, 0); rb_define_method(V8_C_Context, "Global", (VALUE(*)(...)) v8_cxt_Global, 0); rb_define_method(V8_C_Context, "open", (VALUE(*)(...)) v8_cxt_open, 0); rb_define_method(V8_C_Context, "eval", (VALUE(*)(...)) v8_cxt_eval, 2); rb_define_method(V8_C_Context, "eql?", (VALUE(*)(...)) v8_cxt_eql, 1); rb_define_method(V8_C_Context, "==", (VALUE(*)(...)) v8_cxt_eql, 1); //native String VALUE V8__C__String = rb_define_class_under(rb_mNative, "String", rb_cObject); rb_define_singleton_method(V8__C__String, "new", (VALUE(*)(...)) v8_str_new, 1); rb_define_method(V8__C__String, "to_s", (VALUE(*)(...)) v8_str_to_s, 0); VALUE V8__C__Script = rb_define_class_under(rb_mNative, "Script", rb_cObject); rb_define_singleton_method(V8__C__Script, "new", (VALUE(*)(...)) v8_script_new, 1); rb_define_method(V8__C__Script, "Run", (VALUE(*)(...)) v8_script_Run, 0); VALUE V8__C__Template = rb_define_class_under(rb_mNative, "Template", rb_cObject); rb_define_method(V8__C__Template, "Set", (VALUE(*)(...))v8_Template_Set, 2); VALUE V8__C__ObjectTemplate = rb_define_class_under(rb_mNative, "ObjectTemplate", V8__C__Template); rb_define_singleton_method(V8__C__ObjectTemplate, "new", (VALUE(*)(...))v8_ObjectTemplate_New, 0); VALUE V8__C__FunctionTemplate = rb_define_class_under(rb_mNative, "FunctionTemplate", V8__C__Template); rb_define_singleton_method(V8__C__FunctionTemplate, "new", (VALUE(*)(...))v8_FunctionTemplate_New, -1); rb_define_method(V8__C__FunctionTemplate, "GetFunction", (VALUE(*)(...))v8_FunctionTemplate_GetFunction, 0); V8_C_Object = rb_define_class_under(rb_mNative, "Object", rb_cObject); rb_define_singleton_method(V8_C_Object, "new", (VALUE(*)(...))v8_Object_New, 0); rb_define_method(V8_C_Object, "Get", (VALUE(*)(...))v8_Object_Get, 1); rb_define_method(V8_C_Object, "Set", (VALUE(*)(...))v8_Object_Set, 2); rb_define_method(V8_C_Object, "GetPropertyNames", (VALUE(*)(...)) v8_Object_GetPropertyNames, 0); rb_define_method(V8_C_Object, "ToString", (VALUE(*)(...)) v8_Object_ToString, 0); rb_define_method(V8_C_Object, "context", (VALUE(*)(...)) v8_Object_context, 0); V8_C_Message = rb_define_class_under(rb_mNative, "Message", rb_cObject); rb_define_method(V8_C_Message, "Get", (VALUE(*)(...))v8_Message_Get, 0); rb_define_method(V8_C_Message, "GetSourceLine", (VALUE(*)(...))v8_Message_GetSourceLine, 0); rb_define_method(V8_C_Message, "GetScriptResourceName", (VALUE(*)(...))v8_Message_GetScriptResourceName, 0); rb_define_method(V8_C_Message, "GetLineNumber", (VALUE(*)(...))v8_Message_GetLineNumber, 0); rb_define_method(V8_C_Message, "GetStartPosition", (VALUE(*)(...))v8_Message_GetStartPosition, 0); rb_define_method(V8_C_Message, "GetEndPosition", (VALUE(*)(...)) v8_Message_GetEndPosition, 0); rb_define_method(V8_C_Message, "GetStartColumn", (VALUE(*)(...)) v8_Message_GetStartColumn, 0); rb_define_method(V8_C_Message, "GetEndColumn", (VALUE(*)(...)) v8_Message_GetEndColumn, 0); V8_C_Function = rb_define_class_under(rb_mNative, "Function", V8_C_Object); }
void Init_rising_saw() { cCSRisingSaw = rb_define_class_under(mCSSynths, "LLRisingSaw", cCSSynth); rb_define_singleton_method(cCSRisingSaw, "new", rbcs_rsaw_new, -1); }
void Init_magic(void) { id_at_path = rb_intern("@path"); id_at_flags = rb_intern("@flags"); id_at_mutex = rb_intern("@mutex"); rb_cMagic = rb_define_class("Magic", rb_cObject); rb_define_alloc_func(rb_cMagic, magic_allocate); /* * Raised when _Magic_ encounters an error. */ rb_mgc_eError = rb_define_class_under(rb_cMagic, "Error", rb_eStandardError); /* * Stores current value of +errno+ */ rb_define_attr(rb_mgc_eError, "errno", 1, 0); /* * Raised when */ rb_mgc_eMagicError = rb_define_class_under(rb_cMagic, "MagicError", rb_mgc_eError); /* * Raised when */ rb_mgc_eLibraryError = rb_define_class_under(rb_cMagic, "LibraryError", rb_mgc_eError); /* * Raised when */ rb_mgc_eFlagsError = rb_define_class_under(rb_cMagic, "FlagsError", rb_mgc_eError); /* * Raised when */ rb_mgc_eNotImplementedError = rb_define_class_under(rb_cMagic, "NotImplementedError", rb_mgc_eError); rb_define_method(rb_cMagic, "initialize", RUBY_METHOD_FUNC(rb_mgc_initialize), -2); rb_define_method(rb_cMagic, "close", RUBY_METHOD_FUNC(rb_mgc_close), 0); rb_define_method(rb_cMagic, "closed?", RUBY_METHOD_FUNC(rb_mgc_closed), 0); rb_define_method(rb_cMagic, "path", RUBY_METHOD_FUNC(rb_mgc_get_path), 0); rb_define_method(rb_cMagic, "flags", RUBY_METHOD_FUNC(rb_mgc_getflags), 0); rb_define_method(rb_cMagic, "flags=", RUBY_METHOD_FUNC(rb_mgc_setflags), 1); rb_define_method(rb_cMagic, "file", RUBY_METHOD_FUNC(rb_mgc_file), 1); rb_define_method(rb_cMagic, "buffer", RUBY_METHOD_FUNC(rb_mgc_buffer), 1); rb_define_method(rb_cMagic, "descriptor", RUBY_METHOD_FUNC(rb_mgc_descriptor), 1); rb_define_method(rb_cMagic, "load", RUBY_METHOD_FUNC(rb_mgc_load), -2); rb_define_method(rb_cMagic, "compile", RUBY_METHOD_FUNC(rb_mgc_compile), -2); rb_define_method(rb_cMagic, "check", RUBY_METHOD_FUNC(rb_mgc_check), -2); rb_alias(rb_cMagic, rb_intern("valid?"), rb_intern("check")); rb_define_singleton_method(rb_cMagic, "version", RUBY_METHOD_FUNC(rb_mgc_version), 0); /* * No special handling and/or flags specified. Default behaviour. */ rb_define_const(rb_cMagic, "NONE", INT2NUM(MAGIC_NONE)); /* * Print debugging messages to standard error output. */ rb_define_const(rb_cMagic, "DEBUG", INT2NUM(MAGIC_DEBUG)); /* * If the file queried is a symbolic link, follow it. */ rb_define_const(rb_cMagic, "SYMLINK", INT2NUM(MAGIC_SYMLINK)); /* * If the file is compressed, unpack it and look at the contents. */ rb_define_const(rb_cMagic, "COMPRESS", INT2NUM(MAGIC_COMPRESS)); /* * If the file is a block or character special device, then open * the device and try to look at the contents. */ rb_define_const(rb_cMagic, "DEVICES", INT2NUM(MAGIC_DEVICES)); /* * Return a MIME type string, instead of a textual description. */ rb_define_const(rb_cMagic, "MIME_TYPE", INT2NUM(MAGIC_MIME_TYPE)); /* * Return all matches, not just the first. */ rb_define_const(rb_cMagic, "CONTINUE", INT2NUM(MAGIC_CONTINUE)); /* * Check the Magic database for consistency and print warnings to * standard error output. */ rb_define_const(rb_cMagic, "CHECK", INT2NUM(MAGIC_CHECK)); /* * Attempt to preserve access time (atime, utime or utimes) of the * file queried on systems that support such system calls. */ rb_define_const(rb_cMagic, "PRESERVE_ATIME", INT2NUM(MAGIC_PRESERVE_ATIME)); /* * Do not translate unprintable characters to an octal representation. */ rb_define_const(rb_cMagic, "RAW", INT2NUM(MAGIC_RAW)); /* * Treat operating system errors while trying to open files and follow * symbolic links as first class errors, instead of storing them in the * Magic library error buffer for retrieval later. */ rb_define_const(rb_cMagic, "ERROR", INT2NUM(MAGIC_ERROR)); /* * Return a MIME encoding, instead of a textual description. */ rb_define_const(rb_cMagic, "MIME_ENCODING", INT2NUM(MAGIC_MIME_ENCODING)); /* * A shorthand for using MIME_TYPE and MIME_ENCODING flags together. */ rb_define_const(rb_cMagic, "MIME", INT2NUM(MAGIC_MIME)); /* * Return the Apple creator and type. */ rb_define_const(rb_cMagic, "APPLE", INT2NUM(MAGIC_APPLE)); /* * Do not look for, or inside compressed files. */ rb_define_const(rb_cMagic, "NO_CHECK_COMPRESS", INT2NUM(MAGIC_NO_CHECK_COMPRESS)); /* * Do not look for, or inside tar archive files. */ rb_define_const(rb_cMagic, "NO_CHECK_TAR", INT2NUM(MAGIC_NO_CHECK_TAR)); /* * Do not consult Magic files. */ rb_define_const(rb_cMagic, "NO_CHECK_SOFT", INT2NUM(MAGIC_NO_CHECK_SOFT)); /* * Check for EMX application type (only supported on EMX). */ rb_define_const(rb_cMagic, "NO_CHECK_APPTYPE", INT2NUM(MAGIC_NO_CHECK_APPTYPE)); /* * Do not check for ELF files (do not examine ELF file details). */ rb_define_const(rb_cMagic, "NO_CHECK_ELF", INT2NUM(MAGIC_NO_CHECK_ELF)); /* * Do not check for various types of text files. */ rb_define_const(rb_cMagic, "NO_CHECK_TEXT", INT2NUM(MAGIC_NO_CHECK_TEXT)); /* * Do not check for CDF files. */ rb_define_const(rb_cMagic, "NO_CHECK_CDF", INT2NUM(MAGIC_NO_CHECK_CDF)); /* * Do not look for known tokens inside ASCII files. */ rb_define_const(rb_cMagic, "NO_CHECK_TOKENS", INT2NUM(MAGIC_NO_CHECK_TOKENS)); /* * Return a MIME encoding, instead of a textual description. */ rb_define_const(rb_cMagic, "NO_CHECK_ENCODING", INT2NUM(MAGIC_NO_CHECK_ENCODING)); /* * Do not use built-in tests; only consult the Magic file. */ rb_define_const(rb_cMagic, "NO_CHECK_BUILTIN", INT2NUM(MAGIC_NO_CHECK_BUILTIN)); /* * Do not check for various types of text files, same as NO_CHECK_TEXT. */ rb_define_const(rb_cMagic, "NO_CHECK_ASCII", INT2NUM(MAGIC_NO_CHECK_ASCII)); /* * Do not look for Fortran sequences inside ASCII files. */ rb_define_const(rb_cMagic, "NO_CHECK_FORTRAN", INT2NUM(MAGIC_NO_CHECK_FORTRAN)); /* * Do not look for troff sequences inside ASCII files. */ rb_define_const(rb_cMagic, "NO_CHECK_TROFF", INT2NUM(MAGIC_NO_CHECK_TROFF)); }
void Init_mkfifo() { rb_define_singleton_method(rb_cFile, "mkfifo", rb_cFile_mkfifo, 1); }
void Init_gsl_integration(VALUE module) { VALUE mgsl_integ; mgsl_integ = rb_define_module_under(module, "Integration"); rb_gsl_integration_define_symbols(mgsl_integ); rb_define_method(cgsl_function, "integration_qng", rb_gsl_integration_qng, -1); rb_define_method(cgsl_function, "integration_qag", rb_gsl_integration_qag, -1); rb_define_method(cgsl_function, "integration_qags", rb_gsl_integration_qags, -1); rb_define_method(cgsl_function, "integration_qagp", rb_gsl_integration_qagp, -1); rb_define_method(cgsl_function, "integration_qagi", rb_gsl_integration_qagi, -1); rb_define_method(cgsl_function, "integration_qagiu", rb_gsl_integration_qagiu, -1); rb_define_method(cgsl_function, "integration_qagil", rb_gsl_integration_qagil, -1); rb_define_method(cgsl_function, "integration_qawc", rb_gsl_integration_qawc, -1); rb_define_alias(cgsl_function, "qng", "integration_qng"); rb_define_alias(cgsl_function, "qag", "integration_qag"); rb_define_alias(cgsl_function, "qags", "integration_qags"); rb_define_alias(cgsl_function, "qagp", "integration_qagp"); rb_define_alias(cgsl_function, "qagi", "integration_qagi"); rb_define_alias(cgsl_function, "qagiu", "integration_qagiu"); rb_define_alias(cgsl_function, "qagil", "integration_qagil"); rb_define_alias(cgsl_function, "qawc", "integration_qawc"); cgsl_integration_qaws_table = rb_define_class_under(mgsl_integ, "QAWS_Table", cGSL_Object); rb_define_singleton_method(cgsl_integration_qaws_table, "alloc", rb_gsl_integration_qaws_table_alloc, -1); /* rb_define_singleton_method(cgsl_integration_qaws_table, "new", rb_gsl_integration_qaws_table_alloc, -1);*/ rb_define_method(cgsl_integration_qaws_table, "to_a", rb_gsl_integration_qaws_table_to_a, 0); rb_define_method(cgsl_integration_qaws_table, "set", rb_gsl_integration_qaws_table_set, -1); rb_define_method(rb_cArray, "to_gsl_integration_qaws_table", rb_gsl_ary_to_integration_qaws_table, 0); rb_define_alias(rb_cArray, "to_qaws_table", "to_gsl_integration_qaws_table"); rb_define_method(cgsl_function, "integration_qaws", rb_gsl_integration_qaws, -1); rb_define_alias(cgsl_function, "qaws", "integration_qaws"); cgsl_integration_qawo_table = rb_define_class_under(mgsl_integ, "QAWO_Table", cGSL_Object); rb_define_singleton_method(cgsl_integration_qawo_table, "alloc", rb_gsl_integration_qawo_table_alloc, -1); /* rb_define_singleton_method(cgsl_integration_qawo_table, "new", rb_gsl_integration_qawo_table_alloc, -1);*/ rb_define_method(cgsl_integration_qawo_table, "to_a", rb_gsl_integration_qawo_table_to_a, 0); rb_define_method(rb_cArray, "to_gsl_integration_qawo_table", rb_gsl_ary_to_integration_qawo_table, 0); rb_define_method(cgsl_integration_qawo_table, "set", rb_gsl_integration_qawo_table_set, -1); rb_define_method(cgsl_integration_qawo_table, "set_length", rb_gsl_integration_qawo_table_set_length, 1); rb_define_method(cgsl_function, "integration_qawo", rb_gsl_integration_qawo, -1); rb_define_method(cgsl_function, "integration_qawf", rb_gsl_integration_qawf, -1); rb_define_alias(cgsl_function, "qawo", "integration_qawo"); rb_define_alias(cgsl_function, "qawf", "integration_qawf"); cgsl_integration_workspace = rb_define_class_under(mgsl_integ, "Workspace", cGSL_Object); /* rb_define_singleton_method(cgsl_integration_workspace, "new", rb_gsl_integration_workspace_alloc, -1);*/ rb_define_singleton_method(cgsl_integration_workspace, "alloc", rb_gsl_integration_workspace_alloc, -1); rb_define_method(cgsl_integration_workspace, "limit", rb_gsl_integration_workspace_limit, 0); rb_define_method(cgsl_integration_workspace, "size", rb_gsl_integration_workspace_size, 0); rb_define_method(cgsl_integration_workspace, "nrmax", rb_gsl_integration_workspace_nrmax, 0); rb_define_method(cgsl_integration_workspace, "i", rb_gsl_integration_workspace_i, 0); rb_define_method(cgsl_integration_workspace, "maximum_level", rb_gsl_integration_workspace_maximum_level, 0); rb_define_method(cgsl_integration_workspace, "to_a", rb_gsl_integration_workspace_to_a, 0); rb_define_method(cgsl_integration_workspace, "alist", rb_gsl_integration_workspace_alist, 0); rb_define_method(cgsl_integration_workspace, "blist", rb_gsl_integration_workspace_blist, 0); rb_define_method(cgsl_integration_workspace, "rlist", rb_gsl_integration_workspace_rlist, 0); rb_define_method(cgsl_integration_workspace, "elist", rb_gsl_integration_workspace_elist, 0); /*****/ rb_define_module_function(mgsl_integ, "qng", rb_gsl_integration_qng, -1); rb_define_module_function(mgsl_integ, "qag", rb_gsl_integration_qag, -1); rb_define_module_function(mgsl_integ, "qags", rb_gsl_integration_qags, -1); rb_define_module_function(mgsl_integ, "qagp", rb_gsl_integration_qagp, -1); rb_define_module_function(mgsl_integ, "qagi", rb_gsl_integration_qagi, -1); rb_define_module_function(mgsl_integ, "qagiu", rb_gsl_integration_qagiu, -1); rb_define_module_function(mgsl_integ, "qagil", rb_gsl_integration_qagil, -1); rb_define_module_function(mgsl_integ, "qawc", rb_gsl_integration_qawc, -1); rb_define_module_function(mgsl_integ, "qaws", rb_gsl_integration_qaws, -1); rb_define_module_function(mgsl_integ, "qawo", rb_gsl_integration_qawo, -1); rb_define_module_function(mgsl_integ, "qawf", rb_gsl_integration_qawf, -1); }
void Init_iseq(void) { rb_define_global_const("ISeq", rb_cISeq); rb_define_singleton_method(rb_cISeq, "load", method_iseq_load, 1); }
void Init_mysql(void) { cMysql = rb_define_class("Mysql", rb_cObject); cMysqlRes = rb_define_class_under(cMysql, "Result", rb_cObject); cMysqlField = rb_define_class_under(cMysql, "Field", rb_cObject); eMysql = rb_define_class_under(cMysql, "Error", rb_eStandardError); rb_define_global_const("MysqlRes", cMysqlRes); rb_define_global_const("MysqlField", cMysqlField); rb_define_global_const("MysqlError", eMysql); /* Mysql class method */ rb_define_singleton_method(cMysql, "init", init, 0); rb_define_singleton_method(cMysql, "real_connect", real_connect, -1); rb_define_singleton_method(cMysql, "connect", real_connect, -1); rb_define_singleton_method(cMysql, "new", real_connect, -1); rb_define_singleton_method(cMysql, "escape_string", escape_string, 1); rb_define_singleton_method(cMysql, "quote", escape_string, 1); rb_define_singleton_method(cMysql, "client_info", client_info, 0); rb_define_singleton_method(cMysql, "get_client_info", client_info, 0); #if MYSQL_VERSION_ID >= 32332 rb_define_singleton_method(cMysql, "debug", my_debug, 1); #endif #if MYSQL_VERSION_ID >= 40000 rb_define_singleton_method(cMysql, "get_client_version", client_version, 0); rb_define_singleton_method(cMysql, "client_version", client_version, 0); #endif /* Mysql object method */ #if MYSQL_VERSION_ID >= 32200 rb_define_method(cMysql, "real_connect", real_connect2, -1); rb_define_method(cMysql, "connect", real_connect2, -1); rb_define_method(cMysql, "options", options, -1); #endif rb_define_method(cMysql, "initialize", initialize, -1); #if MYSQL_VERSION_ID >= 32332 rb_define_method(cMysql, "escape_string", real_escape_string, 1); rb_define_method(cMysql, "quote", real_escape_string, 1); #else rb_define_method(cMysql, "escape_string", escape_string, 1); rb_define_method(cMysql, "quote", escape_string, 1); #endif rb_define_method(cMysql, "client_info", client_info, 0); rb_define_method(cMysql, "get_client_info", client_info, 0); rb_define_method(cMysql, "affected_rows", affected_rows, 0); #if MYSQL_VERSION_ID >= 32303 rb_define_method(cMysql, "change_user", change_user, -1); #endif #if MYSQL_VERSION_ID >= 32321 rb_define_method(cMysql, "character_set_name", character_set_name, 0); #endif rb_define_method(cMysql, "close", my_close, 0); #if MYSQL_VERSION_ID < 40000 rb_define_method(cMysql, "create_db", create_db, 1); rb_define_method(cMysql, "drop_db", drop_db, 1); #endif #if MYSQL_VERSION_ID >= 32332 rb_define_method(cMysql, "dump_debug_info", dump_debug_info, 0); #endif rb_define_method(cMysql, "errno", my_errno, 0); rb_define_method(cMysql, "error", my_error, 0); rb_define_method(cMysql, "field_count", field_count, 0); #if MYSQL_VERSION_ID >= 40000 rb_define_method(cMysql, "get_client_version", client_version, 0); rb_define_method(cMysql, "client_version", client_version, 0); #endif rb_define_method(cMysql, "get_host_info", host_info, 0); rb_define_method(cMysql, "host_info", host_info, 0); rb_define_method(cMysql, "get_proto_info", proto_info, 0); rb_define_method(cMysql, "proto_info", proto_info, 0); rb_define_method(cMysql, "get_server_info", server_info, 0); rb_define_method(cMysql, "server_info", server_info, 0); rb_define_method(cMysql, "info", info, 0); rb_define_method(cMysql, "insert_id", insert_id, 0); rb_define_method(cMysql, "kill", my_kill, 1); rb_define_method(cMysql, "list_dbs", list_dbs, -1); rb_define_method(cMysql, "list_fields", list_fields, -1); rb_define_method(cMysql, "list_processes", list_processes, 0); rb_define_method(cMysql, "list_tables", list_tables, -1); #if MYSQL_VERSION_ID >= 32200 rb_define_method(cMysql, "ping", ping, 0); #endif rb_define_method(cMysql, "query", query, 1); rb_define_method(cMysql, "refresh", refresh, 1); rb_define_method(cMysql, "reload", reload, 0); rb_define_method(cMysql, "select_db", select_db, 1); rb_define_method(cMysql, "shutdown", my_shutdown, -1); rb_define_method(cMysql, "stat", my_stat, 0); rb_define_method(cMysql, "store_result", store_result, 0); rb_define_method(cMysql, "thread_id", thread_id, 0); rb_define_method(cMysql, "use_result", use_result, 0); #if MYSQL_VERSION_ID >= 40100 rb_define_method(cMysql, "get_server_version", server_version, 0); rb_define_method(cMysql, "server_version", server_version, 0); rb_define_method(cMysql, "warning_count", warning_count, 0); rb_define_method(cMysql, "commit", commit, 0); rb_define_method(cMysql, "rollback", rollback, 0); rb_define_method(cMysql, "autocommit", autocommit, 1); #endif #ifdef HAVE_MYSQL_SSL_SET rb_define_method(cMysql, "ssl_set", ssl_set, -1); #endif rb_define_method(cMysql, "query_with_result", query_with_result, 0); rb_define_method(cMysql, "query_with_result=", query_with_result_set, 1); /* Mysql constant */ #if MYSQL_VERSION_ID >= 32200 rb_define_const(cMysql, "OPT_CONNECT_TIMEOUT", INT2NUM(MYSQL_OPT_CONNECT_TIMEOUT)); rb_define_const(cMysql, "OPT_COMPRESS", INT2NUM(MYSQL_OPT_COMPRESS)); rb_define_const(cMysql, "OPT_NAMED_PIPE", INT2NUM(MYSQL_OPT_NAMED_PIPE)); rb_define_const(cMysql, "INIT_COMMAND", INT2NUM(MYSQL_INIT_COMMAND)); rb_define_const(cMysql, "READ_DEFAULT_FILE", INT2NUM(MYSQL_READ_DEFAULT_FILE)); rb_define_const(cMysql, "READ_DEFAULT_GROUP", INT2NUM(MYSQL_READ_DEFAULT_GROUP)); #endif #if MYSQL_VERSION_ID >= 32349 rb_define_const(cMysql, "OPT_LOCAL_INFILE", INT2NUM(MYSQL_OPT_LOCAL_INFILE)); #endif rb_define_const(cMysql, "REFRESH_GRANT", INT2NUM(REFRESH_GRANT)); rb_define_const(cMysql, "REFRESH_LOG", INT2NUM(REFRESH_LOG)); rb_define_const(cMysql, "REFRESH_TABLES", INT2NUM(REFRESH_TABLES)); #ifdef REFRESH_HOSTS rb_define_const(cMysql, "REFRESH_HOSTS", INT2NUM(REFRESH_HOSTS)); #endif #ifdef REFRESH_STATUS rb_define_const(cMysql, "REFRESH_STATUS", INT2NUM(REFRESH_STATUS)); #endif #ifdef REFRESH_THREADS rb_define_const(cMysql, "REFRESH_THREADS", INT2NUM(REFRESH_THREADS)); #endif #ifdef REFRESH_SLAVE rb_define_const(cMysql, "REFRESH_SLAVE", INT2NUM(REFRESH_SLAVE)); #endif #ifdef REFRESH_MASTER rb_define_const(cMysql, "REFRESH_MASTER", INT2NUM(REFRESH_MASTER)); #endif #ifdef CLIENT_LONG_PASSWORD #endif #ifdef CLIENT_FOUND_ROWS rb_define_const(cMysql, "CLIENT_FOUND_ROWS", INT2NUM(CLIENT_FOUND_ROWS)); #endif #ifdef CLIENT_LONG_FLAG #endif #ifdef CLIENT_CONNECT_WITH_DB #endif #ifdef CLIENT_NO_SCHEMA rb_define_const(cMysql, "CLIENT_NO_SCHEMA", INT2NUM(CLIENT_NO_SCHEMA)); #endif #ifdef CLIENT_COMPRESS rb_define_const(cMysql, "CLIENT_COMPRESS", INT2NUM(CLIENT_COMPRESS)); #endif #ifdef CLIENT_ODBC rb_define_const(cMysql, "CLIENT_ODBC", INT2NUM(CLIENT_ODBC)); #endif #ifdef CLIENT_LOCAL_FILES rb_define_const(cMysql, "CLIENT_LOCAL_FILES", INT2NUM(CLIENT_LOCAL_FILES)); #endif #ifdef CLIENT_IGNORE_SPACE rb_define_const(cMysql, "CLIENT_IGNORE_SPACE", INT2NUM(CLIENT_IGNORE_SPACE)); #endif #ifdef CLIENT_CHANGE_USER rb_define_const(cMysql, "CLIENT_CHANGE_USER", INT2NUM(CLIENT_CHANGE_USER)); #endif #ifdef CLIENT_INTERACTIVE rb_define_const(cMysql, "CLIENT_INTERACTIVE", INT2NUM(CLIENT_INTERACTIVE)); #endif #ifdef CLIENT_SSL rb_define_const(cMysql, "CLIENT_SSL", INT2NUM(CLIENT_SSL)); #endif #ifdef CLIENT_IGNORE_SIGPIPE rb_define_const(cMysql, "CLIENT_IGNORE_SIGPIPE", INT2NUM(CLIENT_IGNORE_SIGPIPE)); #endif #ifdef CLIENT_TRANSACTIONS rb_define_const(cMysql, "CLIENT_TRANSACTIONS", INT2NUM(CLIENT_TRANSACTIONS)); #endif /* Mysql::Result object method */ rb_define_method(cMysqlRes, "data_seek", data_seek, 1); rb_define_method(cMysqlRes, "fetch_field", fetch_field, 0); rb_define_method(cMysqlRes, "fetch_fields", fetch_fields, 0); rb_define_method(cMysqlRes, "fetch_field_direct", fetch_field_direct, 1); rb_define_method(cMysqlRes, "fetch_lengths", fetch_lengths, 0); rb_define_method(cMysqlRes, "fetch_row", fetch_row, 0); rb_define_method(cMysqlRes, "fetch_hash", fetch_hash, -1); rb_define_method(cMysqlRes, "field_seek", field_seek, 1); rb_define_method(cMysqlRes, "field_tell", field_tell, 0); rb_define_method(cMysqlRes, "free", res_free, 0); rb_define_method(cMysqlRes, "num_fields", num_fields, 0); rb_define_method(cMysqlRes, "num_rows", num_rows, 0); rb_define_method(cMysqlRes, "row_seek", row_seek, 1); rb_define_method(cMysqlRes, "row_tell", row_tell, 0); rb_define_method(cMysqlRes, "each", each, 0); rb_define_method(cMysqlRes, "each_hash", each_hash, -1); /* MysqlField object method */ rb_define_method(cMysqlField, "name", field_name, 0); rb_define_method(cMysqlField, "table", field_table, 0); rb_define_method(cMysqlField, "def", field_def, 0); rb_define_method(cMysqlField, "type", field_type, 0); rb_define_method(cMysqlField, "length", field_length, 0); rb_define_method(cMysqlField, "max_length", field_max_length, 0); rb_define_method(cMysqlField, "flags", field_flags, 0); rb_define_method(cMysqlField, "decimals", field_decimals, 0); rb_define_method(cMysqlField, "hash", field_hash, 0); rb_define_method(cMysqlField, "inspect", field_inspect, 0); #ifdef IS_NUM rb_define_method(cMysqlField, "is_num?", field_is_num, 0); #endif #ifdef IS_NOT_NULL rb_define_method(cMysqlField, "is_not_null?", field_is_not_null, 0); #endif #ifdef IS_PRI_KEY rb_define_method(cMysqlField, "is_pri_key?", field_is_pri_key, 0); #endif /* Mysql::Field constant: TYPE */ rb_define_const(cMysqlField, "TYPE_TINY", INT2NUM(FIELD_TYPE_TINY)); #if MYSQL_VERSION_ID >= 32115 rb_define_const(cMysqlField, "TYPE_ENUM", INT2NUM(FIELD_TYPE_ENUM)); #endif rb_define_const(cMysqlField, "TYPE_DECIMAL", INT2NUM(FIELD_TYPE_DECIMAL)); rb_define_const(cMysqlField, "TYPE_SHORT", INT2NUM(FIELD_TYPE_SHORT)); rb_define_const(cMysqlField, "TYPE_LONG", INT2NUM(FIELD_TYPE_LONG)); rb_define_const(cMysqlField, "TYPE_FLOAT", INT2NUM(FIELD_TYPE_FLOAT)); rb_define_const(cMysqlField, "TYPE_DOUBLE", INT2NUM(FIELD_TYPE_DOUBLE)); rb_define_const(cMysqlField, "TYPE_NULL", INT2NUM(FIELD_TYPE_NULL)); rb_define_const(cMysqlField, "TYPE_TIMESTAMP", INT2NUM(FIELD_TYPE_TIMESTAMP)); rb_define_const(cMysqlField, "TYPE_LONGLONG", INT2NUM(FIELD_TYPE_LONGLONG)); rb_define_const(cMysqlField, "TYPE_INT24", INT2NUM(FIELD_TYPE_INT24)); rb_define_const(cMysqlField, "TYPE_DATE", INT2NUM(FIELD_TYPE_DATE)); rb_define_const(cMysqlField, "TYPE_TIME", INT2NUM(FIELD_TYPE_TIME)); rb_define_const(cMysqlField, "TYPE_DATETIME", INT2NUM(FIELD_TYPE_DATETIME)); #if MYSQL_VERSION_ID >= 32130 rb_define_const(cMysqlField, "TYPE_YEAR", INT2NUM(FIELD_TYPE_YEAR)); #endif rb_define_const(cMysqlField, "TYPE_SET", INT2NUM(FIELD_TYPE_SET)); rb_define_const(cMysqlField, "TYPE_BLOB", INT2NUM(FIELD_TYPE_BLOB)); rb_define_const(cMysqlField, "TYPE_STRING", INT2NUM(FIELD_TYPE_STRING)); #if MYSQL_VERSION_ID >= 40000 rb_define_const(cMysqlField, "TYPE_VAR_STRING", INT2NUM(FIELD_TYPE_VAR_STRING)); #endif rb_define_const(cMysqlField, "TYPE_CHAR", INT2NUM(FIELD_TYPE_CHAR)); /* Mysql::Field constant: FLAG */ rb_define_const(cMysqlField, "NOT_NULL_FLAG", INT2NUM(NOT_NULL_FLAG)); rb_define_const(cMysqlField, "PRI_KEY_FLAG", INT2NUM(PRI_KEY_FLAG)); rb_define_const(cMysqlField, "UNIQUE_KEY_FLAG", INT2NUM(UNIQUE_KEY_FLAG)); rb_define_const(cMysqlField, "MULTIPLE_KEY_FLAG", INT2NUM(MULTIPLE_KEY_FLAG)); rb_define_const(cMysqlField, "BLOB_FLAG", INT2NUM(BLOB_FLAG)); rb_define_const(cMysqlField, "UNSIGNED_FLAG", INT2NUM(UNSIGNED_FLAG)); rb_define_const(cMysqlField, "ZEROFILL_FLAG", INT2NUM(ZEROFILL_FLAG)); rb_define_const(cMysqlField, "BINARY_FLAG", INT2NUM(BINARY_FLAG)); #ifdef ENUM_FLAG rb_define_const(cMysqlField, "ENUM_FLAG", INT2NUM(ENUM_FLAG)); #endif #ifdef AUTO_INCREMENT_FLAG rb_define_const(cMysqlField, "AUTO_INCREMENT_FLAG", INT2NUM(AUTO_INCREMENT_FLAG)); #endif #ifdef TIMESTAMP_FLAG rb_define_const(cMysqlField, "TIMESTAMP_FLAG", INT2NUM(TIMESTAMP_FLAG)); #endif #ifdef SET_FLAG rb_define_const(cMysqlField, "SET_FLAG", INT2NUM(SET_FLAG)); #endif #ifdef NUM_FLAG rb_define_const(cMysqlField, "NUM_FLAG", INT2NUM(NUM_FLAG)); #endif /* Mysql::Error object method */ rb_define_method(eMysql, "error", error_error, 0); rb_define_method(eMysql, "errno", error_errno, 0); /* Mysql::Error constant */ }
void Init_igraph(){ //Modules VALUE cIGraph_generate; VALUE cIGraph_genrandom; VALUE cIGraph_connectivity; VALUE cIGraph_mincuts; VALUE cIGraph_layout; VALUE cIGraph_clique; VALUE cIGraph_indyver; VALUE cIGraph_isomor; VALUE cIGraph_motifs; VALUE cIGraph_sorting; VALUE cIGraph_filewrite; VALUE cIGraph_fileread; VALUE cIGraph_community; VALUE cIGraph_shortestpaths; VALUE cIGraph_neighborhoodm; VALUE cIGraph_components; VALUE cIGraph_closenessm; VALUE cIGraph_spanning; VALUE cIGraph_transitivitym; VALUE cIGraph_spectral; VALUE cIGraph_kcore; VALUE cIGraph_otherop; VALUE cIGraph_randomise; igraph_i_set_attribute_table(&cIGraph_attribute_table); igraph_set_error_handler(cIGraph_error_handler); igraph_set_warning_handler(cIGraph_warning_handler); cIGraph = rb_define_class("IGraph", rb_cObject); cIGraphError = rb_define_class("IGraphError", rb_eRuntimeError); rb_define_alloc_func(cIGraph, cIGraph_alloc); rb_define_method(cIGraph, "initialize", cIGraph_initialize, -1); rb_define_method(cIGraph, "initialize_copy", cIGraph_init_copy, 1); rb_include_module(cIGraph, rb_mEnumerable); /* Functions for deterministically generating graphs. */ cIGraph_generate = rb_define_module_under(cIGraph, "Generate"); rb_include_module(cIGraph, cIGraph_generate); rb_define_singleton_method(cIGraph_generate, "adjacency", cIGraph_adjacency, 2); /* in cIGraph_generators_deterministic.c */ rb_define_singleton_method(cIGraph_generate, "star", cIGraph_star, 3); /* in cIGraph_generators_deterministic.c */ rb_define_singleton_method(cIGraph_generate, "lattice", cIGraph_lattice, 4); /* in cIGraph_generators_deterministic.c */ rb_define_singleton_method(cIGraph_generate, "ring", cIGraph_ring, 4); /* in cIGraph_generators_deterministic.c */ rb_define_singleton_method(cIGraph_generate, "tree", cIGraph_tree, 3); /* in cIGraph_generators_deterministic.c */ rb_define_singleton_method(cIGraph_generate, "full", cIGraph_full, 3); /* in cIGraph_generators_deterministic.c */ rb_define_singleton_method(cIGraph_generate, "atlas", cIGraph_atlas, 1); /* in cIGraph_generators_deterministic.c */ rb_define_singleton_method(cIGraph_generate, "extended_chordal_ring", cIGraph_extended_chordal_ring, 2); /* in cIGraph_generators_deterministic.c */ /* Functions for randomly generating graphs. */ cIGraph_genrandom = rb_define_module_under(cIGraph, "GenerateRandom"); rb_include_module(cIGraph, cIGraph_genrandom); rb_define_singleton_method(cIGraph_genrandom, "grg_game", cIGraph_grg_game, 3); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "barabasi_game", cIGraph_barabasi_game, 4); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "nonlinear_barabasi_game", cIGraph_nonlinear_barabasi_game, 6); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "erdos_renyi_game", cIGraph_erdos_renyi_game, 5); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "watts_strogatz_game", cIGraph_watts_strogatz_game, 4); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "degree_sequence_game", cIGraph_degree_sequence_game, 2); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "growing_random_game", cIGraph_growing_random_game, 4); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "callaway_traits_game", cIGraph_callaway_traits_game, 6); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "establishment_game", cIGraph_establishment_game, 6); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "preference_game", cIGraph_preference_game, 6); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "asymmetric_preference_game", cIGraph_asymmetric_preference_game, 5); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "recent_degree_game", cIGraph_recent_degree_game, 7); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "barabasi_aging_game", cIGraph_barabasi_aging_game, 11); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "recent_degree_aging_game", cIGraph_recent_degree_aging_game, 9); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "cited_type_game", cIGraph_cited_type_game, 5); /* in cIGraph_generators_random.c */ rb_define_singleton_method(cIGraph_genrandom, "citing_cited_type_game", cIGraph_citing_cited_type_game, 5); /* in cIGraph_generators_random.c */ rb_define_method(cIGraph, "[]", cIGraph_get_edge_attr, 2); /* in cIGraph_attribute_handler.c */ rb_define_method(cIGraph, "[]=", cIGraph_set_edge_attr, 3); /* in cIGraph_attribute_handler.c */ rb_define_alias (cIGraph, "get_edge_attr", "[]"); rb_define_alias (cIGraph, "set_edge_attr", "[]="); rb_define_method(cIGraph, "attributes", cIGraph_graph_attributes, 0); /* in cIGraph_attribute_handler.c */ rb_define_method(cIGraph, "each_vertex", cIGraph_each_vertex, 0); /* in cIGraph_iterators.c */ rb_define_method(cIGraph, "each_edge", cIGraph_each_edge, 1); /* in cIGraph_iterators.c */ rb_define_method(cIGraph, "each_edge_eid", cIGraph_each_edge_eid,1); /* in cIGraph_iterators.c */ rb_define_alias (cIGraph, "each", "each_vertex"); rb_define_method(cIGraph, "vertices", cIGraph_all_v, 0); /* in cIGraph_selectors.c */ rb_define_method(cIGraph, "adjacent_vertices", cIGraph_adj_v, 2); /* in cIGraph_selectors.c */ rb_define_method(cIGraph, "nonadjacent_vertices", cIGraph_nonadj_v, 2); /* in cIGraph_selectors.c */ rb_define_alias (cIGraph, "all_vertices", "vertices"); rb_define_method(cIGraph, "edges", cIGraph_all_e, 1); /* in cIGraph_selectors.c */ rb_define_method(cIGraph, "adjacent_edges", cIGraph_adj_e, 2); /* in cIGraph_selectors.c */ rb_define_alias (cIGraph, "all_edges", "edges"); rb_define_method(cIGraph, "vcount", cIGraph_vcount, 0); /* in cIGraph_basic_query.c */ rb_define_method(cIGraph, "ecount", cIGraph_ecount, 0); /* in cIGraph_basic_query.c */ rb_define_method(cIGraph, "edge", cIGraph_edge, 1); /* in cIGraph_basic_query.c */ rb_define_method(cIGraph, "get_eid", cIGraph_get_eid, 2); /* in cIGraph_basic_query.c */ rb_define_method(cIGraph, "neighbours", cIGraph_neighbors, 2); /* in cIGraph_basic_query.c */ rb_define_method(cIGraph, "adjacent", cIGraph_adjacent, 2); /* in cIGraph_basic_query.c */ rb_define_method(cIGraph, "degree", cIGraph_degree, 3); /* in cIGraph_basic_query.c */ rb_define_method(cIGraph, "is_directed?", cIGraph_is_directed, 0); /* in cIGraph_basic_query.c */ rb_define_alias (cIGraph, "is_directed", "is_directed?"); rb_define_alias (cIGraph, "neighbors", "neighbours"); rb_define_method(cIGraph, "add_edges", cIGraph_add_edges, -1); /* in cIGraph_add_delete.c */ rb_define_method(cIGraph, "add_vertices", cIGraph_add_vertices, 1); /* in cIGraph_add_delete.c */ rb_define_method(cIGraph, "add_edge", cIGraph_add_edge, -1); /* in cIGraph_add_delete.c */ rb_define_method(cIGraph, "add_vertex", cIGraph_add_vertex, 1); /* in cIGraph_add_delete.c */ rb_define_method(cIGraph, "delete_edge", cIGraph_delete_edge, 2); /* in cIGraph_add_delete.c */ rb_define_method(cIGraph, "delete_vertex", cIGraph_delete_vertex, 1); /* in cIGraph_add_delete.c */ rb_define_method(cIGraph, "are_connected", cIGraph_are_connected,2); /* in cIGraph_basic_properties.c */ rb_define_alias (cIGraph, "are_connected?", "are_connected"); rb_define_method(cIGraph, "to_directed", cIGraph_to_directed, 1); /* in cIGraph_direction.c */ rb_define_method(cIGraph, "to_undirected", cIGraph_to_undirected, 1); /* in cIGraph_direction.c */ /* These methods randomise a graph by rewiring the edges. */ cIGraph_randomise = rb_define_module_under(cIGraph, "Randomise"); rb_include_module(cIGraph, cIGraph_randomise); rb_define_method(cIGraph_randomise, "rewire_edges", cIGraph_rewire_edges, 1); /* in cIGraph_randomisation.c */ rb_define_method(cIGraph_randomise, "rewire", cIGraph_rewire, 1); /* in cIGraph_randomisation.c */ /* Functions for calculating the shortest path through a graph */ cIGraph_shortestpaths = rb_define_module_under(cIGraph, "ShortestPaths"); rb_include_module(cIGraph, cIGraph_shortestpaths); rb_define_method(cIGraph_shortestpaths, "shortest_paths", cIGraph_shortest_paths, 2); /* in cIGraph_shortest_paths.c */ rb_define_method(cIGraph_shortestpaths, "get_shortest_paths", cIGraph_get_shortest_paths, 3); /* in cIGraph_shortest_paths.c */ rb_define_method(cIGraph_shortestpaths, "get_all_shortest_paths", cIGraph_get_all_shortest_paths, 3); /* in cIGraph_shortest_paths.c */ rb_define_method(cIGraph_shortestpaths, "average_path_length", cIGraph_average_path_length, 2); /* in cIGraph_shortest_paths.c */ rb_define_method(cIGraph_shortestpaths, "diameter", cIGraph_diameter, 2); /* in cIGraph_shortest_paths.c */ rb_define_method(cIGraph_shortestpaths, "girth", cIGraph_girth, 0); /* in cIGraph_shortest_paths.c */ rb_define_method(cIGraph_shortestpaths, "dijkstra_shortest_paths", cIGraph_dijkstra_shortest_paths, 3); /* in cIGraph_dijkstra.c */ /* Functions for querying the neighborhood of vertices */ cIGraph_neighborhoodm = rb_define_module_under(cIGraph, "Neighborhood"); rb_include_module(cIGraph, cIGraph_neighborhoodm); rb_define_method(cIGraph_neighborhoodm, "neighbourhood_size", cIGraph_neighborhood_size, 3); /* in cIGraph_vertex_neighbourhood.c */ rb_define_method(cIGraph_neighborhoodm, "neighbourhood", cIGraph_neighborhood, 3); /* in cIGraph_vertex_neighbourhood.c */ rb_define_method(cIGraph_neighborhoodm, "neighbourhood_graphs", cIGraph_neighborhood_graphs, 3); /* in cIGraph_vertex_neighbourhood.c */ rb_define_alias (cIGraph_neighborhoodm, "neighborhood_size", "neighbourhood_size"); rb_define_alias (cIGraph_neighborhoodm, "neighborhood", "neighbourhood"); rb_define_alias (cIGraph_neighborhoodm, "neighborhood_graphs", "neighbourhood_graphs"); rb_define_method(cIGraph_neighborhoodm, "connect_neighborhood", cIGraph_connect_neighborhood, 2); /* in cIGraph_generators_deterministic.c */ /* Functions for splitting the graph into components */ cIGraph_components = rb_define_module_under(cIGraph, "Components"); rb_include_module(cIGraph, cIGraph_components); rb_define_method(cIGraph_components, "subcomponent", cIGraph_subcomponent, 2); /* in cIGraph_components.c */ rb_define_method(cIGraph_components, "subgraph", cIGraph_subgraph, 1); /* in cIGraph_components.c */ rb_define_method(cIGraph_components, "clusters", cIGraph_clusters, 1); /* in cIGraph_components.c */ rb_define_method(cIGraph_components, "decompose", cIGraph_decompose, -1); /* in cIGraph_components.c */ /* Graph centrality functions */ cIGraph_closenessm = rb_define_module_under(cIGraph, "Closeness"); rb_include_module(cIGraph, cIGraph_closenessm); rb_define_method(cIGraph_closenessm, "closeness", cIGraph_closeness, 2); /* in cIGraph_centrality.c */ rb_define_method(cIGraph_closenessm, "betweenness", cIGraph_betweenness, 2); /* in cIGraph_centrality.c */ rb_define_method(cIGraph_closenessm, "edge_betweenness", cIGraph_edge_betweenness, 1); /* in cIGraph_centrality.c */ rb_define_method(cIGraph_closenessm, "pagerank", cIGraph_pagerank, 5); /* in cIGraph_centrality.c */ rb_define_method(cIGraph_closenessm, "constraint", cIGraph_constraint, -1); /* in cIGraph_centrality.c */ rb_define_method(cIGraph_closenessm, "maxdegree", cIGraph_maxdegree, 3); /* in cIGraph_centrality.c */ /* Minimum spanning tree functions */ cIGraph_spanning = rb_define_module_under(cIGraph, "Spanning"); rb_include_module(cIGraph, cIGraph_spanning); rb_define_method(cIGraph_spanning, "minimum_spanning_tree_unweighted", cIGraph_minimum_spanning_tree_unweighted, 0); /* in cIGraph_spanning.c */ rb_define_method(cIGraph_spanning, "minimum_spanning_tree_prim", cIGraph_minimum_spanning_tree_prim, 1); /* in cIGraph_spanning.c */ /* Graph transitivity functions */ cIGraph_transitivitym = rb_define_module_under(cIGraph, "Transitivity"); rb_include_module(cIGraph, cIGraph_transitivitym); rb_define_method(cIGraph_transitivitym, "transitivity", cIGraph_transitivity, 0); /* in cIGraph_transitivity.c */ rb_define_method(cIGraph_transitivitym, "transitivity_local", cIGraph_transitivity_local, 1); /* in cIGraph_transitivity.c */ rb_define_method(cIGraph_transitivitym, "transitivity_avglocal", cIGraph_transitivity_avglocal, 0); /* in cIGraph_transitivity.c */ /* Functions for the Laplacian matrix. */ cIGraph_spectral = rb_define_module_under(cIGraph, "Spectral"); rb_include_module(cIGraph, cIGraph_spectral); rb_define_method(cIGraph_spectral, "laplacian", cIGraph_laplacian, 1); /* in cIGraph_spectral.c */ /* Functions for finding the coreness of a graph */ cIGraph_kcore = rb_define_module_under(cIGraph, "KCores"); rb_include_module(cIGraph, cIGraph_kcore); rb_define_method(cIGraph_kcore, "coreness", cIGraph_coreness, 1); /* in cIGraph_kcores.c */ /* Other general graph operations */ cIGraph_otherop = rb_define_module_under(cIGraph, "OtherOperations"); rb_include_module(cIGraph, cIGraph_otherop); rb_define_method(cIGraph_otherop, "density", cIGraph_density, 1); /* in cIGraph_other_ops.c */ rb_define_method(cIGraph_otherop, "simplify", cIGraph_simplify, 2); /* in cIGraph_other_ops.c */ rb_define_method(cIGraph_otherop, "reciprocity", cIGraph_reciprocity, 1); /* in cIGraph_other_ops.c */ rb_define_method(cIGraph_otherop, "bibcoupling", cIGraph_bibcoupling, 1); /* in cIGraph_other_ops.c */ rb_define_method(cIGraph_otherop, "cocitation", cIGraph_cocitation, 1); /* in cIGraph_other_ops.c */ rb_define_method(cIGraph_otherop, "get_adjacency", cIGraph_get_adjacency, 1); /* in cIGraph_other_ops.c */ /* Clique finding functions */ cIGraph_clique = rb_define_module_under(cIGraph, "Cliques"); rb_include_module(cIGraph, cIGraph_clique); rb_define_method(cIGraph_clique, "cliques", cIGraph_cliques, 2); /* in cIGraph_cliques.c */ rb_define_method(cIGraph_clique, "largest_cliques", cIGraph_largest_cliques, 0); /* in cIGraph_cliques.c */ rb_define_method(cIGraph_clique, "maximal_cliques", cIGraph_maximal_cliques, 0); /* in cIGraph_cliques.c */ rb_define_method(cIGraph_clique, "clique_number", cIGraph_clique_number, 0); /* in cIGraph_cliques.c */ /* Independent vertex set finding functions */ cIGraph_indyver = rb_define_module_under(cIGraph, "IndependentVertexSets"); rb_include_module(cIGraph, cIGraph_indyver); rb_define_method(cIGraph_indyver, "independent_vertex_sets", cIGraph_independent_vertex_sets, 2); /* in cIGraph_independent_vertex_sets.c */ rb_define_method(cIGraph_indyver, "largest_independent_vertex_sets", cIGraph_largest_independent_vertex_sets, 0); /* in cIGraph_independent_vertex_sets.c */ rb_define_method(cIGraph_indyver, "maximal_independent_vertex_sets", cIGraph_maximal_independent_vertex_sets, 0); /* in cIGraph_independent_vertex_sets.c */ rb_define_method(cIGraph_indyver, "independence_number", cIGraph_independence_number, 0); /* in cIGraph_independent_vertex_sets.c */ /* Functions for isomorphism and isoclasses */ cIGraph_isomor = rb_define_module_under(cIGraph, "Isomorphism"); rb_include_module(cIGraph, cIGraph_isomor); rb_define_method(cIGraph_isomor, "isomorphic", cIGraph_isomorphic, 1); /* in cIGraph_isomorphism.c */ rb_define_method(cIGraph_isomor, "isomorphic_vf2", cIGraph_isomorphic_vf2, 1); /* in cIGraph_isomorphism.c */ rb_define_method(cIGraph_isomor, "isoclass", cIGraph_isoclass, 0); /* in cIGraph_isomorphism.c */ rb_define_method(cIGraph_isomor, "isoclass_subgraph", cIGraph_isoclass_subgraph, 1); /* in cIGraph_isomorphism.c */ rb_define_singleton_method(cIGraph_generate, "isoclass_create", cIGraph_isoclass_create, 3); /* in cIGraph_isomorphism.c */ /* Motif finding functions */ cIGraph_motifs = rb_define_module_under(cIGraph, "Motifs"); rb_include_module(cIGraph, cIGraph_motifs); rb_define_method(cIGraph_motifs, "motifs_randesu", cIGraph_motifs_randesu, 2); /* in cIGraph_motif.c */ rb_define_method(cIGraph_motifs, "motifs_randesu_no", cIGraph_motifs_randesu_no, 2); /* in cIGraph_motif.c */ rb_define_method(cIGraph_motifs, "motifs_randesu_estimate", cIGraph_motifs_randesu_estimate, 4); /* in cIGraph_motif.c */ /* Graph sorting functions. */ cIGraph_sorting = rb_define_module_under(cIGraph, "Sorting"); rb_include_module(cIGraph, cIGraph_sorting); rb_define_method(cIGraph_sorting, "topological_sorting", cIGraph_topological_sorting, 1); /* in cIGraph_topological_sort.c */ /* Functions for reading graphs from files */ cIGraph_fileread = rb_define_module_under(cIGraph, "FileRead"); rb_include_module(cIGraph, cIGraph_fileread); #ifdef __APPLE__ rb_define_singleton_method(cIGraph_fileread, "read_graph_edgelist", cIGraph_unavailable_method, -1); rb_define_singleton_method(cIGraph_fileread, "read_graph_graphml", cIGraph_unavailable_method, -1); rb_define_singleton_method(cIGraph_fileread, "read_graph_ncol", cIGraph_unavailable_method, -1); rb_define_singleton_method(cIGraph_fileread, "read_graph_lgl", cIGraph_unavailable_method, -1); rb_define_singleton_method(cIGraph_fileread, "read_graph_dimacs", cIGraph_unavailable_method, -1); rb_define_singleton_method(cIGraph_fileread, "read_graph_graphdb", cIGraph_unavailable_method, -1); rb_define_singleton_method(cIGraph_fileread, "read_graph_gml", cIGraph_unavailable_method, -1); rb_define_singleton_method(cIGraph_fileread, "read_graph_pajek", cIGraph_unavailable_method, -1); #else rb_define_singleton_method(cIGraph_fileread, "read_graph_edgelist", cIGraph_read_graph_edgelist, 2); /* in cIGraph_file.c */ rb_define_singleton_method(cIGraph_fileread, "read_graph_graphml", cIGraph_read_graph_graphml, 2); /* in cIGraph_file.c */ rb_define_singleton_method(cIGraph_fileread, "read_graph_ncol", cIGraph_read_graph_ncol, 5); /* in cIGraph_file.c */ rb_define_singleton_method(cIGraph_fileread, "read_graph_lgl", cIGraph_read_graph_lgl, 3); /* in cIGraph_file.c */ rb_define_singleton_method(cIGraph_fileread, "read_graph_dimacs", cIGraph_read_graph_dimacs, 2); /* in cIGraph_file.c */ rb_define_singleton_method(cIGraph_fileread, "read_graph_graphdb", cIGraph_read_graph_graphdb, 2); /* in cIGraph_file.c */ rb_define_singleton_method(cIGraph_fileread, "read_graph_gml", cIGraph_read_graph_gml, 1); /* in cIGraph_file.c */ rb_define_singleton_method(cIGraph_fileread, "read_graph_pajek", cIGraph_read_graph_pajek, 2); /* in cIGraph_file.c */ #endif /* Functions for writing graphs to files */ cIGraph_filewrite = rb_define_module_under(cIGraph, "FileWrite"); rb_include_module(cIGraph, cIGraph_filewrite); #ifdef __APPLE__ rb_define_method(cIGraph_filewrite, "write_graph_edgelist", cIGraph_unavailable_method, -1); rb_define_method(cIGraph_filewrite, "write_graph_graphml", cIGraph_unavailable_method, -1); rb_define_method(cIGraph_filewrite, "write_graph_gml", cIGraph_unavailable_method, -1); rb_define_method(cIGraph_filewrite, "write_graph_ncol", cIGraph_unavailable_method, -1); rb_define_method(cIGraph_filewrite, "write_graph_lgl", cIGraph_unavailable_method, -1); rb_define_method(cIGraph_filewrite, "write_graph_dimacs", cIGraph_unavailable_method, -1); rb_define_method(cIGraph_filewrite, "write_graph_pajek", cIGraph_unavailable_method, -1); #else rb_define_method(cIGraph_filewrite, "write_graph_edgelist", cIGraph_write_graph_edgelist, 1); /* in cIGraph_file.c */ rb_define_method(cIGraph_filewrite, "write_graph_graphml", cIGraph_write_graph_graphml, 1); /* in cIGraph_file.c */ rb_define_method(cIGraph_filewrite, "write_graph_gml", cIGraph_write_graph_gml, 1); /* in cIGraph_file.c */ rb_define_method(cIGraph_filewrite, "write_graph_ncol", cIGraph_write_graph_ncol, 3); /* in cIGraph_file.c */ rb_define_method(cIGraph_filewrite, "write_graph_lgl", cIGraph_write_graph_lgl, 4); /* in cIGraph_file.c */ rb_define_method(cIGraph_filewrite, "write_graph_dimacs", cIGraph_write_graph_dimacs, 4); /* in cIGraph_file.c */ rb_define_method(cIGraph_filewrite, "write_graph_pajek", cIGraph_write_graph_pajek, 1); /* in cIGraph_file.c */ #endif /* Graph layout functions */ cIGraph_layout = rb_define_module_under(cIGraph, "Layout"); rb_include_module(cIGraph, cIGraph_layout); rb_define_method(cIGraph_layout, "layout_random", cIGraph_layout_random, 0); /* in cIGraph_layout.c */ rb_define_method(cIGraph_layout, "layout_circle", cIGraph_layout_circle, 0); /* in cIGraph_layout.c */ rb_define_method(cIGraph_layout, "layout_fruchterman_reingold", cIGraph_layout_fruchterman_reingold, 6); /* in cIGraph_layout.c */ rb_define_method(cIGraph_layout, "layout_kamada_kawai", cIGraph_layout_kamada_kawai, 5); /* in cIGraph_layout.c */ rb_define_method(cIGraph_layout, "layout_reingold_tilford", cIGraph_layout_reingold_tilford, 1); /* in cIGraph_layout.c */ rb_define_method(cIGraph_layout, "layout_reingold_tilford_circular", cIGraph_layout_reingold_tilford_circular, 1); /* in cIGraph_layout.c */ rb_define_method(cIGraph_layout, "layout_grid_fruchterman_reingold", cIGraph_layout_grid_fruchterman_reingold, 7); /* in cIGraph_layout.c */ rb_define_method(cIGraph_layout, "layout_lgl", cIGraph_layout_lgl, 7); /* in cIGraph_layout.c */ rb_define_method(cIGraph_layout, "layout_random_3d", cIGraph_layout_random_3d, 0); /* in cIGraph_layout3d.c */ rb_define_method(cIGraph_layout, "layout_sphere", cIGraph_layout_sphere, 0); /* in cIGraph_layout3d.c */ rb_define_method(cIGraph_layout, "layout_fruchterman_reingold_3d", cIGraph_layout_fruchterman_reingold_3d, 5); /* in cIGraph_layout3d.c */ rb_define_method(cIGraph_layout, "layout_kamada_kawai_3d", cIGraph_layout_kamada_kawai_3d, 5); /* in cIGraph_layout3d.c */ rb_define_singleton_method(cIGraph_layout, "layout_merge_dla", cIGraph_layout_merge_dla, 2); /* in cIGraph_layout.c */ /* Minimum cuts related functions */ cIGraph_mincuts = rb_define_module_under(cIGraph, "MinimumCuts"); rb_include_module(cIGraph, cIGraph_mincuts); rb_define_method(cIGraph_mincuts, "maxflow_value", cIGraph_maxflow_value, 3); /* in cIGraph_min_cuts.c */ rb_define_method(cIGraph_mincuts, "st_mincut_value", cIGraph_st_mincut_value, 3); /* in cIGraph_min_cuts.c */ rb_define_method(cIGraph_mincuts, "mincut_value", cIGraph_mincut_value, 1); /* in cIGraph_min_cuts.c */ rb_define_method(cIGraph_mincuts, "mincut", cIGraph_mincut, 1); /* in cIGraph_min_cuts.c */ /* Vertex and edge connectivity functions */ cIGraph_connectivity = rb_define_module_under(cIGraph, "Connectivity"); rb_include_module(cIGraph, cIGraph_connectivity); rb_define_method(cIGraph_connectivity, "st_edge_connectivity", cIGraph_st_edge_connectivity, 2); /* in cIGraph_connectivity.c */ rb_define_method(cIGraph_connectivity, "edge_connectivity", cIGraph_edge_connectivity, 0); /* in cIGraph_connectivity.c */ rb_define_method(cIGraph_connectivity, "st_vertex_connectivity", cIGraph_st_vertex_connectivity, 3); /* in cIGraph_connectivity.c */ rb_define_method(cIGraph_connectivity, "vertex_connectivity", cIGraph_vertex_connectivity, 0); /* in cIGraph_connectivity.c */ rb_define_method(cIGraph_connectivity, "edge_disjoint_paths", cIGraph_edge_disjoint_paths, 2); /* in cIGraph_connectivity.c */ rb_define_method(cIGraph_connectivity, "vertex_disjoint_paths", cIGraph_vertex_disjoint_paths, 2); /* in cIGraph_connectivity.c */ rb_define_method(cIGraph_connectivity, "adhesion", cIGraph_adhesion, 0); /* in cIGraph_connectivity.c */ rb_define_method(cIGraph_connectivity, "cohesion", cIGraph_cohesion, 0); /* in cIGraph_connectivity.c */ /* Community and modularity related functions */ cIGraph_community = rb_define_module_under(cIGraph, "Community"); rb_include_module(cIGraph, cIGraph_community); rb_define_method(cIGraph_community, "modularity", cIGraph_modularity, 1); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_to_membership", cIGraph_community_to_membership, 3); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_spinglass", cIGraph_community_spinglass, 8); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_spinglass_single", cIGraph_community_spinglass_single, 5); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_leading_eigenvector", cIGraph_community_leading_eigenvector, 1); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_leading_eigenvector_naive", cIGraph_community_leading_eigenvector_naive, 1); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_leading_eigenvector_step", cIGraph_community_leading_eigenvector_step, 2); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_walktrap", cIGraph_community_walktrap, 2); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_edge_betweenness", cIGraph_community_edge_betweenness, 1); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_eb_get_merges", cIGraph_community_eb_get_merges, 1); /* in cIGraph_community.c */ rb_define_method(cIGraph_community, "community_fastgreedy", cIGraph_community_fastgreedy, 0); /* in cIGraph_community.c */ rb_define_const(cIGraph, "VERSION", rb_str_new2("0.9.1")); rb_define_const(cIGraph, "EDGEORDER_ID", INT2NUM(1)); rb_define_const(cIGraph, "EDGEORDER_FROM", INT2NUM(2)); rb_define_const(cIGraph, "EDGEORDER_TO", INT2NUM(3)); rb_define_const(cIGraph, "OUT", INT2NUM(1)); rb_define_const(cIGraph, "IN", INT2NUM(2)); rb_define_const(cIGraph, "ALL", INT2NUM(3)); rb_define_const(cIGraph, "TOTAL", INT2NUM(4)); rb_define_const(cIGraph_components, "WEAK", INT2NUM(1)); rb_define_const(cIGraph_components, "STRONG", INT2NUM(2)); rb_define_const(cIGraph, "ARBITRARY", INT2NUM(0)); rb_define_const(cIGraph, "MUTUAL", INT2NUM(1)); rb_define_const(cIGraph, "EACH", INT2NUM(0)); rb_define_const(cIGraph, "COLLAPSE", INT2NUM(1)); rb_define_const(cIGraph_otherop, "GET_ADJACENCY_UPPER", INT2NUM(0)); rb_define_const(cIGraph_otherop, "GET_ADJACENCY_LOWER", INT2NUM(1)); rb_define_const(cIGraph_otherop, "GET_ADJACENCY_BOTH", INT2NUM(2)); rb_define_const(cIGraph, "ERDOS_RENYI_GNP", INT2NUM(0)); rb_define_const(cIGraph, "ERDOS_RENYI_GNM", INT2NUM(1)); rb_define_const(cIGraph_generate, "ADJ_DIRECTED", INT2NUM(0)); rb_define_const(cIGraph_generate, "ADJ_UNDIRECTED", INT2NUM(1)); rb_define_const(cIGraph_generate, "ADJ_MAX", INT2NUM(2)); rb_define_const(cIGraph_generate, "ADJ_MIN", INT2NUM(3)); rb_define_const(cIGraph_generate, "ADJ_PLUS", INT2NUM(4)); rb_define_const(cIGraph_generate, "ADJ_UPPER", INT2NUM(5)); rb_define_const(cIGraph_generate, "ADJ_LOWER", INT2NUM(6)); rb_define_const(cIGraph_generate, "STAR_OUT", INT2NUM(0)); rb_define_const(cIGraph_generate, "STAR_IN", INT2NUM(1)); rb_define_const(cIGraph_generate, "STAR_UNDIRECTED", INT2NUM(2)); rb_define_const(cIGraph_generate, "TREE_OUT", INT2NUM(0)); rb_define_const(cIGraph_generate, "TREE_IN", INT2NUM(1)); rb_define_const(cIGraph_generate, "TREE_UNDIRECTED", INT2NUM(2)); rb_define_const(cIGraph_connectivity, "VCONN_NEI_ERROR", INT2NUM(0)); rb_define_const(cIGraph_connectivity, "VCONN_NEI_INFINITY", INT2NUM(1)); rb_define_const(cIGraph_connectivity, "VCONN_NEI_IGNORE", INT2NUM(2)); rb_define_const(cIGraph_community, "SPINCOMM_UPDATE_SIMPLE", INT2NUM(0)); rb_define_const(cIGraph_community, "SPINCOMM_UPDATE_CONFIG", INT2NUM(1)); /* This class wraps the igraph matrix type. It can be created from and * converted to an Array of Ruby Arrays. */ cIGraphMatrix = rb_define_class("IGraphMatrix", rb_cObject); rb_define_alloc_func(cIGraphMatrix, cIGraph_matrix_alloc); rb_define_method(cIGraphMatrix, "initialize", cIGraph_matrix_initialize, -1); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "initialize_copy", cIGraph_matrix_init_copy, 1); /* in cIGraph_matrix.c */ //rb_define_singleton_method(cIGraphMatrix, "[]", cIGraph_matrix_initialize, -1); rb_include_module(cIGraphMatrix, rb_mEnumerable); rb_define_method (cIGraphMatrix, "each", cIGraph_matrix_each,0); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "[]", cIGraph_matrix_get, 2); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "[]=", cIGraph_matrix_set, 3); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "size", cIGraph_matrix_size, 0); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "nrow", cIGraph_matrix_nrow, 0); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "ncol", cIGraph_matrix_ncol, 0); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "max", cIGraph_matrix_max, 0); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "*", cIGraph_matrix_scale, 1); /* in cIGraph_matrix.c */ rb_define_method(cIGraphMatrix, "to_a", cIGraph_matrix_toa, 0); /* in cIGraph_matrix.c */ }
void Init_Exception(void) { rb_eException = rb_define_class("Exception", rb_cObject); rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1); rb_define_method(rb_eException, "exception", exc_exception, -1); rb_define_method(rb_eException, "initialize", exc_initialize, -1); rb_define_method(rb_eException, "==", exc_equal, 1); rb_define_method(rb_eException, "to_s", exc_to_s, 0); rb_define_method(rb_eException, "message", exc_message, 0); rb_define_method(rb_eException, "inspect", exc_inspect, 0); rb_define_method(rb_eException, "backtrace", exc_backtrace, 0); rb_define_method(rb_eException, "backtrace_locations", exc_backtrace_locations, 0); rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1); rb_define_method(rb_eException, "cause", exc_cause, 0); rb_eSystemExit = rb_define_class("SystemExit", rb_eException); rb_define_method(rb_eSystemExit, "initialize", exit_initialize, -1); rb_define_method(rb_eSystemExit, "status", exit_status, 0); rb_define_method(rb_eSystemExit, "success?", exit_success_p, 0); rb_eFatal = rb_define_class("fatal", rb_eException); rb_eSignal = rb_define_class("SignalException", rb_eException); rb_eInterrupt = rb_define_class("Interrupt", rb_eSignal); rb_eStandardError = rb_define_class("StandardError", rb_eException); rb_eTypeError = rb_define_class("TypeError", rb_eStandardError); rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError); rb_eIndexError = rb_define_class("IndexError", rb_eStandardError); rb_eKeyError = rb_define_class("KeyError", rb_eIndexError); rb_eRangeError = rb_define_class("RangeError", rb_eStandardError); rb_eScriptError = rb_define_class("ScriptError", rb_eException); rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError); rb_eLoadError = rb_define_class("LoadError", rb_eScriptError); /* the path failed to load */ rb_attr(rb_eLoadError, rb_intern_const("path"), 1, 0, Qfalse); rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError); rb_eNameError = rb_define_class("NameError", rb_eStandardError); rb_define_method(rb_eNameError, "initialize", name_err_initialize, -1); rb_define_method(rb_eNameError, "name", name_err_name, 0); rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData); rb_define_singleton_method(rb_cNameErrorMesg, "!", rb_name_err_mesg_new, NAME_ERR_MESG_COUNT); rb_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1); rb_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0); rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_dump, 1); rb_define_singleton_method(rb_cNameErrorMesg, "_load", name_err_mesg_load, 1); rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError); rb_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1); rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0); rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError); rb_eSecurityError = rb_define_class("SecurityError", rb_eException); rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException); rb_eEncodingError = rb_define_class("EncodingError", rb_eStandardError); rb_eEncCompatError = rb_define_class_under(rb_cEncoding, "CompatibilityError", rb_eEncodingError); syserr_tbl = st_init_numtable(); rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError); rb_define_method(rb_eSystemCallError, "initialize", syserr_initialize, -1); rb_define_method(rb_eSystemCallError, "errno", syserr_errno, 0); rb_define_singleton_method(rb_eSystemCallError, "===", syserr_eqq, 1); rb_mErrno = rb_define_module("Errno"); rb_define_global_function("warn", rb_warn_m, -1); }
void Init_libsvm_ext() { mLibsvm = rb_define_module("Libsvm"); /* Libsvm::Problem */ cProblem = rb_define_class_under(mLibsvm, "Problem", rb_cObject); rb_define_alloc_func(cProblem, problem_alloc); rx_reg_accessor(cProblem, l); rb_define_method(cProblem, "set_examples", cProblem_examples_set, 2); rb_define_method(cProblem, "examples", cProblem_examples, 0); /* Libsvm::SvmParameter */ cSvmParameter = rb_define_class_under(mLibsvm, "SvmParameter", rb_cObject); rb_define_alloc_func(cSvmParameter, parameter_alloc); rx_reg_accessor(cSvmParameter,svm_type); rx_reg_accessor(cSvmParameter,kernel_type); rx_reg_accessor(cSvmParameter,degree); rx_reg_accessor(cSvmParameter,gamma); rx_reg_accessor(cSvmParameter,coef0); rx_reg_accessor(cSvmParameter,cache_size); rx_reg_accessor(cSvmParameter,eps); rx_reg_accessor_as(cSvmParameter,C,c); rb_define_method(cSvmParameter,"label_weights=",cSvmParameter_label_weights_set,1); rb_define_method(cSvmParameter,"label_weights",cSvmParameter_label_weights,0); rx_reg_accessor(cSvmParameter,nu); rx_reg_accessor(cSvmParameter,p); rx_reg_accessor(cSvmParameter,shrinking); rx_reg_accessor(cSvmParameter,probability); /* Libsvm::Node */ cNode = rb_define_class_under(mLibsvm, "Node", rb_cObject); rb_define_alloc_func(cNode, node_alloc); rx_reg_accessor(cNode,index); rx_reg_accessor(cNode,value); /* Libsvm::Model */ cModel = rb_define_class_under(mLibsvm, "Model", rb_cObject); // model_alloc not necessary, since we don't ever create, only wrap it. rb_define_singleton_method(cModel, "train", cModel_class_train, 2); rb_define_singleton_method(cModel, "cross_validation", cModel_class_cross_validation, 3); rb_define_singleton_method(cModel, "load", cModel_class_load, 1); rb_define_method(cModel, "save", cModel_save, 1); rb_define_method(cModel, "svm_type", cModel_svm_type, 0); rb_define_method(cModel, "classes", cModel_classes, 0); rb_define_method(cModel, "predict", cModel_predict, 1); /* Not covered, for various reasons: TODO - void svm_get_labels(const struct svm_model *model, int *label); SVR? - double svm_get_svr_probability(const struct svm_model *model); SVR? - double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates); Model holds reference to this, so when to use it? void svm_destroy_param(struct svm_parameter *param); SVR? - int svm_check_probability_model(const struct svm_model *model); */ mKernelType = rb_define_module_under(mLibsvm, "KernelType"); rb_define_const(mKernelType, "LINEAR", INT2NUM(LINEAR)); rb_define_const(mKernelType, "POLY", INT2NUM(POLY)); rb_define_const(mKernelType, "RBF", INT2NUM(RBF)); rb_define_const(mKernelType, "SIGMOID", INT2NUM(SIGMOID)); rb_define_const(mKernelType, "PRECOMPUTED", INT2NUM(PRECOMPUTED)); mSvmType = rb_define_module_under(mLibsvm,"SvmType"); rb_define_const(mSvmType, "C_SVC", INT2NUM(C_SVC)); rb_define_const(mSvmType, "NU_SVC", INT2NUM(NU_SVC)); rb_define_const(mSvmType, "ONE_CLASS", INT2NUM(ONE_CLASS)); rb_define_const(mSvmType, "EPSILON_SVR", INT2NUM(EPSILON_SVR)); rb_define_const(mSvmType, "NU_SVR", INT2NUM(NU_SVR)); }
void Init_uuiddqd() { Uuiddqd = rb_define_module("Uuiddqd"); rb_define_singleton_method(Uuiddqd, "generate", method_generate, 0); }
/*! * Defines a module function for \a module. * \param module an module or a class. * \param name name of the function * \param func the method body * \param argc the number of parameters, or -1 or -2. see \ref defmethod. */ void rb_define_module_function(VALUE module, const char *name, VALUE (*func)(ANYARGS), int argc) { rb_define_private_method(module, name, func, argc); rb_define_singleton_method(module, name, func, argc); }
void Init_ossl_ocsp(void) { /* * OpenSSL::OCSP implements Online Certificate Status Protocol requests * and responses. * * Creating and sending an OCSP request requires a subject certificate * that contains an OCSP URL in an authorityInfoAccess extension and the * issuer certificate for the subject certificate. First, load the issuer * and subject certificates: * * subject = OpenSSL::X509::Certificate.new subject_pem * issuer = OpenSSL::X509::Certificate.new issuer_pem * * To create the request we need to create a certificate ID for the * subject certificate so the CA knows which certificate we are asking * about: * * digest = OpenSSL::Digest::SHA1.new * certificate_id = * OpenSSL::OCSP::CertificateId.new subject, issuer, digest * * Then create a request and add the certificate ID to it: * * request = OpenSSL::OCSP::Request.new * request.add_certid certificate_id * * Adding a nonce to the request protects against replay attacks but not * all CA process the nonce. * * request.add_nonce * * To submit the request to the CA for verification we need to extract the * OCSP URI from the subject certificate: * * authority_info_access = subject.extensions.find do |extension| * extension.oid == 'authorityInfoAccess' * end * * descriptions = authority_info_access.value.split "\n" * ocsp = descriptions.find do |description| * description.start_with? 'OCSP' * end * * require 'uri' * * ocsp_uri = URI ocsp[/URI:(.*)/, 1] * * To submit the request we'll POST the request to the OCSP URI (per RFC * 2560). Note that we only handle HTTP requests and don't handle any * redirects in this example, so this is insufficient for serious use. * * require 'net/http' * * http_response = * Net::HTTP.start ocsp_uri.hostname, ocsp.port do |http| * http.post ocsp_uri.path, request.to_der, * 'content-type' => 'application/ocsp-request' * end * * response = OpenSSL::OCSP::Response.new http_response.body * response_basic = response.basic * * First we check if the response has a valid signature. Without a valid * signature we cannot trust it. If you get a failure here you may be * missing a system certificate store or may be missing the intermediate * certificates. * * store = OpenSSL::X509::Store.new * store.set_default_paths * * unless response.verify [], store then * raise 'response is not signed by a trusted certificate' * end * * The response contains the status information (success/fail). We can * display the status as a string: * * puts response.status_string #=> successful * * Next we need to know the response details to determine if the response * matches our request. First we check the nonce. Again, not all CAs * support a nonce. See Request#check_nonce for the meanings of the * return values. * * p request.check_nonce basic_response #=> value from -1 to 3 * * Then extract the status information from the basic response. (You can * check multiple certificates in a request, but for this example we only * submitted one.) * * response_certificate_id, status, reason, revocation_time, * this_update, next_update, extensions = basic_response.status * * Then check the various fields. * * unless response_certificate_id == certificate_id then * raise 'certificate id mismatch' * end * * now = Time.now * * if this_update > now then * raise 'update date is in the future' * end * * if now > next_update then * raise 'next update time has passed' * end */ mOCSP = rb_define_module_under(mOSSL, "OCSP"); /* * OCSP error class. */ eOCSPError = rb_define_class_under(mOCSP, "OCSPError", eOSSLError); /* * An OpenSSL::OCSP::Request contains the certificate information for * determining if a certificate has been revoked or not. A Request can be * created for a certificate or from a DER-encoded request created * elsewhere. */ cOCSPReq = rb_define_class_under(mOCSP, "Request", rb_cObject); rb_define_alloc_func(cOCSPReq, ossl_ocspreq_alloc); rb_define_method(cOCSPReq, "initialize", ossl_ocspreq_initialize, -1); rb_define_method(cOCSPReq, "add_nonce", ossl_ocspreq_add_nonce, -1); rb_define_method(cOCSPReq, "check_nonce", ossl_ocspreq_check_nonce, 1); rb_define_method(cOCSPReq, "add_certid", ossl_ocspreq_add_certid, 1); rb_define_method(cOCSPReq, "certid", ossl_ocspreq_get_certid, 0); rb_define_method(cOCSPReq, "sign", ossl_ocspreq_sign, -1); rb_define_method(cOCSPReq, "verify", ossl_ocspreq_verify, -1); rb_define_method(cOCSPReq, "to_der", ossl_ocspreq_to_der, 0); /* * An OpenSSL::OCSP::Response contains the status of a certificate check * which is created from an OpenSSL::OCSP::Request. */ cOCSPRes = rb_define_class_under(mOCSP, "Response", rb_cObject); rb_define_singleton_method(cOCSPRes, "create", ossl_ocspres_s_create, 2); rb_define_alloc_func(cOCSPRes, ossl_ocspres_alloc); rb_define_method(cOCSPRes, "initialize", ossl_ocspres_initialize, -1); rb_define_method(cOCSPRes, "status", ossl_ocspres_status, 0); rb_define_method(cOCSPRes, "status_string", ossl_ocspres_status_string, 0); rb_define_method(cOCSPRes, "basic", ossl_ocspres_get_basic, 0); rb_define_method(cOCSPRes, "to_der", ossl_ocspres_to_der, 0); /* * An OpenSSL::OCSP::BasicResponse contains the status of a certificate * check which is created from an OpenSSL::OCSP::Request. A * BasicResponse is more detailed than a Response. */ cOCSPBasicRes = rb_define_class_under(mOCSP, "BasicResponse", rb_cObject); rb_define_alloc_func(cOCSPBasicRes, ossl_ocspbres_alloc); rb_define_method(cOCSPBasicRes, "initialize", ossl_ocspbres_initialize, -1); rb_define_method(cOCSPBasicRes, "copy_nonce", ossl_ocspbres_copy_nonce, 1); rb_define_method(cOCSPBasicRes, "add_nonce", ossl_ocspbres_add_nonce, -1); rb_define_method(cOCSPBasicRes, "add_status", ossl_ocspbres_add_status, 7); rb_define_method(cOCSPBasicRes, "status", ossl_ocspbres_get_status, 0); rb_define_method(cOCSPBasicRes, "sign", ossl_ocspbres_sign, -1); rb_define_method(cOCSPBasicRes, "verify", ossl_ocspbres_verify, -1); /* * An OpenSSL::OCSP::CertificateId identifies a certificate to the CA so * that a status check can be performed. */ cOCSPCertId = rb_define_class_under(mOCSP, "CertificateId", rb_cObject); rb_define_alloc_func(cOCSPCertId, ossl_ocspcid_alloc); rb_define_method(cOCSPCertId, "initialize", ossl_ocspcid_initialize, -1); rb_define_method(cOCSPCertId, "cmp", ossl_ocspcid_cmp, 1); rb_define_method(cOCSPCertId, "cmp_issuer", ossl_ocspcid_cmp_issuer, 1); rb_define_method(cOCSPCertId, "serial", ossl_ocspcid_get_serial, 0); /* Internal error in issuer */ rb_define_const(mOCSP, "RESPONSE_STATUS_INTERNALERROR", INT2NUM(OCSP_RESPONSE_STATUS_INTERNALERROR)); /* Illegal confirmation request */ rb_define_const(mOCSP, "RESPONSE_STATUS_MALFORMEDREQUEST", INT2NUM(OCSP_RESPONSE_STATUS_MALFORMEDREQUEST)); /* The certificate was revoked for an unknown reason */ rb_define_const(mOCSP, "REVOKED_STATUS_NOSTATUS", INT2NUM(OCSP_REVOKED_STATUS_NOSTATUS)); /* You must sign the request and resubmit */ rb_define_const(mOCSP, "RESPONSE_STATUS_SIGREQUIRED", INT2NUM(OCSP_RESPONSE_STATUS_SIGREQUIRED)); /* Response has valid confirmations */ rb_define_const(mOCSP, "RESPONSE_STATUS_SUCCESSFUL", INT2NUM(OCSP_RESPONSE_STATUS_SUCCESSFUL)); /* Try again later */ rb_define_const(mOCSP, "RESPONSE_STATUS_TRYLATER", INT2NUM(OCSP_RESPONSE_STATUS_TRYLATER)); /* The certificate subject's name or other information changed */ rb_define_const(mOCSP, "REVOKED_STATUS_AFFILIATIONCHANGED", INT2NUM(OCSP_REVOKED_STATUS_AFFILIATIONCHANGED)); /* This CA certificate was revoked due to a key compromise */ rb_define_const(mOCSP, "REVOKED_STATUS_CACOMPROMISE", INT2NUM(OCSP_REVOKED_STATUS_CACOMPROMISE)); /* The certificate is on hold */ rb_define_const(mOCSP, "REVOKED_STATUS_CERTIFICATEHOLD", INT2NUM(OCSP_REVOKED_STATUS_CERTIFICATEHOLD)); /* The certificate is no longer needed */ rb_define_const(mOCSP, "REVOKED_STATUS_CESSATIONOFOPERATION", INT2NUM(OCSP_REVOKED_STATUS_CESSATIONOFOPERATION)); /* The certificate was revoked due to a key compromise */ rb_define_const(mOCSP, "REVOKED_STATUS_KEYCOMPROMISE", INT2NUM(OCSP_REVOKED_STATUS_KEYCOMPROMISE)); /* The certificate was previously on hold and should now be removed from * the CRL */ rb_define_const(mOCSP, "REVOKED_STATUS_REMOVEFROMCRL", INT2NUM(OCSP_REVOKED_STATUS_REMOVEFROMCRL)); /* The certificate was superseded by a new certificate */ rb_define_const(mOCSP, "REVOKED_STATUS_SUPERSEDED", INT2NUM(OCSP_REVOKED_STATUS_SUPERSEDED)); /* Your request is unauthorized. */ rb_define_const(mOCSP, "RESPONSE_STATUS_UNAUTHORIZED", INT2NUM(OCSP_RESPONSE_STATUS_UNAUTHORIZED)); /* The certificate was revoked for an unspecified reason */ rb_define_const(mOCSP, "REVOKED_STATUS_UNSPECIFIED", INT2NUM(OCSP_REVOKED_STATUS_UNSPECIFIED)); /* Do not include certificates in the response */ rb_define_const(mOCSP, "NOCERTS", INT2NUM(OCSP_NOCERTS)); /* Do not search certificates contained in the response for a signer */ rb_define_const(mOCSP, "NOINTERN", INT2NUM(OCSP_NOINTERN)); /* Do not check the signature on the response */ rb_define_const(mOCSP, "NOSIGS", INT2NUM(OCSP_NOSIGS)); /* Do not verify the certificate chain on the response */ rb_define_const(mOCSP, "NOCHAIN", INT2NUM(OCSP_NOCHAIN)); /* Do not verify the response at all */ rb_define_const(mOCSP, "NOVERIFY", INT2NUM(OCSP_NOVERIFY)); /* Do not check trust */ rb_define_const(mOCSP, "NOEXPLICIT", INT2NUM(OCSP_NOEXPLICIT)); /* (This flag is not used by OpenSSL 1.0.1g) */ rb_define_const(mOCSP, "NOCASIGN", INT2NUM(OCSP_NOCASIGN)); /* (This flag is not used by OpenSSL 1.0.1g) */ rb_define_const(mOCSP, "NODELEGATED", INT2NUM(OCSP_NODELEGATED)); /* Do not make additional signing certificate checks */ rb_define_const(mOCSP, "NOCHECKS", INT2NUM(OCSP_NOCHECKS)); /* Do not verify additional certificates */ rb_define_const(mOCSP, "TRUSTOTHER", INT2NUM(OCSP_TRUSTOTHER)); /* Identify the response by signing the certificate key ID */ rb_define_const(mOCSP, "RESPID_KEY", INT2NUM(OCSP_RESPID_KEY)); /* Do not include producedAt time in response */ rb_define_const(mOCSP, "NOTIME", INT2NUM(OCSP_NOTIME)); /* Indicates the certificate is not revoked but does not necessarily mean * the certificate was issued or that this response is within the * certificate's validity interval */ rb_define_const(mOCSP, "V_CERTSTATUS_GOOD", INT2NUM(V_OCSP_CERTSTATUS_GOOD)); /* Indicates the certificate has been revoked either permanently or * temporarily (on hold). */ rb_define_const(mOCSP, "V_CERTSTATUS_REVOKED", INT2NUM(V_OCSP_CERTSTATUS_REVOKED)); /* Indicates the responder does not know about the certificate being * requested. */ rb_define_const(mOCSP, "V_CERTSTATUS_UNKNOWN", INT2NUM(V_OCSP_CERTSTATUS_UNKNOWN)); /* The responder ID is based on the key name. */ rb_define_const(mOCSP, "V_RESPID_NAME", INT2NUM(V_OCSP_RESPID_NAME)); /* The responder ID is based on the public key. */ rb_define_const(mOCSP, "V_RESPID_KEY", INT2NUM(V_OCSP_RESPID_KEY)); }
/* * INIT */ void Init_ossl_pkcs7() { cPKCS7 = rb_define_class_under(mOSSL, "PKCS7", rb_cObject); ePKCS7Error = rb_define_class_under(cPKCS7, "PKCS7Error", eOSSLError); rb_define_singleton_method(cPKCS7, "read_smime", ossl_pkcs7_s_read_smime, 1); rb_define_singleton_method(cPKCS7, "write_smime", ossl_pkcs7_s_write_smime, -1); rb_define_singleton_method(cPKCS7, "sign", ossl_pkcs7_s_sign, -1); rb_define_singleton_method(cPKCS7, "encrypt", ossl_pkcs7_s_encrypt, -1); rb_attr(cPKCS7, rb_intern("data"), 1, 0, Qfalse); rb_attr(cPKCS7, rb_intern("error_string"), 1, 1, Qfalse); rb_define_alloc_func(cPKCS7, ossl_pkcs7_alloc); rb_define_copy_func(cPKCS7, ossl_pkcs7_copy); rb_define_method(cPKCS7, "initialize", ossl_pkcs7_initialize, -1); rb_define_method(cPKCS7, "type=", ossl_pkcs7_set_type, 1); rb_define_method(cPKCS7, "type", ossl_pkcs7_get_type, 0); rb_define_method(cPKCS7, "detached=", ossl_pkcs7_set_detached, 1); rb_define_method(cPKCS7, "detached", ossl_pkcs7_get_detached, 0); rb_define_method(cPKCS7, "detached?", ossl_pkcs7_detached_p, 0); rb_define_method(cPKCS7, "cipher=", ossl_pkcs7_set_cipher, 1); rb_define_method(cPKCS7, "add_signer", ossl_pkcs7_add_signer, 1); rb_define_method(cPKCS7, "signers", ossl_pkcs7_get_signer, 0); rb_define_method(cPKCS7, "add_recipient", ossl_pkcs7_add_recipient, 1); rb_define_method(cPKCS7, "recipients", ossl_pkcs7_get_recipient, 0); rb_define_method(cPKCS7, "add_certificate", ossl_pkcs7_add_certificate, 1); rb_define_method(cPKCS7, "certificates=", ossl_pkcs7_set_certificates, 1); rb_define_method(cPKCS7, "certificates", ossl_pkcs7_get_certificates, 0); rb_define_method(cPKCS7, "add_crl", ossl_pkcs7_add_crl, 1); rb_define_method(cPKCS7, "crls=", ossl_pkcs7_set_crls, 1); rb_define_method(cPKCS7, "crls", ossl_pkcs7_get_crls, 0); rb_define_method(cPKCS7, "add_data", ossl_pkcs7_add_data, 1); rb_define_alias(cPKCS7, "data=", "add_data"); rb_define_method(cPKCS7, "verify", ossl_pkcs7_verify, -1); rb_define_method(cPKCS7, "decrypt", ossl_pkcs7_decrypt, -1); rb_define_method(cPKCS7, "to_pem", ossl_pkcs7_to_pem, 0); rb_define_alias(cPKCS7, "to_s", "to_pem"); rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0); cPKCS7Signer = rb_define_class_under(cPKCS7, "SignerInfo", rb_cObject); rb_define_const(cPKCS7, "Signer", cPKCS7Signer); rb_define_alloc_func(cPKCS7Signer, ossl_pkcs7si_alloc); rb_define_method(cPKCS7Signer, "initialize", ossl_pkcs7si_initialize,3); rb_define_method(cPKCS7Signer, "issuer", ossl_pkcs7si_get_issuer, 0); rb_define_alias(cPKCS7Signer, "name", "issuer"); rb_define_method(cPKCS7Signer, "serial", ossl_pkcs7si_get_serial,0); rb_define_method(cPKCS7Signer,"signed_time",ossl_pkcs7si_get_signed_time,0); cPKCS7Recipient = rb_define_class_under(cPKCS7,"RecipientInfo",rb_cObject); rb_define_alloc_func(cPKCS7Recipient, ossl_pkcs7ri_alloc); rb_define_method(cPKCS7Recipient, "initialize", ossl_pkcs7ri_initialize,1); rb_define_method(cPKCS7Recipient, "issuer", ossl_pkcs7ri_get_issuer,0); rb_define_method(cPKCS7Recipient, "serial", ossl_pkcs7ri_get_serial,0); rb_define_method(cPKCS7Recipient, "enc_key", ossl_pkcs7ri_get_enc_key,0); #define DefPKCS7Const(x) rb_define_const(cPKCS7, #x, INT2NUM(PKCS7_##x)) DefPKCS7Const(TEXT); DefPKCS7Const(NOCERTS); DefPKCS7Const(NOSIGS); DefPKCS7Const(NOCHAIN); DefPKCS7Const(NOINTERN); DefPKCS7Const(NOVERIFY); DefPKCS7Const(DETACHED); DefPKCS7Const(BINARY); DefPKCS7Const(NOATTR); DefPKCS7Const(NOSMIMECAP); }
void Init_lost() { VALUE mod = rb_define_module("Lost"); rb_define_singleton_method(mod, "coreloc_enable", coreloc_enable, 0); rb_define_singleton_method(mod, "current_position", coreloc_pos, 0); }
void Init_generator() { rb_require("json/common"); mJSON = rb_define_module("JSON"); mExt = rb_define_module_under(mJSON, "Ext"); mGenerator = rb_define_module_under(mExt, "Generator"); eGeneratorError = rb_path2class("JSON::GeneratorError"); eCircularDatastructure = rb_path2class("JSON::CircularDatastructure"); eNestingError = rb_path2class("JSON::NestingError"); cState = rb_define_class_under(mGenerator, "State", rb_cObject); rb_define_alloc_func(cState, cState_s_allocate); rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1); rb_define_method(cState, "initialize", cState_initialize, -1); rb_define_method(cState, "indent", cState_indent, 0); rb_define_method(cState, "indent=", cState_indent_set, 1); rb_define_method(cState, "space", cState_space, 0); rb_define_method(cState, "space=", cState_space_set, 1); rb_define_method(cState, "space_before", cState_space_before, 0); rb_define_method(cState, "space_before=", cState_space_before_set, 1); rb_define_method(cState, "object_nl", cState_object_nl, 0); rb_define_method(cState, "object_nl=", cState_object_nl_set, 1); rb_define_method(cState, "array_nl", cState_array_nl, 0); rb_define_method(cState, "array_nl=", cState_array_nl_set, 1); rb_define_method(cState, "check_circular?", cState_check_circular_p, 0); rb_define_method(cState, "max_nesting", cState_max_nesting, 0); rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1); rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0); rb_define_method(cState, "seen?", cState_seen_p, 1); rb_define_method(cState, "remember", cState_remember, 1); rb_define_method(cState, "forget", cState_forget, 1); rb_define_method(cState, "configure", cState_configure, 1); rb_define_method(cState, "to_h", cState_to_h, 0); mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods"); mObject = rb_define_module_under(mGeneratorMethods, "Object"); rb_define_method(mObject, "to_json", mObject_to_json, -1); mHash = rb_define_module_under(mGeneratorMethods, "Hash"); rb_define_method(mHash, "to_json", mHash_to_json, -1); mArray = rb_define_module_under(mGeneratorMethods, "Array"); rb_define_method(mArray, "to_json", mArray_to_json, -1); mInteger = rb_define_module_under(mGeneratorMethods, "Integer"); rb_define_method(mInteger, "to_json", mInteger_to_json, -1); mFloat = rb_define_module_under(mGeneratorMethods, "Float"); rb_define_method(mFloat, "to_json", mFloat_to_json, -1); mString = rb_define_module_under(mGeneratorMethods, "String"); rb_define_singleton_method(mString, "included", mString_included_s, 1); rb_define_method(mString, "to_json", mString_to_json, -1); rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1); rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0); mString_Extend = rb_define_module_under(mString, "Extend"); rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1); mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass"); rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1); mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass"); rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1); mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass"); rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1); i_to_s = rb_intern("to_s"); i_to_json = rb_intern("to_json"); i_new = rb_intern("new"); i_indent = rb_intern("indent"); i_space = rb_intern("space"); i_space_before = rb_intern("space_before"); i_object_nl = rb_intern("object_nl"); i_array_nl = rb_intern("array_nl"); i_check_circular = rb_intern("check_circular"); i_max_nesting = rb_intern("max_nesting"); i_allow_nan = rb_intern("allow_nan"); i_pack = rb_intern("pack"); i_unpack = rb_intern("unpack"); i_create_id = rb_intern("create_id"); i_extend = rb_intern("extend"); }
void Init_gsl_linalg_complex(VALUE module) { VALUE mgsl_linalg_complex; VALUE mgsl_linalg_complex_LU; mgsl_linalg_complex = rb_define_module_under(module, "Complex"); mgsl_linalg_complex_LU = rb_define_module_under(mgsl_linalg_complex, "LU"); cgsl_matrix_complex_LU = rb_define_class_under(mgsl_linalg_complex_LU, "LUMatrix", cgsl_matrix_complex); rb_define_singleton_method(mgsl_linalg_complex, "LU_decomp!", rb_gsl_linalg_complex_LU_decomp, -1); rb_define_singleton_method(mgsl_linalg_complex_LU, "decomp!", rb_gsl_linalg_complex_LU_decomp, -1); rb_define_method(cgsl_matrix_complex, "LU_decomp!", rb_gsl_linalg_complex_LU_decomp, -1); rb_define_alias(cgsl_matrix_complex, "decomp!", "LU_decomp!"); rb_define_singleton_method(mgsl_linalg_complex, "LU_decomp", rb_gsl_linalg_complex_LU_decomp2, -1); rb_define_singleton_method(mgsl_linalg_complex_LU, "decomp", rb_gsl_linalg_complex_LU_decomp2, -1); rb_define_method(cgsl_matrix_complex, "LU_decomp", rb_gsl_linalg_complex_LU_decomp2, -1); rb_define_alias(cgsl_matrix_complex, "decomp", "LU_decomp"); rb_define_singleton_method(mgsl_linalg_complex, "LU_solve", rb_gsl_linalg_complex_LU_solve, -1); rb_define_singleton_method(mgsl_linalg_complex_LU, "solve", rb_gsl_linalg_complex_LU_solve, -1); rb_define_method(cgsl_matrix_complex, "LU_solve", rb_gsl_linalg_complex_LU_solve, -1); rb_define_method(cgsl_matrix_complex_LU, "solve", rb_gsl_linalg_complex_LU_solve, -1); rb_define_singleton_method(mgsl_linalg_complex, "LU_svx", rb_gsl_linalg_complex_LU_svx, -1); rb_define_singleton_method(mgsl_linalg_complex_LU, "svx", rb_gsl_linalg_complex_LU_svx, -1); rb_define_method(cgsl_matrix_complex, "LU_svx", rb_gsl_linalg_complex_LU_svx, -1); rb_define_method(cgsl_matrix_complex_LU, "svx", rb_gsl_linalg_complex_LU_svx, -1); rb_define_singleton_method(mgsl_linalg_complex, "LU_refine", rb_gsl_linalg_complex_LU_refine, 5); rb_define_singleton_method(mgsl_linalg_complex_LU, "refine", rb_gsl_linalg_complex_LU_refine, 5); rb_define_singleton_method(mgsl_linalg_complex, "LU_invert", rb_gsl_linalg_complex_LU_invert, -1); rb_define_singleton_method(mgsl_linalg_complex_LU, "invert", rb_gsl_linalg_complex_LU_invert, -1); rb_define_method(cgsl_matrix_complex, "LU_invert", rb_gsl_linalg_complex_LU_invert, -1); rb_define_alias(cgsl_matrix_complex, "invert", "LU_invert"); rb_define_alias(cgsl_matrix_complex, "inv", "LU_invert"); rb_define_method(cgsl_matrix_complex_LU, "invert", rb_gsl_linalg_complex_LU_invert, -1); #ifdef GSL_1_1_1_LATER rb_define_singleton_method(mgsl_linalg_complex, "LU_det", rb_gsl_linalg_complex_LU_det, -1); rb_define_singleton_method(mgsl_linalg_complex_LU, "det", rb_gsl_linalg_complex_LU_det, -1); rb_define_method(cgsl_matrix_complex, "LU_det", rb_gsl_linalg_complex_LU_det, -1); rb_define_alias(cgsl_matrix_complex, "det", "LU_det"); rb_define_method(cgsl_matrix_complex_LU, "det", rb_gsl_linalg_complex_LU_det, -1); rb_define_singleton_method(mgsl_linalg_complex, "LU_lndet", rb_gsl_linalg_complex_LU_lndet, -1); rb_define_singleton_method(mgsl_linalg_complex_LU, "lndet", rb_gsl_linalg_complex_LU_lndet, -1); rb_define_method(cgsl_matrix_complex, "LU_lndet", rb_gsl_linalg_complex_LU_lndet, -1); rb_define_alias(cgsl_matrix_complex, "lndet", "LU_lndet"); rb_define_method(cgsl_matrix_complex_LU, "LU_lndet", rb_gsl_linalg_complex_LU_lndet, -1); rb_define_singleton_method(mgsl_linalg_complex, "LU_sgndet", rb_gsl_linalg_complex_LU_sgndet, -1); rb_define_singleton_method(mgsl_linalg_complex_LU, "sgndet", rb_gsl_linalg_complex_LU_sgndet, -1); rb_define_method(cgsl_matrix_complex, "LU_sgndet", rb_gsl_linalg_complex_LU_sgndet, -1); rb_define_alias(cgsl_matrix_complex, "sgndet", "LU_sgndet"); rb_define_method(cgsl_matrix_complex_LU, "LU_sgndet", rb_gsl_linalg_complex_LU_sgndet, -1); #endif #ifdef GSL_1_10_LATER VALUE mgsl_linalg_complex_chol; mgsl_linalg_complex_chol = rb_define_module_under(mgsl_linalg_complex, "Cholesky"); cgsl_matrix_complex_C = rb_define_class_under(mgsl_linalg_complex_chol, "CholeskyMatrix", cgsl_matrix_complex); rb_define_singleton_method(mgsl_linalg_complex_chol, "decomp", rb_gsl_linalg_cholesky_decomp, -1); rb_define_method(cgsl_matrix_complex, "cholesky_decomp", rb_gsl_linalg_cholesky_decomp, -1); rb_define_singleton_method(mgsl_linalg_complex_chol, "solve", rb_gsl_linalg_cholesky_solve, -1); rb_define_method(cgsl_matrix_complex, "cholesky_solve", rb_gsl_linalg_cholesky_solve, -1); rb_define_method(cgsl_matrix_complex_C, "solve", rb_gsl_linalg_cholesky_solve, -1); rb_define_singleton_method(mgsl_linalg_complex_chol, "svx", rb_gsl_linalg_cholesky_svx, -1); rb_define_method(cgsl_matrix_complex, "cholesky_svx", rb_gsl_linalg_cholesky_svx, -1); rb_define_method(cgsl_matrix_complex_C, "svx", rb_gsl_linalg_cholesky_svx, -1); VALUE mgsl_linalg_complex_Householder = rb_define_module_under(mgsl_linalg_complex, "Householder"); rb_define_singleton_method(mgsl_linalg_complex, "householder_transform", rb_gsl_linalg_complex_householder_transform, -1); rb_define_singleton_method(mgsl_linalg_complex_Householder, "transform", rb_gsl_linalg_complex_householder_transform, -1); rb_define_method(cgsl_vector_complex, "householder_transform", rb_gsl_linalg_complex_householder_transform, -1); rb_define_singleton_method(mgsl_linalg_complex, "householder_hm", rb_gsl_linalg_complex_householder_hm, 3); rb_define_singleton_method(mgsl_linalg_complex_Householder, "hm", rb_gsl_linalg_complex_householder_hm, 3); rb_define_singleton_method(mgsl_linalg_complex, "householder_mh", rb_gsl_linalg_complex_householder_mh, 3); rb_define_singleton_method(mgsl_linalg_complex_Householder, "mh", rb_gsl_linalg_complex_householder_mh, 3); rb_define_singleton_method(mgsl_linalg_complex, "householder_hv", rb_gsl_linalg_complex_householder_hv, 3); rb_define_singleton_method(mgsl_linalg_complex_Householder, "hv", rb_gsl_linalg_complex_householder_hv, 3); #endif }
static void static_init_ruby_environment( void ) { /* only initialize the ruby environment once */ if( static_ruby_initialized ) return; static_ruby_initialized = 1; ruby_init(); /* "EMBEDDED_STUFF" is a macro that contains all of the Ruby code needed to * define the core XChat-Ruby interface. Once this has been defined, all we * need to do is extract the defined classes and add the C hooks to them. */ rb_eval_string( XCHAT_RUBY_PLUGIN ); static_xchat_module = rb_eval_string( "XChatRuby" ); static_xchat_klass = rb_eval_string( "XChatRuby::XChatRubyEnvironment" ); static_xchat_list_klass = rb_eval_string( "XChatRuby::XChatRubyList" ); static_xchat_hook_klass = rb_define_class( "XChatRuby::XChatRubyCallback", rb_cObject ); static_xchat_context_klass = rb_define_class_under( static_xchat_module, "XChatContext", rb_cObject ); static_xchat_list_internal_klass = rb_define_class_under( static_xchat_module, "XChatListInternal", rb_cObject ); static_xchat_process_command_hook = rb_intern( "process_command_hook" ); static_xchat_process_print_hook = rb_intern( "process_print_hook" ); static_xchat_process_server_hook = rb_intern( "process_server_hook" ); static_xchat_process_timer_hook = rb_intern( "process_timer_hook" ); rb_define_singleton_method( static_xchat_klass, "internal_xchat_hook_command", static_ruby_xchat_hook_command, 3 ); rb_define_singleton_method( static_xchat_klass, "internal_xchat_hook_print", static_ruby_xchat_hook_print, 2 ); rb_define_singleton_method( static_xchat_klass, "internal_xchat_hook_server", static_ruby_xchat_hook_server, 2 ); rb_define_singleton_method( static_xchat_klass, "internal_xchat_hook_timer", static_ruby_xchat_hook_timer, 2 ); rb_define_singleton_method( static_xchat_klass, "internal_xchat_print", static_ruby_xchat_print, 1 ); rb_define_singleton_method( static_xchat_klass, "internal_xchat_unhook", static_ruby_xchat_unhook, 1 ); rb_define_singleton_method( static_xchat_klass, "command", static_ruby_xchat_command, 1 ); rb_define_singleton_method( static_xchat_klass, "find_context", static_ruby_xchat_find_context, 2 ); rb_define_singleton_method( static_xchat_klass, "get_context", static_ruby_xchat_get_context, 0 ); rb_define_singleton_method( static_xchat_klass, "get_info", static_ruby_xchat_get_info, 1 ); rb_define_singleton_method( static_xchat_klass, "get_prefs", static_ruby_xchat_get_prefs, 1 ); rb_define_singleton_method( static_xchat_klass, "set_context", static_ruby_xchat_set_context, 1 ); rb_define_singleton_method( static_xchat_klass, "nickcmp", static_ruby_xchat_nickcmp, 2 ); rb_define_singleton_method( static_xchat_klass, "emit_print", static_ruby_xchat_emit_print, -1 ); rb_define_method( static_xchat_list_klass, "internal_xchat_list_get", static_ruby_xchat_list_get, 1 ); rb_define_method( static_xchat_list_klass, "internal_xchat_list_next", static_ruby_xchat_list_next, 1 ); rb_define_method( static_xchat_list_klass, "internal_xchat_list_str", static_ruby_xchat_list_str, 2 ); rb_define_method( static_xchat_list_klass, "internal_xchat_list_int", static_ruby_xchat_list_int, 2 ); rb_funcall( static_xchat_klass, rb_intern( "register" ), 0 ); }
void Init_highpass() { cCSHighpass = rb_define_class_under(mCSFilters, "LLHighpass", cCSLowpass); rb_define_singleton_method(cCSHighpass, "new", rbcs_highpass_new, -1); }
void Init_digest(void) { id_reset = rb_intern("reset"); id_update = rb_intern("update"); id_finish = rb_intern("finish"); id_digest = rb_intern("digest"); id_hexdigest = rb_intern("hexdigest"); id_digest_length = rb_intern("digest_length"); /* * module Digest */ rb_mDigest = rb_define_module("Digest"); /* module functions */ rb_define_module_function(rb_mDigest, "hexencode", rb_digest_s_hexencode, 1); /* * module Digest::Instance */ rb_mDigest_Instance = rb_define_module_under(rb_mDigest, "Instance"); /* instance methods that should be overridden */ rb_define_method(rb_mDigest_Instance, "update", rb_digest_instance_update, 1); rb_define_method(rb_mDigest_Instance, "<<", rb_digest_instance_update, 1); rb_define_private_method(rb_mDigest_Instance, "finish", rb_digest_instance_finish, 0); rb_define_method(rb_mDigest_Instance, "reset", rb_digest_instance_reset, 0); rb_define_method(rb_mDigest_Instance, "digest_length", rb_digest_instance_digest_length, 0); rb_define_method(rb_mDigest_Instance, "block_length", rb_digest_instance_block_length, 0); /* instance methods that may be overridden */ rb_define_method(rb_mDigest_Instance, "==", rb_digest_instance_equal, 1); rb_define_method(rb_mDigest_Instance, "inspect", rb_digest_instance_inspect, 0); /* instance methods that need not usually be overridden */ rb_define_method(rb_mDigest_Instance, "new", rb_digest_instance_new, 0); rb_define_method(rb_mDigest_Instance, "digest", rb_digest_instance_digest, -1); rb_define_method(rb_mDigest_Instance, "digest!", rb_digest_instance_digest_bang, 0); rb_define_method(rb_mDigest_Instance, "hexdigest", rb_digest_instance_hexdigest, -1); rb_define_method(rb_mDigest_Instance, "hexdigest!", rb_digest_instance_hexdigest_bang, 0); rb_define_method(rb_mDigest_Instance, "to_s", rb_digest_instance_to_s, 0); rb_define_method(rb_mDigest_Instance, "length", rb_digest_instance_length, 0); rb_define_method(rb_mDigest_Instance, "size", rb_digest_instance_length, 0); /* * class Digest::Class */ rb_cDigest_Class = rb_define_class_under(rb_mDigest, "Class", rb_cObject); rb_define_method(rb_cDigest_Class, "initialize", rb_digest_class_init, 0); rb_include_module(rb_cDigest_Class, rb_mDigest_Instance); /* class methods */ rb_define_singleton_method(rb_cDigest_Class, "digest", rb_digest_class_s_digest, -1); rb_define_singleton_method(rb_cDigest_Class, "hexdigest", rb_digest_class_s_hexdigest, -1); id_metadata = rb_intern("metadata"); /* class Digest::Base < Digest::Class */ rb_cDigest_Base = rb_define_class_under(rb_mDigest, "Base", rb_cDigest_Class); rb_define_alloc_func(rb_cDigest_Base, rb_digest_base_alloc); rb_define_method(rb_cDigest_Base, "initialize_copy", rb_digest_base_copy, 1); rb_define_method(rb_cDigest_Base, "reset", rb_digest_base_reset, 0); rb_define_method(rb_cDigest_Base, "update", rb_digest_base_update, 1); rb_define_method(rb_cDigest_Base, "<<", rb_digest_base_update, 1); rb_define_private_method(rb_cDigest_Base, "finish", rb_digest_base_finish, 0); rb_define_method(rb_cDigest_Base, "digest_length", rb_digest_base_digest_length, 0); rb_define_method(rb_cDigest_Base, "block_length", rb_digest_base_block_length, 0); }
void Init_DNSSD_Service(void) { mDNSSD = rb_define_module("DNSSD"); dnssd_id_join = rb_intern("join"); dnssd_id_push = rb_intern("push"); dnssd_iv_continue = rb_intern("@continue"); dnssd_iv_records = rb_intern("@records"); dnssd_iv_replies = rb_intern("@replies"); dnssd_iv_service = rb_intern("@service"); dnssd_iv_thread = rb_intern("@thread"); dnssd_iv_type = rb_intern("@type"); cDNSSDFlags = rb_define_class_under(mDNSSD, "Flags", rb_cObject); cDNSSDRecord = rb_define_class_under(mDNSSD, "Record", rb_cObject); cDNSSDService = rb_define_class_under(mDNSSD, "Service", rb_cObject); cDNSSDTextRecord = rb_path2class("DNSSD::TextRecord"); cDNSSDReplyAddrInfo = rb_path2class("DNSSD::Reply::AddrInfo"); cDNSSDReplyBrowse = rb_path2class("DNSSD::Reply::Browse"); cDNSSDReplyDomain = rb_path2class("DNSSD::Reply::Domain"); cDNSSDReplyQueryRecord = rb_path2class("DNSSD::Reply::QueryRecord"); cDNSSDReplyRegister = rb_path2class("DNSSD::Reply::Register"); cDNSSDReplyResolve = rb_path2class("DNSSD::Reply::Resolve"); rb_cSocket = rb_path2class("Socket"); /* Maximum length for a domain name */ rb_define_const(cDNSSDService, "MAX_DOMAIN_NAME", ULONG2NUM(kDNSServiceMaxDomainName)); /* Maximum length for a service name */ rb_define_const(cDNSSDService, "MAX_SERVICE_NAME", ULONG2NUM(kDNSServiceMaxServiceName)); #ifdef kDNSServiceProperty_DaemonVersion /* DaemonVersion property value */ rb_define_const(cDNSSDService, "DaemonVersion", rb_str_new2(kDNSServiceProperty_DaemonVersion)); #endif #ifdef HAVE_DNSSERVICEGETPROPERTY /* IPv4 protocol for #getaddrinfo */ rb_define_const(cDNSSDService, "IPv4", ULONG2NUM(kDNSServiceProtocol_IPv4)); /* IPv6 protocol for #getaddrinfo */ rb_define_const(cDNSSDService, "IPv6", ULONG2NUM(kDNSServiceProtocol_IPv6)); /* HACK the below are only used by NAT, fix with proper HAVE_ */ /* TCP protocol for creating NAT port mappings */ rb_define_const(cDNSSDService, "TCP", ULONG2NUM(kDNSServiceProtocol_TCP)); /* UDP protocol for creating NAT port mappings */ rb_define_const(cDNSSDService, "UDP", ULONG2NUM(kDNSServiceProtocol_UDP)); #endif rb_define_alloc_func(cDNSSDService, dnssd_service_s_allocate); rb_define_singleton_method(cDNSSDService, "fullname", dnssd_service_s_fullname, 3); #ifdef HAVE_DNSSERVICEGETPROPERTY rb_define_singleton_method(cDNSSDService, "get_property", dnssd_service_s_get_property, 1); #endif rb_define_method(cDNSSDService, "stop", dnssd_service_stop, 0); rb_define_method(cDNSSDService, "stopped?", dnssd_service_stopped_p, 0); rb_define_method(cDNSSDService, "_add_record", dnssd_service_add_record, 4); rb_define_method(cDNSSDService, "_update_record", dnssd_service_update_record, 4); rb_define_method(cDNSSDService, "_browse", dnssd_service_browse, 4); rb_define_method(cDNSSDService, "_enumerate_domains", dnssd_service_enumerate_domains, 2); #ifdef HAVE_DNSSERVICEGETADDRINFO rb_define_method(cDNSSDService, "_getaddrinfo", dnssd_service_getaddrinfo, 4); #endif rb_define_method(cDNSSDService, "_query_record", dnssd_service_query_record, 5); rb_define_method(cDNSSDService, "_register", dnssd_service_register, 8); rb_define_method(cDNSSDService, "_resolve", dnssd_service_resolve, 5); rb_define_method(cDNSSDService, "_process", dnssd_service_process, 0); }
static VALUE module_specs_rb_define_singleton_method(VALUE self, VALUE cls, VALUE str_name) { rb_define_singleton_method(cls, RSTRING_PTR(str_name), module_specs_test_method, 0); return Qnil; }
void init_mysql2_client() { /* verify the libmysql we're about to use was the version we were built against https://github.com/luislavena/mysql-gem/commit/a600a9c459597da0712f70f43736e24b484f8a99 */ int i; int dots = 0; const char *lib = mysql_get_client_info(); for (i = 0; lib[i] != 0 && MYSQL_LINK_VERSION[i] != 0; i++) { if (lib[i] == '.') { dots++; /* we only compare MAJOR and MINOR */ if (dots == 2) break; } if (lib[i] != MYSQL_LINK_VERSION[i]) { rb_raise(rb_eRuntimeError, "Incorrect MySQL client library version! This gem was compiled for %s but the client library is %s.", MYSQL_LINK_VERSION, lib); return; } } /* Initializing mysql library, so different threads could call Client.new */ /* without race condition in the library */ if (mysql_library_init(0, NULL, NULL) != 0) { rb_raise(rb_eRuntimeError, "Could not initialize MySQL client library"); return; } #if 0 mMysql2 = rb_define_module("Mysql2"); Teach RDoc about Mysql2 constant. #endif cMysql2Client = rb_define_class_under(mMysql2, "Client", rb_cObject); rb_define_alloc_func(cMysql2Client, allocate); rb_define_singleton_method(cMysql2Client, "escape", rb_mysql_client_escape, 1); rb_define_singleton_method(cMysql2Client, "info", rb_mysql_client_info, 0); rb_define_method(cMysql2Client, "close", rb_mysql_client_close, 0); rb_define_method(cMysql2Client, "abandon_results!", rb_mysql_client_abandon_results, 0); rb_define_method(cMysql2Client, "escape", rb_mysql_client_real_escape, 1); rb_define_method(cMysql2Client, "server_info", rb_mysql_client_server_info, 0); rb_define_method(cMysql2Client, "socket", rb_mysql_client_socket, 0); rb_define_method(cMysql2Client, "async_result", rb_mysql_client_async_result, 0); rb_define_method(cMysql2Client, "last_id", rb_mysql_client_last_id, 0); rb_define_method(cMysql2Client, "affected_rows", rb_mysql_client_affected_rows, 0); rb_define_method(cMysql2Client, "thread_id", rb_mysql_client_thread_id, 0); rb_define_method(cMysql2Client, "ping", rb_mysql_client_ping, 0); rb_define_method(cMysql2Client, "select_db", rb_mysql_client_select_db, 1); rb_define_method(cMysql2Client, "more_results?", rb_mysql_client_more_results, 0); rb_define_method(cMysql2Client, "next_result", rb_mysql_client_next_result, 0); rb_define_method(cMysql2Client, "store_result", rb_mysql_client_store_result, 0); rb_define_method(cMysql2Client, "reconnect=", set_reconnect, 1); rb_define_method(cMysql2Client, "warning_count", rb_mysql_client_warning_count, 0); rb_define_method(cMysql2Client, "query_info_string", rb_mysql_info, 0); #ifdef HAVE_RUBY_ENCODING_H rb_define_method(cMysql2Client, "encoding", rb_mysql_client_encoding, 0); #endif rb_define_private_method(cMysql2Client, "connect_timeout=", set_connect_timeout, 1); rb_define_private_method(cMysql2Client, "read_timeout=", set_read_timeout, 1); rb_define_private_method(cMysql2Client, "write_timeout=", set_write_timeout, 1); rb_define_private_method(cMysql2Client, "local_infile=", set_local_infile, 1); rb_define_private_method(cMysql2Client, "charset_name=", set_charset_name, 1); rb_define_private_method(cMysql2Client, "secure_auth=", set_secure_auth, 1); rb_define_private_method(cMysql2Client, "default_file=", set_read_default_file, 1); rb_define_private_method(cMysql2Client, "default_group=", set_read_default_group, 1); rb_define_private_method(cMysql2Client, "init_command=", set_init_command, 1); rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5); rb_define_private_method(cMysql2Client, "initialize_ext", initialize_ext, 0); rb_define_private_method(cMysql2Client, "connect", rb_connect, 7); rb_define_private_method(cMysql2Client, "_query", rb_query, 2); sym_id = ID2SYM(rb_intern("id")); sym_version = ID2SYM(rb_intern("version")); sym_header_version = ID2SYM(rb_intern("header_version")); sym_async = ID2SYM(rb_intern("async")); sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys")); sym_as = ID2SYM(rb_intern("as")); sym_array = ID2SYM(rb_intern("array")); sym_stream = ID2SYM(rb_intern("stream")); intern_merge = rb_intern("merge"); intern_merge_bang = rb_intern("merge!"); intern_error_number_eql = rb_intern("error_number="); intern_sql_state_eql = rb_intern("sql_state="); #ifdef CLIENT_LONG_PASSWORD rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"), LONG2NUM(CLIENT_LONG_PASSWORD)); #endif #ifdef CLIENT_FOUND_ROWS rb_const_set(cMysql2Client, rb_intern("FOUND_ROWS"), LONG2NUM(CLIENT_FOUND_ROWS)); #endif #ifdef CLIENT_LONG_FLAG rb_const_set(cMysql2Client, rb_intern("LONG_FLAG"), LONG2NUM(CLIENT_LONG_FLAG)); #endif #ifdef CLIENT_CONNECT_WITH_DB rb_const_set(cMysql2Client, rb_intern("CONNECT_WITH_DB"), LONG2NUM(CLIENT_CONNECT_WITH_DB)); #endif #ifdef CLIENT_NO_SCHEMA rb_const_set(cMysql2Client, rb_intern("NO_SCHEMA"), LONG2NUM(CLIENT_NO_SCHEMA)); #endif #ifdef CLIENT_COMPRESS rb_const_set(cMysql2Client, rb_intern("COMPRESS"), LONG2NUM(CLIENT_COMPRESS)); #endif #ifdef CLIENT_ODBC rb_const_set(cMysql2Client, rb_intern("ODBC"), LONG2NUM(CLIENT_ODBC)); #endif #ifdef CLIENT_LOCAL_FILES rb_const_set(cMysql2Client, rb_intern("LOCAL_FILES"), LONG2NUM(CLIENT_LOCAL_FILES)); #endif #ifdef CLIENT_IGNORE_SPACE rb_const_set(cMysql2Client, rb_intern("IGNORE_SPACE"), LONG2NUM(CLIENT_IGNORE_SPACE)); #endif #ifdef CLIENT_PROTOCOL_41 rb_const_set(cMysql2Client, rb_intern("PROTOCOL_41"), LONG2NUM(CLIENT_PROTOCOL_41)); #endif #ifdef CLIENT_INTERACTIVE rb_const_set(cMysql2Client, rb_intern("INTERACTIVE"), LONG2NUM(CLIENT_INTERACTIVE)); #endif #ifdef CLIENT_SSL rb_const_set(cMysql2Client, rb_intern("SSL"), LONG2NUM(CLIENT_SSL)); #endif #ifdef CLIENT_IGNORE_SIGPIPE rb_const_set(cMysql2Client, rb_intern("IGNORE_SIGPIPE"), LONG2NUM(CLIENT_IGNORE_SIGPIPE)); #endif #ifdef CLIENT_TRANSACTIONS rb_const_set(cMysql2Client, rb_intern("TRANSACTIONS"), LONG2NUM(CLIENT_TRANSACTIONS)); #endif #ifdef CLIENT_RESERVED rb_const_set(cMysql2Client, rb_intern("RESERVED"), LONG2NUM(CLIENT_RESERVED)); #endif #ifdef CLIENT_SECURE_CONNECTION rb_const_set(cMysql2Client, rb_intern("SECURE_CONNECTION"), LONG2NUM(CLIENT_SECURE_CONNECTION)); #else /* HACK because MySQL5.7 no longer defines this constant, * but we're using it in our default connection flags. */ rb_const_set(cMysql2Client, rb_intern("SECURE_CONNECTION"), LONG2NUM(0)); #endif #ifdef CLIENT_MULTI_STATEMENTS rb_const_set(cMysql2Client, rb_intern("MULTI_STATEMENTS"), LONG2NUM(CLIENT_MULTI_STATEMENTS)); #endif #ifdef CLIENT_PS_MULTI_RESULTS rb_const_set(cMysql2Client, rb_intern("PS_MULTI_RESULTS"), LONG2NUM(CLIENT_PS_MULTI_RESULTS)); #endif #ifdef CLIENT_SSL_VERIFY_SERVER_CERT rb_const_set(cMysql2Client, rb_intern("SSL_VERIFY_SERVER_CERT"), LONG2NUM(CLIENT_SSL_VERIFY_SERVER_CERT)); #endif #ifdef CLIENT_REMEMBER_OPTIONS rb_const_set(cMysql2Client, rb_intern("REMEMBER_OPTIONS"), LONG2NUM(CLIENT_REMEMBER_OPTIONS)); #endif #ifdef CLIENT_ALL_FLAGS rb_const_set(cMysql2Client, rb_intern("ALL_FLAGS"), LONG2NUM(CLIENT_ALL_FLAGS)); #endif #ifdef CLIENT_BASIC_FLAGS rb_const_set(cMysql2Client, rb_intern("BASIC_FLAGS"), LONG2NUM(CLIENT_BASIC_FLAGS)); #endif }