File src/dinoex_ruby.c

* by Dirk Meyer (dinoex) * Copyright (C) 2004-2011 Dirk Meyer * * By using this file, you agree to the terms and conditions set * forth in the GNU General Public License. More information is * available in the README file. * * If you received this file without documentation, it can be * downloaded from http://iroffer.dinoex.net/ * * $Id: dinoex_ruby.c,v 1.49 2012/06/30 10:20:26 cvs Exp $ * * See also: * http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html *


Included Files

include the headers


Preprocessor definitions

#define _LONGLONG 1

#define MAX_RUBYCMD_PARTS 10


Typedef protect_call_arg_t

typedef struct protect_call_arg protect_call_arg_t
struct protect_call_arg  
   {  
      VALUE* argv;  
      VALUE recvobj;  
      ID mid;  
      int argc;  
      int dummy;  
   }  

Global Variable myruby_loaded

int myruby_loaded
Visible in:   src/dinoex_ruby.c
Used in: check_script() src/dinoex_ruby.c
  do_myruby_added() src/dinoex_ruby.c
  do_myruby_notice() src/dinoex_ruby.c
  do_myruby_packlist() src/dinoex_ruby.c
  do_myruby_privmsg() src/dinoex_ruby.c
  do_myruby_ruby() src/dinoex_ruby.c
  do_myruby_server() src/dinoex_ruby.c
  do_myruby_upload_done() src/dinoex_ruby.c
  load_script() src/dinoex_ruby.c
  startup_myruby() src/dinoex_ruby.c

Global Variable myruby_time

time_t myruby_time
Visible in:   src/dinoex_ruby.c
Used in: check_script() src/dinoex_ruby.c
  load_script() src/dinoex_ruby.c

Global Variable cLine

char* cLine
Visible in:   src/dinoex_ruby.c
Used in: cie_channel() src/dinoex_ruby.c
  cie_hostmask() src/dinoex_ruby.c
  cie_inputline() src/dinoex_ruby.c
  cie_message() src/dinoex_ruby.c
  cie_nick() src/dinoex_ruby.c
  do_myruby_notice() src/dinoex_ruby.c
  do_myruby_privmsg() src/dinoex_ruby.c
  do_myruby_server() src/dinoex_ruby.c

Global Variable cFile

char* cFile
Visible in:   src/dinoex_ruby.c
Used in: cie_added_file() src/dinoex_ruby.c
  do_myruby_added() src/dinoex_ruby.c
  do_myruby_upload_done() src/dinoex_ruby.c

Global Variable cPack

unsigned int cPack
Visible in:   src/dinoex_ruby.c
Used in: cie_added_pack() src/dinoex_ruby.c
  do_myruby_added() src/dinoex_ruby.c

Global Variable cIrofferConfig

VALUE cIrofferConfig
Visible in:   src/dinoex_ruby.c

Global Variable cIrofferEvent

VALUE cIrofferEvent
Visible in:   src/dinoex_ruby.c
Used in: Init_IrofferEvent() src/dinoex_ruby.c
  load_script() src/dinoex_ruby.c

Global Variable oIrofferEvent

VALUE oIrofferEvent
Visible in:   src/dinoex_ruby.c
Used in: do_myruby_added() src/dinoex_ruby.c
  do_myruby_notice() src/dinoex_ruby.c
  do_myruby_packlist() src/dinoex_ruby.c
  do_myruby_privmsg() src/dinoex_ruby.c
  do_myruby_ruby() src/dinoex_ruby.c
  do_myruby_server() src/dinoex_ruby.c
  do_myruby_upload_done() src/dinoex_ruby.c
  load_script() src/dinoex_ruby.c

Global Function do_myruby_added()

call the ruby class after adding a pack

int do_myruby_added ( char* filename, unsigned int pack )

