summaryrefslogtreecommitdiffstats
path: root/perl-install/services.pm
blob: 3821957a692084834fc9b0d5d716a787201359d4 (plain)
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
package services; # $Id$




#-######################################################################################
#- misc imports
#-######################################################################################

use strict;
use common;
use run_program;

use common;
use run_program;

sub description {
    my %services = (
acpid => N_("Listen and dispatch ACPI events from the kernel"),	    
alsa => N_("Launch the ALSA (Advanced Linux Sound Architecture) sound system"),
anacron => N_("Anacron is a periodic command scheduler."),
apmd => N_("apmd is used for monitoring battery status and logging it via syslog.
It can also be used for shutting down the machine when the battery is low."),
atd => N_("Runs commands scheduled by the at command at the time specified when
at was run, and runs batch commands when the load average is low enough."),
'avahi-deamon' => N_("Avahi is a ZeroConf daemon which implements an mDNS stack"),
cpufreq => N_("Set CPU frequency settings"),
crond => N_("cron is a standard UNIX program that runs user-specified programs
at periodic scheduled times. vixie cron adds a number of features to the basic
UNIX cron, including better security and more powerful configuration options."),
cups => N_("Common UNIX Printing System (CUPS) is an advanced printer spooling system"),
dm => N_("Launches the graphical display manager"),
fam => N_("FAM is a file monitoring daemon. It is used to get reports when files change.
It is used by GNOME and KDE"),
g15daemon => N_("G15Daemon allows users access to all extra keys by decoding them and 
pushing them back into the kernel via the linux UINPUT driver. This driver must be loaded 
before g15daemon can be used for keyboard access. The G15 LCD is also supported. By default, 
with no other clients active, g15daemon will display a clock. Client applications and 
scripts can access the LCD via a simple API."),
gpm => N_("GPM adds mouse support to text-based Linux applications such the
Midnight Commander. It also allows mouse-based console cut-and-paste operations,
and includes support for pop-up menus on the console."),
haldaemon => N_("HAL is a daemon that collects and maintains information about hardware"),
harddrake => N_("HardDrake runs a hardware probe, and optionally configures
new/changed hardware."),
httpd => N_("Apache is a World Wide Web server. It is used to serve HTML files and CGI."),
inet => N_("The internet superserver daemon (commonly called inetd) starts a
variety of other internet services as needed. It is responsible for starting
many services, including telnet, ftp, rsh, and rlogin. Disabling inetd disables
all of the services it is responsible for."),
ip6tables => N_("Automates a packet filtering firewall with ip6tables"),
iptables => N_("Automates a packet filtering firewall with iptables"),
ipchains => N_("Launch packet filtering for Linux kernel 2.2 series, to set
up a firewall to protect your machine from network attacks."),
irqbalance => N_("Evenly distributes IRQ load across multiple CPUs for enhanced performance"),
keytable => N_("This package loads the selected keyboard map as set in
/etc/sysconfig/keyboard.  This can be selected using the kbdconfig utility.
You should leave this enabled for most machines."),
kheader => N_("Automatic regeneration of kernel header in /boot for
/usr/include/linux/{autoconf,version}.h"),
kudzu => N_("Automatic detection and configuration of hardware at boot."),
'laptop-mode' => N_("Tweaks system behavior to extend battery life"),
linuxconf => N_("Linuxconf will sometimes arrange to perform various tasks
at boot-time to maintain the system configuration."),
lpd => N_("lpd is the print daemon required for lpr to work properly. It is
basically a server that arbitrates print jobs to printer(s)."),
lvs => N_("Linux Virtual Server, used to build a high-performance and highly
available server."),
mandi => N_("Monitors the network (Interactive Firewall and wireless"),
mdadm => N_("Software RAID monitoring and management"),
messagebus => N_("DBUS is a daemon which broadcasts notifications of system events and other messages"),
msec => N_("Enables MSEC security policy on system startup"),
named => N_("named (BIND) is a Domain Name Server (DNS) that is used to resolve host names to IP addresses."),
netconsole => N_("Initializes network console logging"),
netfs => N_("Mounts and unmounts all Network File System (NFS), SMB (Lan
Manager/Windows), and NCP (NetWare) mount points."),
network => N_("Activates/Deactivates all network interfaces configured to start
at boot time."),
'network-auth' => N_("Requires network to be up if enabled"),
'network-up' => N_("Wait for the hotplugged network to be up"),
nfs => N_("NFS is a popular protocol for file sharing across TCP/IP networks.
This service provides NFS server functionality, which is configured via the
/etc/exports file."),
nfslock => N_("NFS is a popular protocol for file sharing across TCP/IP
networks. This service provides NFS file locking functionality."),
ntpd => N_("Synchronizes system time using the Network Time Protocol (NTP)"),
numlock => N_("Automatically switch on numlock key locker under console
and Xorg at boot."),
oki4daemon => N_("Support the OKI 4w and compatible winprinters."),
partmon => N_("Checks if a partition is close to full up"),
pcmcia => N_("PCMCIA support is usually to support things like ethernet and
modems in laptops.  It will not get started unless configured so it is safe to have
it installed on machines that do not need it."),
portmap => N_("The portmapper manages RPC connections, which are used by
protocols such as NFS and NIS. The portmap server must be running on machines
which act as servers for protocols which make use of the RPC mechanism."),
portreserve => N_("Reserves some TCP ports"),
postfix => N_("Postfix is a Mail Transport Agent, which is the program that moves mail from one machine to another."),
random => N_("Saves and restores system entropy pool for higher quality random
number generation."),
rawdevices => N_("Assign raw devices to block devices (such as hard drive
partitions), for the use of applications such as Oracle or DVD players"),
resolvconf => N_("Nameserver information manager"),
routed => N_("The routed daemon allows for automatic IP router table updated via
the RIP protocol. While RIP is widely used on small networks, more complex
routing protocols are needed for complex networks."),
rstatd => N_("The rstat protocol allows users on a network to retrieve
performance metrics for any machine on that network."),
rsyslog => N_("Syslog is the facility by which many daemons use to log messages to various system log files.  It is a good idea to always run rsyslog."),
rusersd => N_("The rusers protocol allows users on a network to identify who is
logged in on other responding machines."),
rwhod => N_("The rwho protocol lets remote users get a list of all of the users
logged into a machine running the rwho daemon (similar to finger)."),
saned => N_("SANE (Scanner Access Now Easy) enables to access scanners, video cameras, ..."),
shorewall => N_("Packet filtering firewall"),
smb => N_("The SMB/CIFS protocol enables to share access to files & printers and also integrates with a Windows Server domain"),
sound => N_("Launch the sound system on your machine"),
'speech-dispatcherd' => N_("layer for speech analysis"),
sshd => N_("Secure Shell is a network protocol that allows data to be exchanged over a secure channel between two computers"),
syslog => N_("Syslog is the facility by which many daemons use to log messages
to various system log files.  It is a good idea to always run syslog."),
'udev-post' => N_("Moves the generated persistent udev rules to /etc/udev/rules.d"),
usb => N_("Load the drivers for your usb devices."),
vnStat => N_("A lightweight network traffic monitor"),
xfs => N_("Starts the X Font Server."),
xinetd => N_("Starts other deamons on demand."),
    );
    my ($name) = @_;
    my $s = $services{$name};
    if ($s) {
	$s = translate($s);
    } else {
	my $file = find { -e $_ } map { "$::prefix$_/$name" } '/etc/rc.d/init.d', '/etc/init.d', '/etc/xinetd.d';
	$s = cat_($file);
	$s =~ s/\\\s*\n#\s*//mg;
	$s = 
	  $s =~ /^#\s+(?:Short-)?[dD]escription:\s+(.*?)^(?:[^#]|# {0,2}\S)/sm ? $1 :
	  $s =~ /^#\s*(.*?)^[^#]/sm ? $1 : '';

	$s =~ s/#\s*//mg;
    }
    $s =~ s/\n/ /gm; $s =~ s/\s+$//;
    $s;
}

sub ask_ {
    my ($in) = @_;
    my %root_services = (
			 N("Printing") => [ qw(cups cupslpd lpr lpd oki4daemon hpoj cups-lpd) ],
			 N("Internet") => [ qw(httpd boa tux roxen ftp pftp tftp proftpd wu-ftpd pure-ftpdipsec proftpd-xinetd
                                               ipchains iptables ip6tables ipvsadm isdn4linux ibod jabber jabber-icq adsl squid
                                               portsentry prelude nessusd junkbuster radvd cddbp ippl iptoip jail.init) ],
			 N("File sharing") => [ qw(nfs-common nfs-server nfslock smb nettalk netfs mcserv autofs amd
                                                   venus.init auth2.init codasrv.init update.init swat) ],
			 N("System") => [ qw(usb usbd pcmcia irda xinetd inetd kudzu harddrake apmd sound network xfs
                                             alsa functions halt kheader killall mandrake_everytime mandrake_firstime
                                             random rawdevices single keytable syslog crond medusa-init portmap rpcbind acon
                                             anacron atd gpm psacct wine acpid numlock jserver sensors mosix bpowerd bpowerfail
                                             fcron powertweak.init ups syslog-ng cvs apcupsd) ],
			 N("Remote Administration") => [ qw(sshd telnetd telnet rsh rlogin rexec webmin cfd heartbeat ldirectord
                                                            iplog mon vncserver netsaint olympusd drakxtools_http) ],
#			 N("Network Client") => [ qw(ypbind nscd arpwatch fetchmail dnrd_rc diald rsync) ],
#			 N("Network Server") => [ qw(named bootparamd ntpd xntpd chronyd postfix sendmail
#                                                     imap imaps ipop2 ipop3 pop3s routed yppasswdd ypserv ldap dhcpd dhcrelay
#                                                     hylafax innd identd rstatd rusersd rwalld rwhod gated
#                                                     kadmin kprop krb524 krb5kdc krb5server hldsld bayonne sockd dhsd gnu-pop3d
#                                                     gdips pptpd.conf vrrpd crossfire bnetd pvmd ircd sympa finger ntalk talk) ],
			 N("Database Server") => [ qw(mysql postgresql) ],
			);
    my %services_root;
    foreach my $root (keys %root_services) {
	$services_root{$_} = $root foreach @{$root_services{$root}};
    }
    my ($l, $on_services) = services();
    my %services;
    $services{$_} = 0 foreach @{$l || []};
    $services{$_} = 1 foreach @{$on_services || []};

    $in->ask_browse_tree_info(N("Services"), N("Choose which services should be automatically started at boot time"),
			      {
			       node_state => sub { $services{$_[0]} ? 'selected' : 'unselected' },
			       build_tree => sub {
				   my ($add_node, $flat) = @_;
				   $add_node->($_, !$flat && ($services_root{$_} || N("Other")))
				     foreach sort keys %services;
			       },
			       grep_unselected => sub { grep { !$services{$_} } @_ },
			       toggle_nodes => sub {
				   my ($set_state, @nodes) = @_;
				   my $new_state = !$services{$nodes[0]};
				   foreach (@nodes) {
				       $set_state->($_, $new_state ? 'selected' : 'unselected');
				       $services{$_} = $new_state;
				   }
			       },
			       get_status => sub {
				   N("%d activated for %d registered", 
				     scalar(grep { $_ } values %services),
				     scalar(values %services));
			       },
			       get_info => sub { formatLines(description($_[0])) },
                               interactive_help => sub { 
                                   interactive::gtk::display_help($in,
                                                               { interactive_help_id => 
                                                                   'misc-params#drakxid-configureServices' }, $::main_window) },
			      }) or return $l, $on_services; #- no change on cancel.
    [ grep { $services{$_} } @$l ];
}

sub ask_standalone_gtk {
    my ($_in) = @_;
    my ($l, $on_services) = services();
    my @xinetd_services = map { $_->[0] } @{(services_raw())[1]};

    require ugtk2;
    ugtk2->import(qw(:wrappers :create));

    my $W = ugtk2->new(N("Services"));
    my ($x, $y, $w_popup);
    my $nopop = sub { $w_popup and $w_popup->destroy; undef $w_popup };
    my $display = sub { 
	my ($text) = @_;
	$nopop->(); 
	gtkshow(gtkadd($w_popup = Gtk2::Window->new('popup'),
		       gtksignal_connect(gtkadd(Gtk2::EventBox->new,
						gtkadd(gtkset_shadow_type(Gtk2::Frame->new, 'etched_out'),
						       gtkset_justify(Gtk2::Label->new($text), 'left'))),
					 button_press_event => sub { $nopop->() }
					)))->move($x, $y) if $text;
    };
    my $update_service = sub {
	my ($service, $label) = @_;
	my $started = -e "/var/lock/subsys/$service";
	$label->set_label($started ? N("running") : N("stopped"));
    };
    my $b = Gtk2::EventBox->new;
    $b->set_events('pointer_motion_mask');
    gtkadd($W->{window}, gtkadd($b, gtkpack_($W->create_box_with_title,
	0, mygtk2::gtknew('Title1', label => N("Services and daemons")),
	1, gtkset_size_request(create_scrolled_window(create_packtable({ col_spacings => 10, row_spacings => 3 },
	    map {
                my $service = $_;
		my $is_xinetd_service = member($service, @xinetd_services);
        	my $infos = warp_text(description($_), 40);
                $infos ||= N("No additional information\nabout this service, sorry.");
		my $label = gtkset_justify(Gtk2::Label->new, 'left');
                $update_service->($service, $label) if !$is_xinetd_service;
		[ gtkpack__(Gtk2::HBox->new(0,0), $_),
		  gtkpack__(Gtk2::HBox->new(0,0), $label),
		  gtkpack__(Gtk2::HBox->new(0,0), gtksignal_connect(Gtk2::Button->new(N("Info")), clicked => sub { $display->($infos) })),

                  gtkpack__(Gtk2::HBox->new(0,0), gtkset_active(gtksignal_connect(
                          Gtk2::CheckButton->new($is_xinetd_service ? N("Start when requested") : N("On boot")),
                          clicked => sub { if ($_[0]->get_active) {
                                               push @$on_services, $service if !member($service, @$on_services);
                                           } else {
                                               @$on_services = grep { $_ ne $service } @$on_services;
                                        } }), member($service, @$on_services))),
		  map { 
		      my $a = $_;
		      gtkpack__(Gtk2::HBox->new(0,0), gtksignal_connect(Gtk2::Button->new(translate($a)),
                          clicked => sub { 
			      my $action = $a eq "Start" ? 'restart' : 'stop'; 
			      log::explanations(qq(GP_LANG="UTF-8" service $service $action));
			      # as we need the output in UTF-8, force it
			      local $_ = `GP_LANG="UTF-8" service $service $action 2>&1`; s/\033\[[^mG]*[mG]//g;
			      c::set_tagged_utf8($_);
			      $update_service->($service, $label);
			      $display->($_);
			  })) if !$is_xinetd_service;
		  } (N_("Start"), N_("Stop"))
		];
	    }
            @$l), [ $::isEmbedded ? 'automatic' : 'never', 'automatic' ]), -1, $::isEmbedded ? -1 : 400),
            0, gtkpack(gtkset_border_width(Gtk2::HBox->new(0,0),5), $W->create_okcancel)
            ))
	  );
    $b->signal_connect(motion_notify_event => sub { my ($w, $e) = @_;
						    my ($ox, $oy) = $w->window->get_origin;
						    $x = $e->x+$ox; $y = $e->y+$oy });
    $b->signal_connect(button_press_event => sub { $nopop->() });
    $::isEmbedded and gtkflush();
    $W->main or return;
    $on_services;
}

sub ask {    
    my ($in) = @_;
    !$::isInstall && $in->isa('interactive::gtk') ? &ask_standalone_gtk : &ask_;
}

sub _set_service {
    my ($service, $enable) = @_;
    my $script = "/etc/rc.d/init.d/$service";
    run_program::rooted($::prefix, "chkconfig", $enable ? "--add" : "--del", $service);
    #- FIXME: handle services with no chkconfig line and with no Default-Start levels in LSB header
    if ($enable && cat_("$::prefix$script") =~ /^#\s+chkconfig:\s+-/m) {
        run_program::rooted($::prefix, "chkconfig", "--level", "35", $service, "on");
    }
}

sub _run_action {
    my ($service, $action) = @_;
    run_program::rooted($::prefix, "/etc/rc.d/init.d/$service", $action);
}

sub doit {
    my ($in, $on_services) = @_;
    my ($l, $was_on_services) = services();

    foreach (@$l) {
	my $before = member($_, @$was_on_services);
	my $after = member($_, @$on_services);
	if ($before != $after) {
	    _set_service($_, $after);
	    if (!$after && !$::isInstall && !$in->isa('interactive::gtk')) {
		#- only done after install AND when not using the gtk frontend (since it allows one to start/stop services)
		#- this allows to skip stopping service "dm"
		_run_action($_, "stop");
	    }
	}
    }
}

sub services_raw() {
    local $ENV{LANGUAGE} = 'C';
    my (@services, @xinetd_services);
    foreach (run_program::rooted_get_stdout($::prefix, '/sbin/chkconfig', '--list')) {
	if (my ($xinetd_name, $on_off) = m!^\t(\S+):\s*(on|off)!) {
	    push @xinetd_services, [ $xinetd_name, $on_off eq 'on' ];
	} elsif (my ($name, $l) = m!^(\S+)\s+(0:(on|off).*)!) {
	    push @services, [ $name, [ $l =~ /(\d+):on/g ] ];
	}
    }
    \@services, \@xinetd_services;
}

#- returns: 
#--- the listref of installed services
#--- the listref of "on" services
sub services() {
    my ($services, $xinetd_services) = services_raw();
    my @l = @$xinetd_services;
    if ($::isInstall) {
        push @l, map { [ $_->[0], @{$_->[1]} > 0 ] } @$services;
    } else {
        my $runlevel = (split " ", `/sbin/runlevel`)[1];
        push @l, map { [ $_->[0], member($runlevel, @{$_->[1]}) ] } @$services;
    }
    @l = sort { $a->[0] cmp $b->[0] } @l;
    [ map { $_->[0] } @l ], [ map { $_->[0] } grep { $_->[1] } @l ];
}






sub service_exists {
    my ($service) = @_;
    -x "$::prefix/etc/rc.d/init.d/$service";
}

sub restart ($) {
    my ($service) = @_;
    # Exit silently if the service is not installed
    service_exists($service) or return 1;
    _run_action($service, "restart");
}

sub restart_or_start ($) {
    my ($service) = @_;
    # Exit silently if the service is not installed
    service_exists($service) or return 1;
    _run_action($service, is_service_running($service) ? "restart" : "start");
}

sub start ($) {
    my ($service) = @_;
    # Exit silently if the service is not installed
    service_exists($service) or return 1;
    _run_action($service, "start");
}

sub start_not_running_service ($) {
    my ($service) = @_;
    # Exit silently if the service is not installed
    service_exists($service) or return 1;
    is_service_running($service) || _run_action($service, "start");
}

sub stop ($) {
    my ($service) = @_;
    # Exit silently if the service is not installed
    service_exists($service) or return 1;
    _run_action($service, "stop");
}

sub is_service_running ($) {
    my ($service) = @_;
    # Exit silently if the service is not installed
    service_exists($service) or return 1;
    run_program::rooted($::prefix, "/etc/rc.d/init.d/$service", '>', '/dev/null', '2>', '/dev/null', "status");
}

sub starts_on_boot {
    my ($service) = @_;
    my (undef, $on_services) = services();
    member($service, @$on_services);
}

sub start_service_on_boot ($) {
    my ($service) = @_;
    _set_service($service, 1);
}

sub do_not_start_service_on_boot ($) {
    my ($service) = @_;
    _set_service($service, 0);
}

sub enable {
    my ($service, $o_dont_apply) = @_;
    start_service_on_boot($service);
    restart_or_start($service) unless $o_dont_apply;
}

sub disable {
    my ($service, $o_dont_apply) = @_;
    do_not_start_service_on_boot($service);
    stop($service) unless $o_dont_apply;
}

sub set_status {
    my ($service, $enable, $o_dont_apply) = @_;
    if ($enable) {
	enable($service, $o_dont_apply);
    } else {
	disable($service, $o_dont_apply);
    }
}

1;
*s++ = ch; continue; } *s++ = (unsigned char) pref_char; while ((beg < end) && Utility_Char_Table[*beg]) beg++; } *s = 0; #if USE_ALLOC_STSTRING (void) _SLpush_alloced_slstring (c, len); #else SLang_push_malloced_string(c); #endif SLfree(str); } /*}}}*/ static int str_replace_cmd_1 (char *orig, char *match, char *rep, unsigned int max_num_replaces, char **new_strp) /*{{{*/ { char *s, *t, *new_str; unsigned int rep_len, match_len, new_len; unsigned int num_replaces; *new_strp = NULL; match_len = strlen (match); if (match_len == 0) return 0; num_replaces = 0; s = orig; while (num_replaces < max_num_replaces) { s = strstr (s, match); if (s == NULL) break; s += match_len; num_replaces++; } if (num_replaces == 0) return 0; max_num_replaces = num_replaces; rep_len = strlen (rep); new_len = (strlen (orig) - num_replaces * match_len) + num_replaces * rep_len; new_str = SLmalloc (new_len + 1); if (new_str == NULL) return -1; s = orig; t = new_str; for (num_replaces = 0; num_replaces < max_num_replaces; num_replaces++) { char *next_s; unsigned int len; next_s = strstr (s, match); /* cannot be NULL */ len = (unsigned int) (next_s - s); strncpy (t, s, len); t += len; strcpy (t, rep); t += rep_len; s = next_s + match_len; } strcpy (t, s); *new_strp = new_str; return (int) num_replaces; } /*}}}*/ static void reverse_string (char *a) { char *b; b = a + strlen (a); while (b > a) { char ch; b--; ch = *a; *a++ = *b; *b = ch; } } static int strreplace_cmd (int *np) { char *orig, *match, *rep; char *new_str; int max_num_replaces; int ret; max_num_replaces = *np; if (-1 == pop_3_strings (&orig, &match, &rep)) return -1; if (max_num_replaces < 0) { reverse_string (orig); reverse_string (match); reverse_string (rep); ret = str_replace_cmd_1 (orig, match, rep, -max_num_replaces, &new_str); if (ret > 0) reverse_string (new_str); else if (ret == 0) reverse_string (orig); } else ret = str_replace_cmd_1 (orig, match, rep, max_num_replaces, &new_str); if (ret == 0) { if (-1 == SLang_push_malloced_string (orig)) ret = -1; orig = NULL; } else if (ret > 0) { if (-1 == SLang_push_malloced_string (new_str)) ret = -1; } free_3_strings (orig, match, rep); return ret; } static int str_replace_cmd (char *orig, char *match, char *rep) { char *s; int ret; ret = str_replace_cmd_1 (orig, match, rep, 1, &s); if (ret == 1) (void) SLang_push_malloced_string (s); return ret; } static void strtok_cmd (char *str) { _SLString_List_Type sl; unsigned char white_buf[256]; char *s; unsigned char *white; if (SLang_Num_Function_Args == 1) white = make_whitespace_lut (); else { white = white_buf; make_lut ((unsigned char *)str, white); if (-1 == SLang_pop_slstring (&str)) return; } if (-1 == _SLstring_list_init (&sl, 256, 1024)) goto the_return; s = str; while (*s != 0) { char *s0; s0 = s; /* Skip whitespace */ while ((*s0 != 0) && (0 != white[(unsigned char)*s0])) s0++; if (*s0 == 0) break; s = s0; while ((*s != 0) && (0 == white[(unsigned char) *s])) s++; /* sl deleted upon failure */ if (-1 == _SLstring_list_append (&sl, SLang_create_nslstring (s0, (unsigned int) (s - s0)))) goto the_return; } /* Deletes sl */ (void) _SLstring_list_push (&sl); the_return: if (white == white_buf) SLang_free_slstring (str); } /* This routine returns the string with text removed between single character comment delimiters from the set b and e. */ static void str_uncomment_string_cmd (char *str, char *b, char *e) /*{{{*/ { unsigned char chb, che; unsigned char *s, *cbeg, *mark; if (strlen(b) != strlen(e)) { SLang_doerror ("Comment delimiter length mismatch."); return; } set_utility_char_table (b); if (NULL == (str = (char *) SLmake_string(str))) return; s = (unsigned char *) str; while ((chb = *s++) != 0) { if (Utility_Char_Table [chb] == 0) continue; mark = s - 1; cbeg = (unsigned char *) b; while (*cbeg != chb) cbeg++; che = (unsigned char) *(e + (int) (cbeg - (unsigned char *) b)); while (((chb = *s++) != 0) && (chb != che)); if (chb == 0) { /* end of string and end not found. Just truncate it a return; */ *mark = 0; break; } strcpy ((char *) mark, (char *)s); s = mark; } SLang_push_malloced_string (str); } /*}}}*/ static void str_quote_string_cmd (char *str, char *quotes, int *slash_ptr) /*{{{*/ { char *q; int slash; unsigned int len; register char *t, *s, *q1; register unsigned char ch; slash = *slash_ptr; if ((slash > 255) || (slash < 0)) { SLang_Error = SL_INVALID_PARM; return; } /* setup the utility table to have 1s at quote char postitions. */ set_utility_char_table (quotes); t = Utility_Char_Table; t[(unsigned int) slash] = 1; /* calculate length */ s = str; len = 0; while ((ch = (unsigned char) *s++) != 0) if (t[ch]) len++; len += (unsigned int) (s - str); if (NULL != (q = SLmalloc(len))) { s = str; q1 = q; while ((ch = (unsigned char) *s++) != 0) { if (t[ch]) *q1++ = slash; *q1++ = (char) ch; } *q1 = 0; SLang_push_malloced_string(q); } } /*}}}*/ /* returns the position of substrin in a string or null */ static int issubstr_cmd (char *a, char *b) /*{{{*/ { char *c; if (NULL == (c = (char *) strstr(a, b))) return 0; return 1 + (int) (c - a); } /*}}}*/ /* returns to stack string at pos n to n + m of a */ static void substr_cmd (char *a, int *n_ptr, int *m_ptr) /*{{{*/ { int n, m; int lena; n = *n_ptr; m = *m_ptr; lena = strlen (a); if (n > lena) n = lena + 1; if (n < 1) { SLang_Error = SL_INVALID_PARM; return; } n--; if (m < 0) m = lena; if (n + m > lena) m = lena - n; (void) _SLang_push_nstring (a + n, (unsigned int) m); } /*}}}*/ /* substitute char m at positin string n in string*/ static void strsub_cmd (int *nptr, int *mptr) /*{{{*/ { char *a; int n, m; unsigned int lena; if (-1 == SLpop_string (&a)) return; n = *nptr; m = *mptr; lena = strlen (a); if ((n <= 0) || (lena < (unsigned int) n)) { SLang_Error = SL_INVALID_PARM; SLfree(a); return; } a[n - 1] = (char) m; SLang_push_malloced_string (a); } /*}}}*/ static void strup_cmd(void) /*{{{*/ { unsigned char c, *a; char *str; if (SLpop_string (&str)) return; a = (unsigned char *) str; while ((c = *a) != 0) { /* if ((*a >= 'a') && (*a <= 'z')) *a -= 32; */ *a = UPPER_CASE(c); a++; } SLang_push_malloced_string (str); } /*}}}*/ static int isdigit_cmd (char *what) /*{{{*/ { return isdigit((unsigned char)*what); } /*}}}*/ static int toupper_cmd (int *ch) /*{{{*/ { return UPPER_CASE(*ch); } /*}}}*/ static int tolower_cmd (int *ch) /*{{{*/ { return LOWER_CASE(*ch); } /*}}}*/ static void strlow_cmd (void) /*{{{*/ { unsigned char c, *a; char *str; if (SLpop_string(&str)) return; a = (unsigned char *) str; while ((c = *a) != 0) { /* if ((*a >= 'a') && (*a <= 'z')) *a -= 32; */ *a = LOWER_CASE(c); a++; } SLang_push_malloced_string ((char *) str); } /*}}}*/ static SLang_Array_Type *do_strchop (char *str, int delim, int quote) { int count; char *s0, *elm; register char *s1; register unsigned char ch; int quoted; SLang_Array_Type *at; char **data; if ((quote < 0) || (quote > 255) || (delim <= 0) || (delim > 255)) { SLang_Error = SL_INVALID_PARM; return NULL; } s1 = s0 = str; quoted = 0; count = 1; /* at least 1 */ while (1) { ch = (unsigned char) *s1++; if ((ch == quote) && quote) { if (*s1 == 0) break; s1++; continue; } if (ch == delim) { count++; continue; } if (ch == 0) break; } if (NULL == (at = SLang_create_array (SLANG_STRING_TYPE, 0, NULL, &count, 1))) return NULL; data = (char **)at->data; count = 0; s1 = s0; while (1) { ch = (unsigned char) *s1; if ((ch == quote) && quote) { s1++; if (*s1 != 0) s1++; quoted = 1; continue; } if ((ch == delim) || (ch == 0)) { if (quoted == 0) elm = SLang_create_nslstring (s0, (unsigned int) (s1 - s0)); else { register char ch1, *p, *p1; char *tmp; tmp = SLmake_nstring (s0, (unsigned int)(s1 - s0)); if (tmp == NULL) break; /* Now unquote it */ p = p1 = tmp; do { ch1 = *p1++; if (ch1 == '\\') ch1 = *p1++; *p++ = ch1; } while (ch1 != 0); quoted = 0; elm = SLang_create_slstring (tmp); SLfree (tmp); } if (elm == NULL) break; data[count] = elm; count++; if (ch == 0) return at; s1++; /* skip past delim */ s0 = s1; /* and reset */ } else s1++; } SLang_free_array (at); return NULL; } static void strchop_cmd (char *str, int *q, int *d) { (void) SLang_push_array (do_strchop (str, *q, *d), 1); } static void strchopr_cmd (char *str, int *q, int *d) { SLang_Array_Type *at; if (NULL != (at = do_strchop (str, *q, *d))) { char **d0, **d1; d0 = (char **) at->data; d1 = d0 + (at->num_elements - 1); while (d0 < d1) { char *tmp; tmp = *d0; *d0 = *d1; *d1 = tmp; d0++; d1--; } } SLang_push_array (at, 1); } static int strcmp_cmd (char *a, char *b) /*{{{*/ { return strcmp(a, b); } /*}}}*/ static int strncmp_cmd (char *a, char *b, int *n) /*{{{*/ { return strncmp(a, b, (unsigned int) *n); } /*}}}*/ static int strlen_cmd (char *s) /*{{{*/ { return (int) strlen (s); } /*}}}*/ static void extract_element_cmd (char *list, int *nth_ptr, int *delim_ptr) { char buf[1024], *b; b = buf; if (-1 == SLextract_list_element (list, *nth_ptr, *delim_ptr, buf, sizeof(buf))) b = NULL; SLang_push_string (b); } /* sprintf functionality for S-Lang */ static char *SLdo_sprintf (char *fmt) /*{{{*/ { register char *p = fmt, ch; char *out = NULL, *outp = NULL; char dfmt[1024]; /* used to hold part of format */ char *f; VOID_STAR varp; int want_width, width, precis, use_varp, int_var; long long_var; unsigned int len = 0, malloc_len = 0, dlen; int do_free, guess_size; #if SLANG_HAS_FLOAT int tmp1, tmp2, use_double; double x; #endif int use_long = 0; while (1) { while ((ch = *p) != 0) { if (ch == '%') break; p++; } /* p points at '%' or 0 */ dlen = (unsigned int) (p - fmt); if (len + dlen >= malloc_len) { malloc_len = len + dlen; if (out == NULL) outp = SLmalloc(malloc_len + 1); else outp = SLrealloc(out, malloc_len + 1); if (NULL == outp) return out; out = outp; outp = out + len; } strncpy(outp, fmt, dlen); len += dlen; outp = out + len; *outp = 0; if (ch == 0) break; /* bump it beyond '%' */ ++p; fmt = p; f = dfmt; *f++ = ch; /* handle flag char */ ch = *p++; /* Make sure cases such as "% #g" can be handled. */ if ((ch == '-') || (ch == '+') || (ch == ' ') || (ch == '#')) { *f++ = ch; ch = *p++; if ((ch == '-') || (ch == '+') || (ch == ' ') || (ch == '#')) { *f++ = ch; ch = *p++; } } /* width */ /* I have got to parse it myself so that I can see how big it needs * to be. */ want_width = width = 0; if (ch == '*') { if (SLang_pop_integer(&width)) return (out); want_width = 1; ch = *p++; } else { if (ch == '0') { *f++ = '0'; ch = *p++; } while ((ch <= '9') && (ch >= '0')) { width = width * 10 + (ch - '0'); ch = *p++; want_width = 1; } } if (want_width) { sprintf(f, "%d", width); f += strlen (f); } precis = 0; /* precision -- also indicates max number of chars from string */ if (ch == '.') { *f++ = ch; ch = *p++; want_width = 0; if (ch == '*') { if (SLang_pop_integer(&precis)) return (out); ch = *p++; want_width = 1; } else while ((ch <= '9') && (ch >= '0')) { precis = precis * 10 + (ch - '0'); ch = *p++; want_width = 1; } if (want_width) { sprintf(f, "%d", precis); f += strlen (f); } else precis = 0; } long_var = 0; int_var = 0; varp = NULL; guess_size = 32; #if SLANG_HAS_FLOAT use_double = 0; #endif use_long = 0; use_varp = 0; do_free = 0; if (ch == 'l') { use_long = 1; ch = *p++; } else if (ch == 'h') ch = *p++; /* not supported */ /* Now the actual format specifier */ switch (ch) { case 'S': _SLstring_intrinsic (); ch = 's'; /* drop */ case 's': if (SLang_pop_slstring((char **) &varp)) return (out); do_free = 1; guess_size = strlen((char *) varp); use_varp = 1; break; case '%': guess_size = 1; do_free = 0; use_varp = 1; varp = (VOID_STAR) "%"; break; case 'c': guess_size = 1; use_long = 0; /* drop */ case 'd': case 'i': case 'o': case 'u': case 'X': case 'x': if (SLang_pop_long (&long_var)) return(out); if (use_long == 0) int_var = (int) long_var; else *f++ = 'l'; break; case 'f': case 'e': case 'g': case 'E': case 'G': #if SLANG_HAS_FLOAT if (SLang_pop_double(&x, &tmp1, &tmp2)) return (out); use_double = 1; guess_size = 256; (void) tmp1; (void) tmp2; use_long = 0; break; #endif case 'p': guess_size = 32; /* Pointer type?? Why?? */ if (-1 == SLdo_pop ()) return out; varp = (VOID_STAR) _SLStack_Pointer; use_varp = 1; use_long = 0; break; default: SLang_doerror("Invalid Format."); return(out); } *f++ = ch; *f = 0; width = width + precis; if (width > guess_size) guess_size = width; if (len + guess_size > malloc_len) { outp = (char *) SLrealloc(out, len + guess_size + 1); if (outp == NULL) { SLang_Error = SL_MALLOC_ERROR; return (out); } out = outp; outp = out + len; malloc_len = len + guess_size; } if (use_varp) { sprintf(outp, dfmt, varp); if (do_free) SLang_free_slstring ((char *)varp); } #if SLANG_HAS_FLOAT else if (use_double) sprintf(outp, dfmt, x); #endif else if (use_long) sprintf (outp, dfmt, long_var); else sprintf(outp, dfmt, int_var); len += strlen(outp); outp = out + len; fmt = p; } if (out != NULL) { outp = SLrealloc (out, (unsigned int) (outp - out) + 1); if (outp != NULL) out = outp; } return (out); } /*}}}*/ int _SLstrops_do_sprintf_n (int n) /*{{{*/ { char *p; char *fmt; SLang_Object_Type *ptr; int ofs; if (-1 == (ofs = SLreverse_stack (n + 1))) return -1; ptr = _SLRun_Stack + ofs; if (SLang_pop_slstring(&fmt)) return -1; p = SLdo_sprintf (fmt); SLang_free_slstring (fmt); while (_SLStack_Pointer > ptr) SLdo_pop (); if (SLang_Error) { SLfree (p); return -1; } return SLang_push_malloced_string (p); } /*}}}*/ static void sprintf_n_cmd (int *n) { _SLstrops_do_sprintf_n (*n); } static void sprintf_cmd (void) { _SLstrops_do_sprintf_n (SLang_Num_Function_Args - 1); /* do not include format */ } /* converts string s to a form that can be used in an eval */ static void make_printable_string(char *s) /*{{{*/ { unsigned int len; register char *s1 = s, ch, *ss1; char *ss; /* compute length */ len = 3; while ((ch = *s1++) != 0) { if ((ch == '\n') || (ch == '\\') || (ch == '"')) len++; len++; } if (NULL == (ss = SLmalloc(len))) return; s1 = s; ss1 = ss; *ss1++ = '"'; while ((ch = *s1++) != 0) { if (ch == '\n') { ch = 'n'; *ss1++ = '\\'; } else if ((ch == '\\') || (ch == '"')) { *ss1++ = '\\'; } *ss1++ = ch; } *ss1++ = '"'; *ss1 = 0; if (-1 == SLang_push_string (ss)) SLfree (ss); } /*}}}*/ static int is_list_element_cmd (char *list, char *elem, int *d_ptr) { char ch; int d, n; unsigned int len; char *lbeg, *lend; d = *d_ptr; len = strlen (elem); n = 1; lend = list; while (1) { lbeg = lend; while ((0 != (ch = *lend)) && (ch != (char) d)) lend++; if ((lbeg + len == lend) && (0 == strncmp (elem, lbeg, len))) break; if (ch == 0) { n = 0; break; } lend++; /* skip delim */ n++; } return n; } /*}}}*/ /* Regular expression routines for strings */ static SLRegexp_Type regexp_reg; static int string_match_cmd (char *str, char *pat, int *nptr) /*{{{*/ { int n; unsigned int len; unsigned char rbuf[512], *match; n = *nptr; regexp_reg.case_sensitive = 1; regexp_reg.buf = rbuf; regexp_reg.pat = (unsigned char *) pat; regexp_reg.buf_len = sizeof (rbuf); if (SLang_regexp_compile (&regexp_reg)) { SLang_verror (SL_INVALID_PARM, "Unable to compile pattern"); return -1; } n--; len = strlen(str); if ((n < 0) || ((unsigned int) n >= len)) { /* SLang_Error = SL_INVALID_PARM; */ return 0; } str += n; len -= n; if (NULL == (match = SLang_regexp_match((unsigned char *) str, len, &regexp_reg))) return 0; /* adjust offsets */ regexp_reg.offset = n; return (1 + (int) ((char *) match - str)); } /*}}}*/ static int string_match_nth_cmd (int *nptr) /*{{{*/ { int n, beg; n = *nptr; if ((n < 0) || (n > 9) || (regexp_reg.pat == NULL) || ((beg = regexp_reg.beg_matches[n]) == -1)) { SLang_Error = SL_INVALID_PARM; return -1; } SLang_push_integer(beg + regexp_reg.offset); return regexp_reg.end_matches[n]; } /*}}}*/ static char *create_delimited_string (char **list, unsigned int n, char *delim) { unsigned int len, dlen; unsigned int i; unsigned int num; char *str, *s; len = 1; /* allow room for \0 char */ num = 0; for (i = 0; i < n; i++) { if (list[i] == NULL) continue; len += strlen (list[i]); num++; } dlen = strlen (delim); if (num > 1) len += (num - 1) * dlen; if (NULL == (str = SLmalloc (len))) return NULL; *str = 0; s = str; i = 0; while (num > 1) { while (list[i] == NULL) i++; strcpy (s, list[i]); s += strlen (list[i]); strcpy (s, delim); s += dlen; i++; num--; } if (num) { while (list[i] == NULL) i++; strcpy (s, list[i]); } return str; } static void create_delimited_string_cmd (int *nptr) { unsigned int n, i; char **strings; char *str; str = NULL; n = 1 + (unsigned int) *nptr; /* n includes delimiter */ if (NULL == (strings = (char **)SLmalloc (n * sizeof (char *)))) { SLdo_pop_n (n); return; } memset((char *)strings, 0, n * sizeof (char *)); i = n; while (i != 0) { i--; if (-1 == SLang_pop_slstring (strings + i)) goto return_error; } str = create_delimited_string (strings + 1, (n - 1), strings[0]); /* drop */ return_error: for (i = 0; i < n; i++) SLang_free_slstring (strings[i]); SLfree ((char *)strings); (void) SLang_push_malloced_string (str); /* NULL Ok */ } static void strjoin_cmd (char *delim) { SLang_Array_Type *at; char *str; if (-1 == SLang_pop_array_of_type (&at, SLANG_STRING_TYPE)) return; str = create_delimited_string ((char **)at->data, at->num_elements, delim); SLang_free_array (at); (void) SLang_push_malloced_string (str); /* NULL Ok */ } static void str_delete_chars_cmd (char *s, char *d) { unsigned char lut[256]; unsigned char *s1, *s2; unsigned char ch; make_lut ((unsigned char *)d, lut); if (NULL == (s = SLmake_string (s))) return; s1 = s2 = (unsigned char *) s; while ((ch = *s2++) != 0) { if (0 == lut[ch]) *s1++ = ch; } *s1 = 0; (void) SLang_push_malloced_string (s); } static unsigned char *make_lut_string (unsigned char *s) { unsigned char lut[256]; unsigned char *l; unsigned int i; /* Complement-- a natural order is imposed */ make_lut (s, lut); l = lut; for (i = 1; i < 256; i++) { if (lut[i]) *l++ = (unsigned char) i; } *l = 0; return (unsigned char *) SLmake_string ((char *)lut); } static unsigned char *make_str_range (unsigned char *s) { unsigned char *s1, *range; unsigned int num; unsigned char ch; int len; if (*s == '^') return make_lut_string (s); num = 0; s1 = s; while ((ch = *s1++) != 0) { unsigned char ch1; ch1 = *s1; if (ch1 == '-') { s1++; ch1 = *s1; len = (int)ch1 - (int)ch; if (len < 0) len = -len; num += (unsigned int) len; if (ch1 != 0) s1++; } num++; } range = (unsigned char *)SLmalloc (num + 1); if (range == NULL) return NULL; s1 = s; s = range; while ((ch = *s1++) != 0) { unsigned char ch1; unsigned int i; ch1 = *s1; if (ch1 != '-') { *s++ = ch; continue; } s1++; ch1 = *s1; if (ch > ch1) { if (ch1 == 0) ch1 = 1; for (i = (unsigned int) ch; i >= (unsigned int) ch1; i--) *s++ = (unsigned char) i; if (*s1 == 0) break; } else { for (i = (unsigned int) ch; i <= (unsigned int) ch1; i++) *s++ = (unsigned char) i; } s1++; } #if 0 if (range + num != s) SLang_verror (SL_INTERNAL_ERROR, "make_str_range: num wrong"); #endif *s = 0; return range; } static void strtrans_cmd (char *s, unsigned char *from, unsigned char *to) { unsigned char map[256]; char *s1; unsigned int i; unsigned char ch; unsigned char last_to; unsigned char *from_range, *to_range; for (i = 0; i < 256; i++) map[i] = (unsigned char) i; if (*to == 0) { str_delete_chars_cmd (s, (char *)from); return; } from_range = make_str_range (from); if (from_range == NULL) return; to_range = make_str_range (to); if (to_range == NULL) { SLfree ((char *)from_range); return; } from = from_range; to = to_range; last_to = 0; while ((ch = *from++) != 0) { unsigned char to_ch; if (0 == (to_ch = *to++)) { do { map[ch] = last_to; } while (0 != (ch = *from++)); break; } last_to = map[ch] = to_ch; } SLfree ((char *)from_range); SLfree ((char *)to_range); s = SLmake_string (s); if (s == NULL) return; s1 = s; while ((ch = (unsigned char) *s1) != 0) *s1++ = (char) map[ch]; (void) SLang_push_malloced_string (s); } static SLang_Intrin_Fun_Type Strops_Table [] = /*{{{*/ { MAKE_INTRINSIC_I("create_delimited_string", create_delimited_string_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_SS("strcmp", strcmp_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_SSI("strncmp", strncmp_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_0("strcat", strcat_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("strlen", strlen_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_SII("strchop", strchop_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_SII("strchopr", strchopr_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_I("strreplace", strreplace_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_SSS("str_replace", str_replace_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_SII("substr", substr_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_SS("is_substr", issubstr_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_II("strsub", strsub_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_SII("extract_element", extract_element_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_SSI("is_list_element", is_list_element_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_SSI("string_match", string_match_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_I("string_match_nth", string_match_nth_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_0("strlow", strlow_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_I("tolower", tolower_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_I("toupper", toupper_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_0("strup", strup_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("isdigit", isdigit_cmd, SLANG_INT_TYPE), MAKE_INTRINSIC_S("strtrim", strtrim_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("strtrim_end", strtrim_end_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("strtrim_beg", strtrim_beg_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("strcompress", strcompress_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_I("Sprintf", sprintf_n_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("sprintf", sprintf_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("sscanf", _SLang_sscanf, SLANG_INT_TYPE), MAKE_INTRINSIC_S("make_printable_string", make_printable_string, SLANG_VOID_TYPE), MAKE_INTRINSIC_SSI("str_quote_string", str_quote_string_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_SSS("str_uncomment_string", str_uncomment_string_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_II("define_case", SLang_define_case, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("strtok", strtok_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("strjoin", strjoin_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_SSS("strtrans", strtrans_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_SS("str_delete_chars", str_delete_chars_cmd, SLANG_VOID_TYPE), SLANG_END_INTRIN_FUN_TABLE }; /*}}}*/ int _SLang_init_slstrops (void) { return SLadd_intrin_fun_table (Strops_Table, NULL); }