06-05-2006
First you'd have to define an interface to which the module writers would conform. My guess is that "modify every function in my program" does not really explain what and how to modify it. You are at the incorrect level of abstraction to make this work if you're going to have everything be function pointers.
Basically, you first want to define a concrete set of functionality that module writers should be able to hook into. Then you have to specify an interface agreement that the module writers can conform to.
One of the first things I think you may want to define is a procedure to initialize the module. Part of this could be that the module passes you back a set of function pointers (into itself) that you can call. You define the datastructure that gets passed and the module conforms and uses it to tell you want it wants to overload or hook into and passes you the callback or overload routine it wants you to call.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Howdie everyone...
I have a shell script RemoveFiles.sh
Inside this file, it only has two commands as below:
rm -f ../../reportToday/temp/*
rm -f ../../report/*
My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies
2. Solaris
I have Apache 2 webserver as delivered with the Solaris 10 installation.
How to verify if Apache is configured with loadable module support?
Or if needs to be recompiled with loadable module support. (2 Replies)
Discussion started by: kavera
2 Replies
3. Linux
Hi all,
I am working on USB data monitoring on Fedora Core 9. Kernel 2.6.25 has a built-in module (the one that isn't loadable, but compiles and links statically with the kernel during compilation) to snoop USB data. It is in <kernel_source_code>/drivers/usb/mon/.
I need to know if I can... (0 Replies)
Discussion started by: anitemp
0 Replies
4. Solaris
Hi men,
Have you ever meet this error ?
I install full Sun MC 4.0 packages (+ Add ons) exception of Sun Midrange Platform Administration because i don't know how to configure it
Then all other servers are ok, only E2900 servers have Config reader module error: Data Acquisition error
I... (12 Replies)
Discussion started by: tien86
12 Replies
5. Shell Programming and Scripting
I am writing perl script to configure Cisco device but Variables inside Net::Telnet::Cisco Module doesn't work and passed to device without resolving.
Please advise.
here is a sample of script:
use Net::Telnet::Cisco;
$device = "10.14.199.1";
($o1, $o2, $o3, $o4) = split(/\./,$device);... (5 Replies)
Discussion started by: ahmed_zaher
5 Replies
6. Red Hat
Hello friends
Today i have changed my passwd policy for strong password
Everything is working correctly but when i changed my password , it did not ask me my old password
my /etc/pam.d/system-auth file is (only passwdqc.so module line)
password required pam_passwdqc.so retry=3... (0 Replies)
Discussion started by: rink
0 Replies
7. Shell Programming and Scripting
My script work on Linux but not work in sun os.
my script.
logFiles="sentLog1.log sentLog2.log"
intial_time="0 0"
logLocation="/usr/local/tomcat/logs/"
sleepTime=600
failMessage=":: $(tput bold)Log not update$(tput rmso) = "
successMessage="OK"
arr=($logFiles)... (7 Replies)
Discussion started by: ooilinlove
7 Replies
8. Red Hat
I need to utilize pam_pwdfile in order to authenticate virtual users in vsftpd. I know I can utilize htpasswd2 -m to create a password file however it is vital since I am administrating several machines in our organization that the password generated be in clear text. Does anyone on here know if... (10 Replies)
Discussion started by: colbyshores
10 Replies
9. IP Networking
hi all. and sorry for the random question, but this sparkled a raging flame-war at work and i want more points of view
situation
a router, with linux of some sort,
dhcp client requesting for ip in wan1 (as usual with wan ports)
dhcp server listening in lan1, and assigning ip (as usual... (9 Replies)
Discussion started by: broli
9 Replies
LEARN ABOUT DEBIAN
anyevent::readme
README(3pm) User Contributed Perl Documentation README(3pm)
NAME
AnyEvent::Callback - callback aggregator for AnyEvent watchers.
SYNOPSIS
use AnyEvent::Callback;
# usually watchers are looked as:
AE::something @args, sub { ... };
AE::something
@args,
sub { ... }, # result
sub { ... }; # error
use AnyEvent::Callback;
AE::something @args, CB { ... };
AE::something @args,
CB sub { ... }, # result
sub { ... }; # error
AE::something @args,
CB sub { ... }, # result
sub { ... }, # error
sub { ... }; # anyway callback
Callback hierarchy
my $cbchild = $cb->CB(sub { ... });
...
$cbchild->error('error'); # will call $cb->error('error');
Inside Your callback You can:
sub my_watcher {
my $cb = pop;
my @args = @_;
# ...
$cb->error( @error ); # error callback will be called
# or:
$cb->( $value ); # result callback will be called
}
Callbacks stack
my $cbs = CBS;
for (1 .. $n) {
AE::something @args, $cbs->cb;
}
$cbs->wait(sub {
for (@_) {
if ($_->is_error) { # handle one error
my @err = $_->errors; # or:
my $errstr = $_->errstr;
} else { # results
my @res = $_->results;
}
}
});
DESCRIPTION
The module allows You to create callback's hierarchy. Also the module groups error and result callbacks into one object.
Also the module checks if one callback was called by watcher or not. If a watcher doesn't call result or error callback, error callback
will be called automatically.
Also the module checks if a callback was called reentrant. In the case the module will complain (using "carp" in Carp).
If a watcher touches error callback and if superior didn't define error callback, the module will call error callback upwards hierarchy.
Example:
AE::something @args, CB &my_watcher, &on_error;
sub on_error {
}
sub my_watcher {
my $cb = pop;
...
the_other_watcher $cb->CB( sub { # error callback wasn't defined
my $cb = pop;
...
yet_another_watcher1 $cb->CB( sub {
my $cb = pop;
...
$cb->( 123 ); # upwards callback
});
yet_another_watcher2 $cb->CB( sub {
my $cb = pop;
...
$cb->error( 456 ); # on_error will be called
});
});
}
METHODS
'CODE' (overloaded fake method)
$cb->( ... );
You can use the object as usually CODEREF.
CB
Creates new callback object that have binding on parent callback.
my $new_cb = $cb->CB(sub { ... }); # the cb doesn't catch errors
my $new_cb = CB(sub { ... }, sub { ... }); # the cb catches errors
my $new_cb = $cb->CB(sub { ... }, sub { ... }); # the same
error
Calls error callback. If the object has no registered error callbacks, parent object's error callback will be called.
$cb->error('WTF?');
COPYRIGHT AND LICENCE
Copyright (C) 2012 by Dmitry E. Oboukhov
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2012-06-30 README(3pm)