Prototyped in: src/dinoex_ruby.h
Calls: do_on_event() src/dinoex_ruby.c
Called by: a_autoaddann() src/dinoex_admin.c
References Variables: cFile src/dinoex_ruby.c
  cPack src/dinoex_ruby.c
  myruby_loaded src/dinoex_ruby.c
  oIrofferEvent src/dinoex_ruby.c

Global Function do_myruby_notice()

push a notice to the ruby class

int do_myruby_notice ( char* line )

Prototyped in: src/dinoex_ruby.h
Calls: do_on_event() src/dinoex_ruby.c
Called by: ir_parseline2() src/dinoex_irc.c
References Variables: cLine src/dinoex_ruby.c
  myruby_loaded src/dinoex_ruby.c
  oIrofferEvent src/dinoex_ruby.c

Global Function do_myruby_packlist()

call the ruby class after adding/removing/changing a pack

int do_myruby_packlist ( void )

Prototyped in: src/dinoex_ruby.h
Calls: do_on_event() src/dinoex_ruby.c
Called by: write_files_changed() src/dinoex_admin.c
References Variables: myruby_loaded src/dinoex_ruby.c
  oIrofferEvent src/dinoex_ruby.c

Global Function do_myruby_privmsg()

push a privmsg to the ruby class

int do_myruby_privmsg ( char* line )

Prototyped in: src/dinoex_ruby.h
Calls: do_on_event() src/dinoex_ruby.c
Called by: ir_parseline2() src/dinoex_irc.c
References Variables: cLine src/dinoex_ruby.c
  myruby_loaded src/dinoex_ruby.c
  oIrofferEvent src/dinoex_ruby.c

Global Function do_myruby_ruby()

call the ruby class from admin chat

int do_myruby_ruby ( const userinput* const u )

Prototyped in: src/dinoex_ruby.h
Calls: get_argv2() src/dinoex_utilities.c
  iroffer_ruby_errro() src/dinoex_ruby.c
  mydelete2() src/iroffer_utilities.c
  __builtin_alloca(), rb_intern(), rb_protect(), rb_respond_to(), rb_str_new(), strlen()
Called by: a_ruby() src/dinoex_admin.c
References Functions: protect_funcall0() src/dinoex_ruby.c
References Variables: myruby_loaded src/dinoex_ruby.c
  oIrofferEvent src/dinoex_ruby.c

Global Function do_myruby_server()

push a server line to the ruby class

int do_myruby_server ( char* line )

Prototyped in: src/dinoex_ruby.h
Calls: do_on_event() src/dinoex_ruby.c
Called by: ir_parseline() src/dinoex_irc.c
References Variables: cLine src/dinoex_ruby.c
  myruby_loaded src/dinoex_ruby.c
  oIrofferEvent src/dinoex_ruby.c

Global Function do_myruby_upload_done()

call the ruby class after an upload was sucessful

int do_myruby_upload_done ( char* filename )

Prototyped in: src/dinoex_ruby.h
Calls: do_on_event() src/dinoex_ruby.c
Called by: fetch_perform() src/dinoex_curl.c
  l_istimeout() src/iroffer_upload.c
References Variables: cFile src/dinoex_ruby.c
  myruby_loaded src/dinoex_ruby.c
  oIrofferEvent src/dinoex_ruby.c

Global Function http_ruby_script()

call a ruby script as CGI via HTTP

unsigned int http_ruby_script ( const char* name, const char* output )

Prototyped in: src/dinoex_ruby.h
Calls: iroffer_ruby_errro() src/dinoex_ruby.c
  mydelete2() src/iroffer_utilities.c
  mymalloc2() src/iroffer_utilities.c
  outerror() src/iroffer_utilities.c
  updatecontext_f() src/iroffer_utilities.c
  __error(), rb_eval_string_protect(), rb_load_protect(), rb_str_new(), ruby_script(), snprintf(), stat(), strerror(), strlen()
Called by: h_runruby() src/dinoex_http.c

