====== Programming ======
Some things I do. Little snippets of peoples homework and such are here: http://scottn.us/code/
====== awk =====
I've been messing with awk a lot lately. Some is in the code directory, but the big one is [[c:twitter.awk|my twitter client]]. odd, huh? :)
====== irc bot =====
lot of stuffs to learn in that. http://scottn.us/bot.php
====== Modules example ======
all: main module
main: main.c
$(CC) $(CFLAGS) -o main main.c -ldl
module: module.c
$(CC) $(CFLAGS) -shared -o module.o module.c
clean:
-rm -f main module.o
struct s_cmd {
char *text;
void (*func)();
};
#include
#include
#include "common.h"
int main(int argc, char **argv)
{
void *dll;
struct s_cmd *c;
void (*func)();
dll = dlopen("./module.o", RTLD_LAZY);
if (!dll) {
fputs(dlerror(), stderr);
return -1;
}
c = dlsym(dll, "__exports");
if (!c) {
fputs("No __exports?\n", stderr);
return -1;
}
while (c->text)
{
printf("my_command = [%s]\n", c->text);
c->func();
c++;
}
return 0;
}
#include
#include "common.h"
void cmd_test();
void cmd_again();
struct s_cmd __exports[] = {
{ "test", &cmd_test },
{ "again", &cmd_again },
NULL
};
void cmd_test()
{
printf("This is test1.\n");
}
void cmd_again()
{
printf("And this is another test\n");
}