static void instance_free (struct instance *o, int is_error) { // free DHCP BDHCPClient_Free(&o->dhcp); if (is_error) { NCDModuleInst_Backend_DeadError(o->i); } else { NCDModuleInst_Backend_Dead(o->i); } }
int main (int argc, char **argv) { if (argc <= 0) { return 1; } if (argc != 2) { printf("Usage: %s <interface>\n", argv[0]); goto fail0; } char *ifname = argv[1]; BTime_Init(); BLog_InitStdout(); if (!BNetwork_GlobalInit()) { DEBUG("BNetwork_GlobalInit failed"); goto fail1; } if (!BReactor_Init(&reactor)) { DEBUG("BReactor_Init failed"); goto fail1; } if (!BSignal_Init(&reactor, signal_handler, NULL)) { DEBUG("BSignal_Init failed"); goto fail2; } struct BDHCPClient_opts opts = {}; if (!BDHCPClient_Init(&dhcp, ifname, opts, &reactor, dhcp_handler, NULL)) { DEBUG("BDHCPClient_Init failed"); goto fail3; } BReactor_Exec(&reactor); BDHCPClient_Free(&dhcp); fail3: BSignal_Finish(); fail2: BReactor_Free(&reactor); fail1: BLog_Free(); fail0: DebugObjectGlobal_Finish(); return 1; }