Global Function rehash_myruby()

reload the scrip on rehash

void rehash_myruby ( int check )

Prototyped in: src/dinoex_ruby.h
Calls: check_script() src/dinoex_ruby.c
  load_script() src/dinoex_ruby.c
Called by: mainloop() src/iroffer_main.c
  rehash_dinoex() src/dinoex_misc.c
References Variables: gdata src/dinoex_main.c

Global Function shutdown_myruby()

cleanup interpreter

void shutdown_myruby ( void )

Prototyped in: src/dinoex_ruby.h
Calls: ruby_cleanup(), ruby_finalize()
Called by: shutdown_dinoex() src/dinoex_misc.c

Global Function startup_myruby()

load the interpreter and the script

void startup_myruby ( void )
efine that callback below

Prototyped in: src/dinoex_ruby.h
Calls: Init_IrofferEvent() src/dinoex_ruby.c
  load_script() src/dinoex_ruby.c
  rb_define_global_function(), rb_eval_string_protect(), ruby_init(), ruby_init_loadpath(), ruby_init_stack(), ruby_show_version()
Called by: config_dinoex() src/dinoex_misc.c
References Functions: cie_inputline() src/dinoex_ruby.c
  cie_privmsg() src/dinoex_ruby.c
References Variables: gdata src/dinoex_main.c
  myruby_loaded src/dinoex_ruby.c

Local Function Init_IrofferEvent()

static void Init_IrofferEvent ( void )
Calls: rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_gc_register_address()
Called by: startup_myruby() src/dinoex_ruby.c
References Functions: cie_added_file() src/dinoex_ruby.c
  cie_added_pack() src/dinoex_ruby.c
  cie_channel() src/dinoex_ruby.c
  cie_command() src/dinoex_ruby.c
  cie_config() src/dinoex_ruby.c
  cie_hostmask() src/dinoex_ruby.c
  cie_info_pack() src/dinoex_ruby.c
  cie_inputline() src/dinoex_ruby.c
  cie_message() src/dinoex_ruby.c
  cie_mode() src/dinoex_ruby.c
  cie_mynick() src/dinoex_ruby.c
  cie_network() src/dinoex_ruby.c
  cie_new() src/dinoex_ruby.c
  cie_nick() src/dinoex_ruby.c
  cie_null() src/dinoex_ruby.c
  cie_privmsg() src/dinoex_ruby.c
  cie_warning() src/dinoex_ruby.c
References Variables: cIrofferEvent src/dinoex_ruby.c
  rb_cObject

Local Function check_script()

static void check_script ( const char* name )
Calls: load_script() src/dinoex_ruby.c
  outerror() src/iroffer_utilities.c
  updatecontext_f() src/iroffer_utilities.c
  __error(), stat(), strerror()
Called by: rehash_myruby() src/dinoex_ruby.c
References Variables: myruby_loaded src/dinoex_ruby.c
  myruby_time src/dinoex_ruby.c

Local Function ci_free()

static void ci_free ( void* UNUSED_p )
Used in: cie_new() src/dinoex_ruby.c

Local Function cie_added_file()

