c:start
Table of Contents
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 my twitter client. odd, huh? :)
irc bot
lot of stuffs to learn in that. http://scottn.us/bot.php
Modules example
- Makefile
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
- common.h
struct s_cmd { char *text; void (*func)(); };
- main.c
#include <stdio.h> #include <dlfcn.h> #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; }
c/start.txt · Last modified: 2023/11/04 22:30 by 127.0.0.1