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
|
#define PERL_NO_GET_CONTEXT
#include "module.h"
#include "irssi-version.h"
#include "core.h"
#include "pidwait.h"
#include "session.h"
#define DEFAULT_COMMAND_CATEGORY "Perl scripts' commands"
static void perl_signal_add_hash(int priority, SV *sv)
{
HV *hv;
HE *he;
I32 len;
if (!is_hvref(sv))
croak("Usage: Irssi::signal_add(hash)");
hv = hvref(sv);
hv_iterinit(hv);
while ((he = hv_iternext(hv)) != NULL)
perl_signal_add_full(hv_iterkey(he, &len), HeVAL(he), priority);
}
static void perl_command_bind_add_hash(int priority, SV *sv, char *category)
{
HV *hv;
HE *he;
I32 len;
hv = hvref(sv);
hv_iterinit(hv);
while ((he = hv_iternext(hv)) != NULL)
perl_command_bind_to(hv_iterkey(he, &len), category, HeVAL(he), priority);
}
static void handle_command_bind(int priority, int items, SV *p0, SV *p1, SV *p2)
{
char *category;
int hash;
hash = items > 0 && is_hvref(p0);
if (!hash) {
if (items < 2 || items > 3)
croak("Usage: Irssi::command_bind(signal, func, category)");
} else if (items > 2)
croak("Usage: Irssi::command_bind(signals_hash, category)");
if (!hash) {
category = items < 3 ? DEFAULT_COMMAND_CATEGORY :
SvPV_nolen(p2);
perl_command_bind_to(SvPV_nolen(p0), category, p1, priority);
} else {
category = items < 2 ? DEFAULT_COMMAND_CATEGORY :
SvPV_nolen(p1);
perl_command_bind_add_hash(priority, p0, category);
}
}
static void add_tuple(gpointer key_, gpointer value_, gpointer user_data)
{
HV *hash = user_data;
char *key = key_;
char *value = value_;
(void) hv_store(hash, key, strlen(key), new_pv(value), 0);
}
static void wrap_signal_emit(void *signal, void **p) {
signal_emit(signal, 6, p[0], p[1], p[2], p[3], p[4], p[5]);
}
static void wrap_signal_continue(void *dummy, void **p) {
(void)dummy;
signal_continue(6, p[0], p[1], p[2], p[3], p[4], p[5]);
}
MODULE = Irssi::Core PACKAGE = Irssi
PROTOTYPES: ENABLE
void
signal_emit(signal, ...)
char *signal
CODE:
int signal_id;
SV *args[SIGNAL_MAX_ARGUMENTS];
int n, used;
signal_id = signal_get_uniq_id(signal);
used = items - 1;
if (used > SIGNAL_MAX_ARGUMENTS) {
used = SIGNAL_MAX_ARGUMENTS;
}
for (n = 0; n < used; ++n) {
args[n] = ST(n + 1);
}
perl_signal_args_to_c(wrap_signal_emit, signal, signal_id, args, used);
void
signal_continue(...)
CODE:
SV *args[SIGNAL_MAX_ARGUMENTS];
int n, used;
used = items;
if (used > SIGNAL_MAX_ARGUMENTS) {
used = SIGNAL_MAX_ARGUMENTS;
}
for (n = 0; n < used; ++n) {
args[n] = ST(n);
}
perl_signal_args_to_c(wrap_signal_continue, NULL, signal_get_emitted_id(), args, used);
void
signal_add(...)
CODE:
if (items != 1 && items != 2)
croak("Usage: Irssi::signal_add(signal, func)");
if (items == 2)
perl_signal_add_full(SvPV_nolen(ST(0)), ST(1),
SIGNAL_PRIORITY_DEFAULT);
else
perl_signal_add_hash(SIGNAL_PRIORITY_DEFAULT, ST(0));
void
signal_add_first(...)
CODE:
if (items != 1 && items != 2)
croak("Usage: Irssi::signal_add_first(signal, func)");
if (items == 2)
perl_signal_add_full(SvPV_nolen(ST(0)), ST(1),
SIGNAL_PRIORITY_HIGH);
else
perl_signal_add_hash(SIGNAL_PRIORITY_HIGH, ST(0));
void
signal_add_last(...)
CODE:
if (items != 1 && items != 2)
croak("Usage: Irssi::signal_add_last(signal, func)");
if (items == 2)
perl_signal_add_full(SvPV_nolen(ST(0)), ST(1),
SIGNAL_PRIORITY_LOW);
else
perl_signal_add_hash(SIGNAL_PRIORITY_LOW, ST(0));
void
signal_add_priority(...)
CODE:
if (items != 2 && items != 3)
croak("Usage: Irssi::signal_add_priority(signal, func, priority)");
if (items == 3)
perl_signal_add_full(SvPV_nolen(ST(0)), ST(1), SvIV(ST(2)));
else
perl_signal_add_hash(SvIV(ST(0)), ST(1));
void
signal_register(...)
PREINIT:
HV *hv;
HE *he;
I32 len, pos;
const char *arr[7];
CODE:
if (items != 1 || !is_hvref(ST(0)))
croak("Usage: Irssi::signal_register(hash)");
hv = hvref(ST(0));
hv_iterinit(hv);
while ((he = hv_iternext(hv)) != NULL) {
const char *key = hv_iterkey(he, &len);
SV *val = HeVAL(he);
AV *av;
if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVAV)
croak("not array reference");
av = (AV *) SvRV(val);
len = av_len(av)+1;
if (len > 6) len = 6;
for (pos = 0; pos < len; pos++) {
SV **val = av_fetch(av, pos, 0);
arr[pos] = SvPV_nolen(*val);
}
arr[pos] = NULL;
perl_signal_register(key, arr);
}
int
SIGNAL_PRIORITY_LOW()
CODE:
RETVAL = SIGNAL_PRIORITY_LOW;
OUTPUT:
RETVAL
int
SIGNAL_PRIORITY_DEFAULT()
CODE:
RETVAL = SIGNAL_PRIORITY_DEFAULT;
OUTPUT:
RETVAL
int
SIGNAL_PRIORITY_HIGH()
CODE:
RETVAL = SIGNAL_PRIORITY_HIGH;
OUTPUT:
RETVAL
void
signal_remove(signal, func)
char *signal
SV *func
CODE:
perl_signal_remove(signal, func);
void
signal_stop()
void
signal_stop_by_name(signal)
char *signal
char *
signal_get_emitted()
CODE:
RETVAL = (char *) signal_get_emitted();
OUTPUT:
RETVAL
int
signal_get_emitted_id()
int
timeout_add(msecs, func, data)
int msecs
SV *func
SV *data
CODE:
if (msecs < 10) {
croak("Irssi::timeout() : msecs must be >= 10");
RETVAL = -1;
} else {
RETVAL = perl_timeout_add(msecs, func, data, FALSE);
}
OUTPUT:
RETVAL
int
timeout_add_once(msecs, func, data)
int msecs
SV *func
SV *data
CODE:
if (msecs < 10) {
croak("Irssi::timeout_once() : msecs must be >= 10");
RETVAL = -1;
} else {
RETVAL = perl_timeout_add(msecs, func, data, TRUE);
}
OUTPUT:
RETVAL
void
timeout_remove(tag)
int tag
CODE:
perl_source_remove(tag);
int
INPUT_READ()
CODE:
RETVAL = G_INPUT_READ;
OUTPUT:
RETVAL
int
INPUT_WRITE()
CODE:
RETVAL = G_INPUT_WRITE;
OUTPUT:
RETVAL
int
input_add(source, condition, func, data)
int source
int condition
SV *func
SV *data
CODE:
RETVAL = perl_input_add(source, condition, func, data, FALSE);
OUTPUT:
RETVAL
void
input_remove(tag)
int tag
CODE:
perl_source_remove(tag);
# maybe there's some easier way than this..? :)
int
MSGLEVEL_CRAP()
CODE:
RETVAL = MSGLEVEL_CRAP;
OUTPUT:
RETVAL
int
MSGLEVEL_MSGS()
CODE:
RETVAL = MSGLEVEL_MSGS;
OUTPUT:
RETVAL
int
MSGLEVEL_PUBLIC()
CODE:
RETVAL = MSGLEVEL_PUBLIC;
OUTPUT:
RETVAL
int
MSGLEVEL_NOTICES()
CODE:
RETVAL = MSGLEVEL_NOTICES;
OUTPUT:
RETVAL
int
MSGLEVEL_SNOTES()
CODE:
RETVAL = MSGLEVEL_SNOTES;
OUTPUT:
RETVAL
int
MSGLEVEL_CTCPS()
CODE:
RETVAL = MSGLEVEL_CTCPS;
OUTPUT:
RETVAL
int
MSGLEVEL_ACTIONS()
CODE:
RETVAL = MSGLEVEL_ACTIONS;
OUTPUT:
RETVAL
int
MSGLEVEL_JOINS()
CODE:
RETVAL = MSGLEVEL_JOINS;
OUTPUT:
RETVAL
int
MSGLEVEL_PARTS()
CODE:
RETVAL = MSGLEVEL_PARTS;
OUTPUT:
RETVAL
int
MSGLEVEL_QUITS()
CODE:
RETVAL = MSGLEVEL_QUITS;
OUTPUT:
RETVAL
int
MSGLEVEL_KICKS()
CODE:
RETVAL = MSGLEVEL_KICKS;
OUTPUT:
RETVAL
int
MSGLEVEL_MODES()
CODE:
RETVAL = MSGLEVEL_MODES;
OUTPUT:
RETVAL
int
MSGLEVEL_TOPICS()
CODE:
RETVAL = MSGLEVEL_TOPICS;
OUTPUT:
RETVAL
int
MSGLEVEL_WALLOPS()
CODE:
RETVAL = MSGLEVEL_WALLOPS;
OUTPUT:
RETVAL
int
MSGLEVEL_INVITES()
CODE:
RETVAL = MSGLEVEL_INVITES;
OUTPUT:
RETVAL
int
MSGLEVEL_NICKS()
CODE:
RETVAL = MSGLEVEL_NICKS;
OUTPUT:
RETVAL
int
MSGLEVEL_DCC()
CODE:
RETVAL = MSGLEVEL_DCC;
OUTPUT:
RETVAL
int
MSGLEVEL_DCCMSGS()
CODE:
RETVAL = MSGLEVEL_DCCMSGS;
OUTPUT:
RETVAL
int
MSGLEVEL_CLIENTNOTICE()
CODE:
RETVAL = MSGLEVEL_CLIENTNOTICE;
OUTPUT:
RETVAL
int
MSGLEVEL_CLIENTCRAP()
CODE:
RETVAL = MSGLEVEL_CLIENTCRAP;
OUTPUT:
RETVAL
int
MSGLEVEL_CLIENTERROR()
CODE:
RETVAL = MSGLEVEL_CLIENTERROR;
OUTPUT:
RETVAL
int
MSGLEVEL_HILIGHT()
CODE:
RETVAL = MSGLEVEL_HILIGHT;
OUTPUT:
RETVAL
int
MSGLEVEL_ALL()
CODE:
RETVAL = MSGLEVEL_ALL;
OUTPUT:
RETVAL
int
MSGLEVEL_NOHILIGHT()
CODE:
RETVAL = MSGLEVEL_NOHILIGHT;
OUTPUT:
RETVAL
int
MSGLEVEL_NO_ACT()
CODE:
RETVAL = MSGLEVEL_NO_ACT;
OUTPUT:
RETVAL
int
MSGLEVEL_NEVER()
CODE:
RETVAL = MSGLEVEL_NEVER;
OUTPUT:
RETVAL
int
MSGLEVEL_LASTLOG()
CODE:
RETVAL = MSGLEVEL_LASTLOG;
OUTPUT:
RETVAL
int
level2bits(str)
char *str
CODE:
RETVAL = level2bits(str, NULL);
OUTPUT:
RETVAL
void
bits2level(bits)
int bits
PREINIT:
char *ret;
PPCODE:
ret = bits2level(bits);
XPUSHs(sv_2mortal(new_pv(ret)));
g_free(ret);
int
combine_level(level, str)
int level
char *str
void
command(cmd)
char *cmd
CODE:
perl_command(cmd, NULL, NULL);
void
commands()
PREINIT:
GSList *tmp;
PPCODE:
for (tmp = commands; tmp != NULL; tmp = tmp->next) {
XPUSHs(sv_2mortal(plain_bless(tmp->data, "Irssi::Command")));
}
void
command_bind_first(...)
CODE:
handle_command_bind(SIGNAL_PRIORITY_HIGH, items, ST(0), ST(1), ST(2));
void
command_bind(...)
CODE:
handle_command_bind(SIGNAL_PRIORITY_DEFAULT, items, ST(0), ST(1), ST(2));
void
command_bind_last(...)
CODE:
handle_command_bind(SIGNAL_PRIORITY_LOW, items, ST(0), ST(1), ST(2));
void
command_runsub(cmd, data, server, item)
char *cmd
char *data
Irssi::Server server
Irssi::Windowitem item
CODE:
perl_command_runsub(cmd, data, server, item);
void
command_unbind(cmd, func)
char *cmd
SV *func
CODE:
perl_command_unbind(cmd, func);
void
command_set_options(cmd, options)
char *cmd
char *options
void
command_parse_options(cmd, data)
char *cmd
char *data
PREINIT:
HV *hash;
GHashTable *optlist;
void *free_arg;
char *ptr;
PPCODE:
if (cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
cmd, &optlist, &ptr)) {
hash = newHV();
g_hash_table_foreach(optlist, add_tuple, hash);
XPUSHs(sv_2mortal(newRV_noinc((SV*)hash)));
XPUSHs(sv_2mortal(new_pv(ptr)));
cmd_params_free(free_arg);
} else {
XPUSHs(&PL_sv_undef);
XPUSHs(&PL_sv_undef);
}
void
pidwait_add(pid)
int pid
void
pidwait_remove(pid)
int pid
void
parse_special(cmd, data="", flags=0)
char *cmd
char *data
int flags
PREINIT:
char *ret;
PPCODE:
ret = parse_special_string(cmd, NULL, NULL, data, NULL, flags);
XPUSHs(sv_2mortal(new_pv(ret)));
g_free_not_null(ret);
char *
get_irssi_dir()
CODE:
RETVAL = (char *) get_irssi_dir();
OUTPUT:
RETVAL
char *
get_irssi_config()
CODE:
RETVAL = (char *) get_irssi_config();
OUTPUT:
RETVAL
char *
get_irssi_binary()
CODE:
RETVAL = irssi_binary;
OUTPUT:
RETVAL
char *
version()
PREINIT:
char version[100];
CODE:
g_snprintf(version, sizeof(version), "%d.%04d",
IRSSI_VERSION_DATE, IRSSI_VERSION_TIME);
RETVAL = version;
OUTPUT:
RETVAL
int
get_gui()
CODE:
RETVAL = irssi_gui;
OUTPUT:
RETVAL
int
IRSSI_GUI_NONE()
CODE:
RETVAL = IRSSI_GUI_NONE;
OUTPUT:
RETVAL
int
IRSSI_GUI_TEXT()
CODE:
RETVAL = IRSSI_GUI_TEXT;
OUTPUT:
RETVAL
int
IRSSI_GUI_GTK()
CODE:
RETVAL = IRSSI_GUI_GTK;
OUTPUT:
RETVAL
int
IRSSI_GUI_GNOME()
CODE:
RETVAL = IRSSI_GUI_GNOME;
OUTPUT:
RETVAL
int
IRSSI_GUI_QT()
CODE:
RETVAL = IRSSI_GUI_QT;
OUTPUT:
RETVAL
int
IRSSI_GUI_KDE()
CODE:
RETVAL = IRSSI_GUI_KDE;
OUTPUT:
RETVAL
#*******************************
MODULE = Irssi::Core PACKAGE = Irssi::Server
#*******************************
void
parse_special(server, cmd, data="", flags=0)
Irssi::Server server
char *cmd
char *data
int flags
PREINIT:
char *ret;
PPCODE:
ret = parse_special_string(cmd, server, NULL, data, NULL, flags);
XPUSHs(sv_2mortal(new_pv(ret)));
g_free_not_null(ret);
void
command(server, cmd)
Irssi::Server server
char *cmd
CODE:
perl_command(cmd, server, NULL);
#*******************************
MODULE = Irssi::Core PACKAGE = Irssi::Windowitem
#*******************************
void
parse_special(item, cmd, data="", flags=0)
Irssi::Windowitem item
char *cmd
char *data
int flags
PREINIT:
char *ret;
PPCODE:
ret = parse_special_string(cmd, item->server, item, data, NULL, flags);
XPUSHs(sv_2mortal(new_pv(ret)));
g_free_not_null(ret);
void
command(item, cmd)
Irssi::Windowitem item
char *cmd
CODE:
perl_command(cmd, item->server, item);
|