[dhcp-agent-commits] dhcp-agent/src dhcp-client-guile.c,1.4,1.5 dhcp-client-guile.h,1.1,1.2 dhcp-cli
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv8131/src Modified Files: dhcp-client-guile.c dhcp-client-guile.h dhcp-client-states.c dhcp-client.c dhcp-sysconf.c dhcp-sysconf.h Log Message: now using hooks for guile extension Index: dhcp-client-guile.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-guile.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-client-guile.c 15 May 2003 06:53:48 -0000 1.4 --- dhcp-client-guile.c 20 May 2003 01:43:40 -0000 1.5 *************** *** 538,543 **** } ! /* run the guile dhcp sysconf script. */ ! static void dhcp_run_guile_sysconf(dhcp_client_control_t *dc) { stringbuffer_t *sb; --- 538,579 ---- } ! /* run the applicable guile hook of state. */ ! static void dhcp_run_guile_sysconf(dhcp_client_control_t *dc, int state) ! { ! SCM hook; ! ! switch(state) { ! ! case STATE_SETUP: ! ! hook = scm_c_eval_string("dhcp-bound-hook"); ! scm_c_run_hook(hook, SCM_EOL); ! break; ! ! case STATE_REBIND: ! ! hook = scm_c_eval_string("dhcp-rebind-hook"); ! scm_c_run_hook(hook, SCM_EOL); ! break; ! ! case STATE_RENEW: ! hook = scm_c_eval_string("dhcp-renew-hook"); ! scm_c_run_hook(hook, SCM_EOL); ! break; ! ! case STATE_DO_SHUTDOWN: ! hook = scm_c_eval_string("dhcp-release-hook"); ! scm_c_run_hook(hook, SCM_EOL); ! break; ! ! default: ! FATAL_MESSAGE("illegal state value passed."); ! } ! ! return; ! } ! ! /* load the guile dhcp sysconf script. */ ! static void load_guile_sysconf(dhcp_client_control_t *dc) { stringbuffer_t *sb; *************** *** 578,583 **** * * * * * * * * * * * * * * * */ ! void dhcp_guile_init(void) { init_client_control_smob(); --- 614,622 ---- * * * * * * * * * * * * * * * */ ! void dhcp_guile_init(dhcp_client_control_t *dc) { + SCM hook; + + /* initialize the client control smob */ init_client_control_smob(); *************** *** 593,604 **** scm_c_define_gsubr("client-fatal-error-message", 1, 0, 0, scm_client_fatal_error_message); scm_c_define_gsubr("client-shutdown", 1, 0, 0, scm_client_shutdown); ! return; } ! void dhcp_sysconf_guile(dhcp_client_control_t *dc, list_t *options) { dhcp_def_guile_options(dc, options); ! dhcp_run_guile_sysconf(dc); dhcp_undef_guile_options(dc, options); --- 632,664 ---- scm_c_define_gsubr("client-fatal-error-message", 1, 0, 0, scm_client_fatal_error_message); scm_c_define_gsubr("client-shutdown", 1, 0, 0, scm_client_shutdown); ! ! /* create hooks. */ ! ! /* bound hook. */ ! hook = scm_make_hook(SCM_MAKINUM(0)); ! scm_c_define("dhcp-bound-hook", hook); ! ! /* rebind. */ ! hook = scm_make_hook(SCM_MAKINUM(0)); ! scm_c_define("dhcp-rebind-hook", hook); ! ! /* renew. */ ! hook = scm_make_hook(SCM_MAKINUM(0)); ! scm_c_define("dhcp-renew-hook", hook); ! ! /* release. */ ! hook = scm_make_hook(SCM_MAKINUM(0)); ! scm_c_define("dhcp-release-hook", hook); ! ! /* load user definitions. */ ! load_guile_sysconf(dc); ! return; } ! void dhcp_sysconf_guile(dhcp_client_control_t *dc, list_t *options, int state) { dhcp_def_guile_options(dc, options); ! dhcp_run_guile_sysconf(dc, state); dhcp_undef_guile_options(dc, options); Index: dhcp-client-guile.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-guile.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-client-guile.h 11 May 2003 07:48:29 -0000 1.1 --- dhcp-client-guile.h 20 May 2003 01:43:40 -0000 1.2 *************** *** 33,39 **** /* guile interface. */ ! extern void dhcp_sysconf_guile(dhcp_client_control_t *dc, list_t *options); ! extern void dhcp_guile_init(void); #endif /* DHCP_CLIENT_GUILE_H */ - --- 33,38 ---- /* guile interface. */ ! extern void dhcp_sysconf_guile(dhcp_client_control_t *dc, list_t *options, int state); ! extern void dhcp_guile_init(dhcp_client_control_t *dc); #endif /* DHCP_CLIENT_GUILE_H */ Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** dhcp-client-states.c 11 May 2003 07:49:05 -0000 1.28 --- dhcp-client-states.c 20 May 2003 01:43:41 -0000 1.29 *************** *** 660,664 **** do_sysconf_setup_timers(options, dc); ! do_sysconf(options, dc); dhcp_opt_destroy_option_list(options); --- 660,664 ---- do_sysconf_setup_timers(options, dc); ! do_sysconf(options, dc, STATE_SETUP); dhcp_opt_destroy_option_list(options); *************** *** 761,765 **** cached_options = client_cache_load_options(dc->cache, 0); ! do_sysconf_cleanup(cached_options, dc); dhcp_opt_destroy_option_list(cached_options); --- 761,765 ---- cached_options = client_cache_load_options(dc->cache, 0); ! do_sysconf(cached_options, dc, STATE_DO_SHUTDOWN); dhcp_opt_destroy_option_list(cached_options); Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** dhcp-client.c 19 May 2003 23:43:03 -0000 1.25 --- dhcp-client.c 20 May 2003 01:43:42 -0000 1.26 *************** *** 391,394 **** --- 391,397 ---- } + /* load up user guile sysconf script. */ + dhcp_guile_init(dc); + if(fake_hw_addr) /* Marla, you liar, you big tourist, I need this. Now get out! */ dhcp_client_control_use_fake_hw_addr(dc, fake_hw_addr); *************** *** 477,482 **** INFO_MESSAGE("See LICENSE file for details."); INFO_MESSAGE(" "); - - dhcp_guile_init(); while((c = getopt(argc, argv, "tpcdavi:m:kwh:l:H:")) != -1) { --- 480,483 ---- Index: dhcp-sysconf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-sysconf.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** dhcp-sysconf.c 11 May 2003 07:49:05 -0000 1.17 --- dhcp-sysconf.c 20 May 2003 01:43:42 -0000 1.18 *************** *** 45,57 **** * * * * * * * * * * * */ ! void do_sysconf(list_t *options, dhcp_client_control_t *dc) ! { ! return dhcp_sysconf_guile(dc, options); ! } ! ! void do_sysconf_cleanup(list_t *options, dhcp_client_control_t *dc) { ! /* nada :-) */ ! return; } --- 45,51 ---- * * * * * * * * * * * */ ! void do_sysconf(list_t *options, dhcp_client_control_t *dc, int state) { ! return dhcp_sysconf_guile(dc, options, state); } Index: dhcp-sysconf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-sysconf.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-sysconf.h 11 May 2003 07:49:05 -0000 1.5 --- dhcp-sysconf.h 20 May 2003 01:43:42 -0000 1.6 *************** *** 40,45 **** /* System configuration routines. */ ! extern void do_sysconf(list_t *options, dhcp_client_control_t *dc); ! extern void do_sysconf_cleanup(list_t *options, dhcp_client_control_t *dc); extern void do_sysconf_setup_timers(list_t *options, dhcp_client_control_t *dc); --- 40,44 ---- /* System configuration routines. */ ! extern void do_sysconf(list_t *options, dhcp_client_control_t *dc, int state); extern void do_sysconf_setup_timers(list_t *options, dhcp_client_control_t *dc); |