# pcb-rnd devlog

## events

PCB has a nice action infrastructure: most user actions are implemented in smallish functions taking (int argc, char *argv[]). Menu items, hotkeys, the command line and batch processing just call these actions. This is the user->pcb_core direction of commands.

Before adding scripting to pcb-rnd, the other direction (pcb_core->user) has to be implemented: an event infrastructure. Random parts of the core or the HID code will yield events using a simple vararg event() function. Other parts of PCB, especially plugins, can bind (sign up to) events with function pointers. When an event is triggered, all functions signed up to the event are called (in random order).

Passing arguments to events is similar to the arguments of actions, except argv[] is not a char *[], but an event_arg_t *[]. event_arg_t has an enum field for argument type and an union for the argument value. This means the API is binary: integers are passed as integers, not as strings.