static VALUE cie_added_file ( void )
Calls: rb_str_new(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: cFile src/dinoex_ruby.c

Local Function cie_added_pack()

static VALUE cie_added_pack ( void )
Calls: rb_int2inum()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: cPack src/dinoex_ruby.c

Local Function cie_channel()

static VALUE cie_channel ( void )
Calls: getpart2() src/dinoex_utilities.c
  mydelete2() src/iroffer_utilities.c
  rb_str_new(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: cLine src/dinoex_ruby.c

Local Function cie_command()

static VALUE cie_command ( VALUE UNUSED_module, VALUE rmsg )
Calls: a_fillwith_msg2() src/dinoex_jobs.c
  ioutput() src/iroffer_utilities.c
  mydelete2() src/iroffer_utilities.c
  mymalloc2() src/iroffer_utilities.c
  rb_obj_as_string_protected() src/dinoex_ruby.c
  u_parseit() src/iroffer_admin.c
  rb_ary_join(), rb_str_new2(), rb_type()
Used in: Init_IrofferEvent() src/dinoex_ruby.c

Local Function cie_config()

static VALUE cie_config ( VALUE UNUSED_module, VALUE rkey )
Calls: mydelete2() src/iroffer_utilities.c
  print_config_key() src/dinoex_config.c
  rb_obj_as_string_protected() src/dinoex_ruby.c
  rb_str_new(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c

Local Function cie_hostmask()

static VALUE cie_hostmask ( void )
Calls: getpart2() src/dinoex_utilities.c
  mydelete2() src/iroffer_utilities.c
  rb_str_new(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: cLine src/dinoex_ruby.c

Local Function cie_info_pack()

static VALUE cie_info_pack ( VALUE UNUSED_module, VALUE rnr, VALUE rkey )
Calls: find_groupdesc() src/dinoex_jobs.c
  get_xdcc_pack() src/dinoex_misc.c
  getfilename() src/dinoex_utilities.c
  irlist_size() src/iroffer_utilities.c
  mydelete2() src/iroffer_utilities.c
  mymalloc2() src/iroffer_utilities.c
  rb_obj_as_string_protected() src/dinoex_ruby.c
  sizestr() src/dinoex_utilities.c
  rb_fix2uint(), rb_int2inum(), rb_str_new(), rb_time_new(), rb_uint2inum(), snprintf(), strcmp(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: gdata src/dinoex_main.c

Local Function cie_inputline()

static VALUE cie_inputline ( void )
Calls: rb_str_new(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
  startup_myruby() src/dinoex_ruby.c
References Variables: cLine src/dinoex_ruby.c

Local Function cie_message()

static VALUE cie_message ( void )
Calls: getpart_eol() src/dinoex_utilities.c
  mydelete2() src/iroffer_utilities.c
  rb_str_new(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: cLine src/dinoex_ruby.c

Local Function cie_mode()

static VALUE cie_mode ( VALUE UNUSED_module, VALUE rname, VALUE rmsg )
Calls: irlist_get_head() src/iroffer_utilities.c
  irlist_get_next() src/iroffer_utilities.c
  rb_obj_as_string_protected() src/dinoex_ruby.c
  writeserver() src/iroffer_misc.c
  strcasecmp()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: gnetwork src/dinoex_main.c

Local Function cie_mynick()

static VALUE cie_mynick ( void )
Calls: get_user_nick() src/dinoex_irc.c
  rb_str_new(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c

Local Function cie_network()

static VALUE cie_network ( void )
Calls: rb_str_new(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: gnetwork src/dinoex_main.c

Local Function cie_new()

static VALUE cie_new ( VALUE rclass )
Calls: rb_data_object_alloc(), rb_obj_call_init()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Functions: ci_free() src/dinoex_ruby.c
References Variables: gdata src/dinoex_main.c

Local Function cie_nick()

static VALUE cie_nick ( void )
Calls: getpart2() src/dinoex_utilities.c
  mydelete2() src/iroffer_utilities.c
  rb_str_new(), strchr(), strlen()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
References Variables: cLine src/dinoex_ruby.c

Local Function cie_null()

static VALUE cie_null ( VALUE UNUSED_self )
Used in: Init_IrofferEvent() src/dinoex_ruby.c

Local Function cie_privmsg()

static VALUE cie_privmsg ( VALUE UNUSED_module, VALUE rname, VALUE rmsg )
Calls: irlist_get_head() src/iroffer_utilities.c
  irlist_get_next() src/iroffer_utilities.c
  privmsg_chan() src/dinoex_jobs.c
  privmsg_slow() src/iroffer_utilities.c
  rb_obj_as_string_protected() src/dinoex_ruby.c
  strcasecmp()
Used in: Init_IrofferEvent() src/dinoex_ruby.c
  startup_myruby() src/dinoex_ruby.c
References Variables: gnetwork src/dinoex_main.c

Local Function cie_warning()

static VALUE cie_warning ( VALUE UNUSED_module, VALUE rmsg )
Calls: outerror() src/iroffer_utilities.c
  rb_obj_as_string_protected() src/dinoex_ruby.c
Used in: Init_IrofferEvent() src/dinoex_ruby.c

Local Function do_on_event()

static unsigned int do_on_event ( VALUE userobject, const char* event )
Calls: rb_funcall_protected() src/dinoex_ruby.c
  rb_intern(), rb_respond_to()
Called by: do_myruby_added() src/dinoex_ruby.c
  do_myruby_notice() src/dinoex_ruby.c
  do_myruby_packlist() src/dinoex_ruby.c
  do_myruby_privmsg() src/dinoex_ruby.c
  do_myruby_server() src/dinoex_ruby.c
  do_myruby_upload_done() src/dinoex_ruby.c

Local Function iroffer_ruby_errro()

static void iroffer_ruby_errro ( int error )
Calls: outerror() src/iroffer_utilities.c
  rb_errinfo() src/dinoex_ruby.c
  rb_class_of(), rb_class_path(), rb_funcall(), rb_gv_get(), rb_intern(), rb_obj_as_string()
Called by: do_myruby_ruby() src/dinoex_ruby.c
  http_ruby_script() src/dinoex_ruby.c
  rb_funcall_protected() src/dinoex_ruby.c
  rb_obj_as_string_protected() src/dinoex_ruby.c

Local Function load_script()

static void load_script ( const char* name )
Calls: outerror() src/iroffer_utilities.c
  updatecontext_f() src/iroffer_utilities.c
  __error(), rb_class_new_instance(), rb_define_variable(), rb_load_protect(), rb_str_new(), ruby_script(), stat(), strerror(), strlen()
Called by: check_script() src/dinoex_ruby.c
  rehash_myruby() src/dinoex_ruby.c
  startup_myruby() src/dinoex_ruby.c
References Variables: cIrofferEvent src/dinoex_ruby.c
  myruby_loaded src/dinoex_ruby.c
  myruby_time src/dinoex_ruby.c
  oIrofferEvent src/dinoex_ruby.c

Local Function protect_funcall0()

static VALUE protect_funcall0 ( VALUE val )
Calls: rb_funcall2()
Used in: do_myruby_ruby() src/dinoex_ruby.c
  rb_funcall_protected() src/dinoex_ruby.c

Local Function rb_errinfo()

static VALUE rb_errinfo ( void )
Called by: iroffer_ruby_errro() src/dinoex_ruby.c
References Variables: ruby_errinfo

Local Function rb_funcall_protected()

static VALUE rb_funcall_protected ( VALUE recvobj, ID mid, int argc, ... )
Calls: iroffer_ruby_errro() src/dinoex_ruby.c
  __builtin_alloca(), __builtin_va_arg(), __builtin_va_end(), __builtin_va_start(), rb_protect()
Called by: do_on_event() src/dinoex_ruby.c
References Functions: protect_funcall0() src/dinoex_ruby.c

Local Function rb_obj_as_string_protected()

static char* rb_obj_as_string_protected ( VALUE objval )
Calls: iroffer_ruby_errro() src/dinoex_ruby.c
  rb_protect(), rb_string_value_ptr()
Called by: cie_command() src/dinoex_ruby.c
  cie_config() src/dinoex_ruby.c
  cie_info_pack() src/dinoex_ruby.c
  cie_mode() src/dinoex_ruby.c
  cie_privmsg() src/dinoex_ruby.c
  cie_warning() src/dinoex_ruby.c
References Functions: rb_obj_as_string()