#include #include "netconf.h" #include #include "netconf.m" #include "internal.h" static NETCONF_HELP_FILE help_netlevel ("netlevel"); static CONFIG_FILE f_netlevel (VAR_RUN_NETLEVEL,help_netlevel ,CONFIGF_MANAGED|CONFIGF_OPTIONAL); /* Store the net level into /var/run/netconf.level */ void netconf_setnetlevel(int level) { FILE_CFG *fout = f_netlevel.fopen ("w"); if (fout != NULL){ fprintf (fout,"%d\n",level); fclose (fout); } } /* Retrieve the net level from /var/run/netconf.level */ int netconf_getnetlevel() { int level=2; FILE_CFG *fin = f_netlevel.fopen ("r"); if (fin != NULL){ fscanf (fin,"%d\n",&level); fclose (fin); } if (level < 0 || level > 2){ xconf_error (MSG_U(E_IVLDNETLEVEL ,"File %s\n" "contains an invalid netconf level: %d\n" "It must be 0, 1 or 2.\n" "Just run \"netconf --runlevel\" with an\n" "explicit value (local, client, or server)\n" "to fix this.\n" "\n" "Assuming \"local\" configuration for now.\n") ,VAR_RUN_NETLEVEL,level); level = 0; } return level; }