-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathxchat-ruby.c
More file actions
897 lines (690 loc) · 24.9 KB
/
xchat-ruby.c
File metadata and controls
897 lines (690 loc) · 24.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
/* --------------------------------------------------------------------------
* xchat-ruby.c -- glue code between Ruby interpreter and XChat plugin API
* Copyright (C) 2003 Jamis Buck (jgb3@email.byu.edu)
* --------------------------------------------------------------------------
* This file is part of the XChat-Ruby plugin.
*
* The XChat-Ruby plugin is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The XChat-Ruby plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the XChat-Ruby plugin; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* --------------------------------------------------------------------------
* This is the glue code between the Ruby interpreter and the XChat plugin
* API.
*
* Author: Jamis Buck (jgb3@email.byu.edu)
* Date: June 2003
* -------------------------------------------------------------------------- */
#include <stdio.h>
#include <stdlib.h>
#include "ruby.h"
#include "lib/xchat-plugin.h"
#include "lib/xchat-ruby-plugin.h" /* this is the ruby code as a #define */
/* ``global'' variables (global to the XChat-Ruby plugin) {{{ */
static xchat_plugin *static_plugin_handle = NULL;
static xchat_plugin *ph = NULL;
static int static_ruby_initialized = 0;
static VALUE static_xchat_module;
static VALUE static_xchat_klass;
static VALUE static_xchat_list_klass;
static VALUE static_xchat_hook_klass;
static VALUE static_xchat_context_klass;
static VALUE static_xchat_list_internal_klass;
static ID static_xchat_process_command_hook;
static ID static_xchat_process_print_hook;
static ID static_xchat_process_server_hook;
static ID static_xchat_process_timer_hook;
/*}}}*/
/* private method declarations {{{*/
/**
* Initializes the ruby environment.
*/
static void static_init_ruby_environment( void );
/**
* Initializes the XChat environment.
*/
static void static_init_xchat_environment( xchat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version );
/**
* Ruby callback function for adding a new callback hook for a
* command.
*/
static VALUE static_ruby_xchat_hook_command( VALUE klass,
VALUE name,
VALUE priority,
VALUE help );
/**
* Ruby callback function for adding a new callback hook for a
* print event.
*/
static VALUE static_ruby_xchat_hook_print( VALUE klass,
VALUE name,
VALUE priority );
/**
* Ruby callback function for adding a new callback hook for a
* server event.
*/
static VALUE static_ruby_xchat_hook_server( VALUE klass,
VALUE name,
VALUE priority );
/**
* Ruby callback function for adding a new callback hook for a
* timer event.
*/
static VALUE static_ruby_xchat_hook_timer( VALUE klass,
VALUE name,
VALUE timeout );
/**
* Ruby callback function for printing text to an XChat window.
*/
static VALUE static_ruby_xchat_print( VALUE klass,
VALUE text );
/**
* Ruby callback function for removing a callback hook.
*/
static VALUE static_ruby_xchat_unhook( VALUE klass,
VALUE hook_id );
/**
* Ruby callback function for invoking a command
*/
static VALUE static_ruby_xchat_command( VALUE klass,
VALUE command );
/**
* Ruby callback function for searching for a specified context.
*/
static VALUE static_ruby_xchat_find_context( VALUE klass,
VALUE server,
VALUE channel );
/**
* Ruby callback function for getting the current XChat context.
*/
static VALUE static_ruby_xchat_get_context( VALUE klass );
/**
* Ruby callback function for getting a named information value.
*/
static VALUE static_ruby_xchat_get_info( VALUE klass,
VALUE id );
/**
* Ruby callback function for getting a named user preference.
*/
static VALUE static_ruby_xchat_get_prefs( VALUE klass,
VALUE name );
/**
* Ruby callback function for setting the current XChat context.
*/
static VALUE static_ruby_xchat_set_context( VALUE klass,
VALUE ctx );
/**
* Ruby callback function for comparing two nicks.
*/
static VALUE static_ruby_xchat_nickcmp( VALUE klass,
VALUE s1,
VALUE s2 );
/**
* Ruby callback function for getting a named list.
*/
static VALUE static_ruby_xchat_list_get( VALUE klass,
VALUE name );
/**
* Ruby callback function for moving to the next value in
* a named list.
*/
static VALUE static_ruby_xchat_list_next( VALUE klass,
VALUE list );
/**
* Ruby callback function for getting a named field from
* a list as a string value.
*/
static VALUE static_ruby_xchat_list_str( VALUE klass,
VALUE list,
VALUE name );
/**
* Ruby callback function for getting a named field from
* a list as an integer value.
*/
static VALUE static_ruby_xchat_list_int( VALUE klass,
VALUE list,
VALUE name );
/**
* Ruby callback function for emitting a print event.
*/
static VALUE static_ruby_xchat_emit_print( int argc,
VALUE *argv,
VALUE klass );
/**
* XChat callbook hook for handling a custom command written
* in Ruby.
*/
static int static_ruby_custom_command_hook( char *word[],
char *word_eol[],
void *userdata );
/**
* XChat callbook hook for handling a custom print event
* handler written in Ruby.
*/
static int static_ruby_custom_print_hook( char *word[],
void *userdata );
/**
* XChat callbook hook for handling a custom server event
* handler written in Ruby.
*/
static int static_ruby_custom_server_hook( char *word[],
char *word_eol[],
void *userdata );
/**
* XChat callbook hook for handling a custom timer event
* handler written in Ruby.
*/
static int static_ruby_custom_timer_hook( void *userdata );
/**
* Callback for destroying a list when Ruby garbage collects
* the associated XChatListInternal object.
*/
static void static_free_xchat_list( xchat_list *list );
/*}}}*/
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 );
}
static void static_init_xchat_environment( xchat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version )
{
*plugin_name = "XChat-Ruby";
*plugin_desc = "Allows the Ruby interpreter to be interactively called from XChat, "
"and for XChat plugins to be written in Ruby.";
*plugin_version = "1.1";
}
static VALUE static_ruby_xchat_hook_command( VALUE klass,
VALUE name,
VALUE priority,
VALUE help )
{
char *s_name;
char *s_help;
int i_priority;
xchat_hook *hook;
VALUE v_hook;
Check_Type( name, T_STRING );
Check_Type( priority, T_FIXNUM );
Check_Type( help, T_STRING );
s_name = StringValueCStr( name );
i_priority = FIX2INT( priority );
s_help = StringValueCStr( help );
hook = xchat_hook_command( static_plugin_handle,
s_name,
i_priority,
static_ruby_custom_command_hook,
s_help,
NULL );
v_hook = Data_Wrap_Struct( static_xchat_hook_klass,
NULL, NULL,
hook );
return v_hook;
}
static VALUE static_ruby_xchat_hook_print( VALUE klass,
VALUE name,
VALUE priority )
{
char *s_name;
int i_priority;
xchat_hook *hook;
VALUE v_hook;
Check_Type( name, T_STRING );
Check_Type( priority, T_FIXNUM );
s_name = StringValueCStr( name );
i_priority = FIX2INT( priority );
hook = xchat_hook_print( static_plugin_handle,
s_name,
i_priority,
static_ruby_custom_print_hook,
(void*)name );
v_hook = Data_Wrap_Struct( static_xchat_hook_klass,
NULL, NULL,
hook );
return v_hook;
}
static VALUE static_ruby_xchat_hook_server( VALUE klass,
VALUE name,
VALUE priority )
{
char *s_name;
int i_priority;
xchat_hook *hook;
VALUE v_hook;
Check_Type( name, T_STRING );
Check_Type( priority, T_FIXNUM );
s_name = StringValueCStr( name );
i_priority = FIX2INT( priority );
hook = xchat_hook_server( static_plugin_handle,
s_name,
i_priority,
static_ruby_custom_server_hook,
NULL );
v_hook = Data_Wrap_Struct( static_xchat_hook_klass,
NULL, NULL,
hook );
return v_hook;
}
static VALUE static_ruby_xchat_hook_timer( VALUE klass,
VALUE name,
VALUE timeout )
{
char *s_name;
int i_timeout;
xchat_hook *hook;
VALUE v_hook;
Check_Type( name, T_STRING );
Check_Type( timeout, T_FIXNUM );
s_name = StringValueCStr( name );
i_timeout = FIX2INT( timeout );
hook = xchat_hook_timer( static_plugin_handle,
i_timeout,
static_ruby_custom_timer_hook,
(void*)name );
v_hook = Data_Wrap_Struct( static_xchat_hook_klass,
NULL, NULL,
hook );
return v_hook;
}
static VALUE static_ruby_xchat_print( VALUE klass,
VALUE text )
{
char *s_text;
Check_Type( text, T_STRING );
s_text = StringValueCStr( text );
xchat_print( static_plugin_handle, s_text );
return Qnil;
}
static VALUE static_ruby_xchat_unhook( VALUE klass,
VALUE hook_id )
{
xchat_hook *hook;
Data_Get_Struct( hook_id, xchat_hook, hook );
xchat_unhook( static_plugin_handle, hook );
return Qnil;
}
static VALUE static_ruby_xchat_command( VALUE klass,
VALUE command )
{
char *cmd;
Check_Type( command, T_STRING );
cmd = StringValueCStr( command );
xchat_command( static_plugin_handle,
cmd );
return Qnil;
}
static VALUE static_ruby_xchat_find_context( VALUE klass,
VALUE server,
VALUE channel )
{
char *s_server = NULL;
char *s_channel = NULL;
xchat_context *ctx;
VALUE v_ctx;
if( !NIL_P( server ) ) s_server = StringValueCStr( server );
if( !NIL_P( channel ) ) s_channel = StringValueCStr( channel );
ctx = xchat_find_context( static_plugin_handle,
s_server,
s_channel );
if( ctx == NULL )
return Qnil;
v_ctx = Data_Wrap_Struct( static_xchat_context_klass,
NULL, NULL,
ctx );
return v_ctx;
}
static VALUE static_ruby_xchat_get_context( VALUE klass )
{
xchat_context *ctx;
VALUE v_ctx;
ctx = xchat_get_context( static_plugin_handle );
v_ctx = Data_Wrap_Struct( static_xchat_context_klass,
NULL, NULL,
ctx );
return v_ctx;
}
static VALUE static_ruby_xchat_get_info( VALUE klass,
VALUE id )
{
char *s_id;
const char *s_info;
s_id = StringValueCStr( id );
s_info = xchat_get_info( static_plugin_handle, s_id );
if( s_info == NULL ) return Qnil;
return rb_str_new2( s_info );
}
static VALUE static_ruby_xchat_get_prefs( VALUE klass,
VALUE name )
{
char *s_name;
char *s_pref;
int i_pref;
int rc;
s_name = StringValueCStr( name );
rc = xchat_get_prefs( static_plugin_handle,
s_name,
(const char**)&s_pref, &i_pref );
switch( rc )
{
case 0: /* failed */
return Qnil;
case 1: /* returned a string */
return rb_str_new2( s_pref );
case 2: /* returned an int */
return INT2FIX( i_pref );
case 3: /* returned a bool */
return ( i_pref ? Qtrue : Qfalse );
}
return Qnil;
}
static VALUE static_ruby_xchat_set_context( VALUE klass,
VALUE ctx )
{
xchat_context *context;
int rc;
Data_Get_Struct( ctx, xchat_context, context );
rc = xchat_set_context( static_plugin_handle,
context );
return INT2FIX( rc );
}
static VALUE static_ruby_xchat_nickcmp( VALUE klass,
VALUE s1,
VALUE s2 )
{
char *s_s1;
char *s_s2;
s_s1 = StringValueCStr( s1 );
s_s2 = StringValueCStr( s2 );
return INT2FIX( xchat_nickcmp( static_plugin_handle, s_s1, s_s2 ) );
}
static VALUE static_ruby_xchat_list_get( VALUE klass,
VALUE name )
{
xchat_list *list;
char *s_name;
VALUE v_list;
s_name = StringValueCStr( name );
list = xchat_list_get( static_plugin_handle, s_name );
if( list == NULL )
return Qnil;
v_list = Data_Wrap_Struct( static_xchat_list_internal_klass,
NULL, static_free_xchat_list,
list );
return v_list;
}
static VALUE static_ruby_xchat_list_next( VALUE klass,
VALUE list )
{
xchat_list *x_list;
int rc;
Data_Get_Struct( list, xchat_list, x_list );
if( x_list == NULL )
return Qfalse;
rc = xchat_list_next( static_plugin_handle, x_list );
return ( rc ? Qtrue : Qfalse );
}
static VALUE static_ruby_xchat_list_str( VALUE klass,
VALUE list,
VALUE name )
{
xchat_list *x_list;
char *str;
char *s_name;
Data_Get_Struct( list, xchat_list, x_list );
s_name = StringValueCStr( name );
str = (char*)xchat_list_str( static_plugin_handle, x_list, (const char*)s_name );
if( str == NULL )
return Qnil;
return rb_str_new2( str );
}
static VALUE static_ruby_xchat_list_int( VALUE klass,
VALUE list,
VALUE name )
{
xchat_list *x_list;
int rc;
char *s_name;
Data_Get_Struct( list, xchat_list, x_list );
s_name = StringValueCStr( name );
rc = xchat_list_int( static_plugin_handle, x_list, s_name );
return INT2FIX( rc );
}
static VALUE static_ruby_xchat_emit_print( int argc,
VALUE *argv,
VALUE klass )
{
char *event;
char *parms[16];
int i;
printf( "[argc: %d]\n", argc );
if( argc < 1 )
return Qfalse;
event = StringValueCStr( argv[0] );
for( i = 1; i < 16; i++ )
{
if( i >= argc ) parms[i-1] = NULL;
else parms[i-1] = StringValueCStr( argv[i] );
}
i = xchat_emit_print( static_plugin_handle,
event,
parms[ 0], parms[ 1], parms[ 2], parms[ 3],
parms[ 4], parms[ 5], parms[ 6], parms[ 7],
parms[ 8], parms[ 9], parms[10], parms[11],
parms[12], parms[13], parms[14], parms[15],
NULL );
return ( i ? Qtrue : Qfalse );
}
static int static_ruby_custom_command_hook( char *word[],
char *word_eol[],
void *userdata )
{
VALUE rb_word;
VALUE rb_word_eol;
VALUE rc;
int i;
rb_word = rb_ary_new();
rb_word_eol = rb_ary_new();
for( i = 1; word[i][0] != '\0'; i++ )
{
rb_ary_push( rb_word, rb_str_new2( word[i] ) );
rb_ary_push( rb_word_eol, rb_str_new2( word_eol[i] ) );
}
rc = rb_funcall( static_xchat_klass,
static_xchat_process_command_hook,
3,
rb_ary_entry( rb_word, 0 ),
rb_word,
rb_word_eol );
return FIX2INT( rc );
}
static int static_ruby_custom_print_hook( char *word[],
void *userdata )
{
VALUE rb_name;
VALUE rb_word;
VALUE rc;
int i;
rb_name = (VALUE)userdata;
rb_word = rb_ary_new();
for( i = 1; word[i] && word[i][0] != '\0'; i++ )
{
rb_ary_push( rb_word, rb_str_new2( word[i] ) );
}
rc = rb_funcall( static_xchat_klass,
static_xchat_process_print_hook,
2,
rb_name,
rb_word );
return FIX2INT( rc );
}
static int static_ruby_custom_server_hook( char *word[],
char *word_eol[],
void *userdata )
{
VALUE rb_word;
VALUE rb_word_eol;
VALUE rc;
int i;
rb_word = rb_ary_new();
rb_word_eol = rb_ary_new();
for( i = 1; word[i][0] != '\0'; i++ )
{
rb_ary_push( rb_word, rb_str_new2( word[i] ) );
rb_ary_push( rb_word_eol, rb_str_new2( word_eol[i] ) );
}
rc = rb_funcall( static_xchat_klass,
static_xchat_process_server_hook,
3,
rb_ary_entry( rb_word, 1 ),
rb_word,
rb_word_eol );
return FIX2INT( rc );
}
static int static_ruby_custom_timer_hook( void *userdata )
{
VALUE rc;
VALUE name;
name = (VALUE)userdata;
rc = rb_funcall( static_xchat_klass,
static_xchat_process_timer_hook,
1,
name );
return FIX2INT( rc );
}
static void static_free_xchat_list( xchat_list *list )
{
xchat_list_free( static_plugin_handle, list );
}
int xchat_plugin_init(xchat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version,
char *arg)
{
ph = static_plugin_handle = plugin_handle;
static_init_xchat_environment( plugin_handle,
plugin_name,
plugin_desc,
plugin_version );
static_init_ruby_environment();
xchat_print( static_plugin_handle,
"Ruby interface loaded\n" );
return 1;
}
int xchat_plugin_deinit()
{
rb_funcall( static_xchat_klass,
rb_intern( "unregister" ),
0 );
return 1;
}