-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 2.4 2002/12/28 03:58:19 david__schmidt Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/src/loadcfg.c,v $
*
* Revisions :
* $Log: loadcfg.c,v $
+ * Revision 2.4 2002/12/28 03:58:19 david__schmidt
+ * Initial drop of dashboard instrumentation - enabled with
+ * --enable-activity-console
+ *
+ * Revision 2.3 2002/09/19 03:48:29 iwanttokeepanon
+ * Just moved "int i" up 3 lines in function unload_configfile, out of the "ifdef FEATURE_ACL" clause. I disable ACL and it was not compiling because "int i" was ifdef(d) out. I noticed this in the past, but am just now in a spot where I can change/commit stuff ... long live broadband!
+ *
+ * Revision 2.2 2002/09/04 15:48:33 oes
+ * Synced with the stable branch:
+ * Revision 1.48.2.1 2002/08/21 17:58:05 oes
+ * Temp kludge to let user and default action file be edited through win32 GUI (FR 592080)
+ *
+ * Revision 2.1 2002/06/04 17:22:36 jongfoster
+ * Adding comments
+ *
* Revision 2.0 2002/06/04 14:34:21 jongfoster
* Moving source files to src/
*
* console and GUI specific options last).
*/
-#define hash_actions_file 1196306641ul /**< "actionsfile" */
-#define hash_admin_address 4112573064ul /**< "admin-address" */
-#define hash_buffer_limit 1881726070ul /**< "buffer-limit */
-#define hash_confdir 1978389ul /**< "confdir" */
-#define hash_debug 78263ul /**< "debug" */
-#define hash_deny_access 1227333715ul /**< "deny-access" */
-#define hash_enable_edit_actions 2517097536ul /**< "enable-edit-actions" */
-#define hash_enable_remote_toggle 2979744683ul /**< "enable-remote-toggle" */
-#define hash_filterfile 250887266ul /**< "filterfile" */
-#define hash_forward 2029845ul /**< "forward" */
-#define hash_forward_socks4 3963965521ul /**< "forward-socks4" */
-#define hash_forward_socks4a 2639958518ul /**< "forward-socks4a" */
-#define hash_jarfile 2046641ul /**< "jarfile" */
-#define hash_listen_address 1255650842ul /**< "listen-address" */
-#define hash_logdir 422889ul /**< "logdir" */
-#define hash_logfile 2114766ul /**< "logfile" */
-#define hash_permit_access 3587953268ul /**< "permit-access" */
-#define hash_proxy_info_url 3903079059ul /**< "proxy-info-url" */
-#define hash_single_threaded 4250084780ul /**< "single-threaded" */
-#define hash_suppress_blocklists 1948693308ul /**< "suppress-blocklists" */
-#define hash_toggle 447966ul /**< "toggle" */
-#define hash_trust_info_url 430331967ul /**< "trust-info-url" */
-#define hash_trustfile 56494766ul /**< "trustfile" */
-#define hash_usermanual 1416668518ul /**< "user-manual" */
-
-#define hash_activity_animation 1817904738ul /**< "activity-animation" */
-#define hash_close_button_minimizes 3651284693ul /**< "close-button-minimizes" */
-#define hash_hide_console 2048809870ul /**< "hide-console" */
-#define hash_log_buffer_size 2918070425ul /**< "log-buffer-size" */
-#define hash_log_font_name 2866730124ul /**< "log-font-name" */
-#define hash_log_font_size 2866731014ul /**< "log-font-size" */
-#define hash_log_highlight_messages 4032101240ul /**< "log-highlight-messages" */
-#define hash_log_max_lines 2868344173ul /**< "log-max-lines" */
-#define hash_log_messages 2291744899ul /**< "log-messages" */
-#define hash_show_on_task_bar 215410365ul /**< "show-on-task-bar" */
-
+#define hash_actions_file 1196306641ul /**< "actionsfile" */
+#define hash_activity_console_address 18904208ul /**< "activity-console-address" */
+#define hash_activity_console_update_freq 3442780376ul /**< "activity-console-update-freq" */
+#define hash_admin_address 4112573064ul /**< "admin-address" */
+#define hash_buffer_limit 1881726070ul /**< "buffer-limit */
+#define hash_confdir 1978389ul /**< "confdir" */
+#define hash_debug 78263ul /**< "debug" */
+#define hash_deny_access 1227333715ul /**< "deny-access" */
+#define hash_enable_edit_actions 2517097536ul /**< "enable-edit-actions" */
+#define hash_enable_remote_toggle 2979744683ul /**< "enable-remote-toggle" */
+#define hash_filterfile 250887266ul /**< "filterfile" */
+#define hash_forward 2029845ul /**< "forward" */
+#define hash_forward_socks4 3963965521ul /**< "forward-socks4" */
+#define hash_forward_socks4a 2639958518ul /**< "forward-socks4a" */
+#define hash_image_blocker_custom_file 2863352327ul /**< "image-blocker-custom-file" */
+#define hash_jarfile 2046641ul /**< "jarfile" */
+#define hash_listen_address 1255650842ul /**< "listen-address" */
+#define hash_logdir 422889ul /**< "logdir" */
+#define hash_logfile 2114766ul /**< "logfile" */
+#define hash_permit_access 3587953268ul /**< "permit-access" */
+#define hash_proxy_info_url 3903079059ul /**< "proxy-info-url" */
+#define hash_single_threaded 4250084780ul /**< "single-threaded" */
+#define hash_suppress_blocklists 1948693308ul /**< "suppress-blocklists" */
+#define hash_toggle 447966ul /**< "toggle" */
+#define hash_trust_info_url 430331967ul /**< "trust-info-url" */
+#define hash_trustfile 56494766ul /**< "trustfile" */
+#define hash_usermanual 1416668518ul /**< "user-manual" */
+
+#define hash_activity_animation 1817904738ul /**< "activity-animation" */
+#define hash_close_button_minimizes 3651284693ul /**< "close-button-minimizes" */
+#define hash_hide_console 2048809870ul /**< "hide-console" */
+#define hash_log_buffer_size 2918070425ul /**< "log-buffer-size" */
+#define hash_log_font_name 2866730124ul /**< "log-font-name" */
+#define hash_log_font_size 2866731014ul /**< "log-font-size" */
+#define hash_log_highlight_messages 4032101240ul /**< "log-highlight-messages" */
+#define hash_log_max_lines 2868344173ul /**< "log-max-lines" */
+#define hash_log_messages 2291744899ul /**< "log-messages" */
+#define hash_show_on_task_bar 215410365ul /**< "show-on-task-bar" */
static void savearg(char *command, char *argument, struct configuration_spec * config);
{
struct configuration_spec * config = (struct configuration_spec *)data;
struct forward_spec *cur_fwd = config->forward;
+ int i;
#ifdef FEATURE_ACL
struct access_control_list *cur_acl = config->acl;
- int i;
while (cur_acl != NULL)
{
freez(config->re_filterfile);
+ freez(config->image_blocker_data);
+ freez(config->image_blocker_format);
}
struct configuration_spec * load_config(void)
{
char buf[BUFFER_SIZE];
- char *p, *q;
- FILE *configfp = NULL;
+ char *p, *q, *image_buf, *image_path;
+ FILE *configfp = NULL,
+ *imagefp = NULL;
struct configuration_spec * config = NULL;
struct client_state * fake_csp;
struct file_list *fs;
+ struct stat statbuf[1];
unsigned long linenum = 0;
- int i;
+ int i, file_size, bytes_read;
if ( !check_file_changed(current_configfile, configfile, &fs))
{
config->buffer_limit = 4096 * 1024;
config->usermanual = strdup(USER_MANUAL_URL);
config->proxy_args = strdup("");
+#ifdef FEATURE_ACTIVITY_CONSOLE
+ config->activity_port = ACTIVTY_ADDR_PORT;
+ config->activity_freq = 5;
+#endif /* def FEATURE_ACTIVITY_CONSOLE */
if ((configfp = fopen(configfile, "r")) == NULL)
{
free(p);
continue;
+/* *************************************************************************
+ * activity-console-address [ip][:port]
+ * *************************************************************************/
+#ifdef FEATURE_ACTIVITY_CONSOLE
+ case hash_activity_console_address :
+ freez(config->activity_address);
+ config->activity_address = strdup(arg);
+ continue;
+#endif /* def FEATURE_ACTIVITY_CONSOLE */
+
+/* *************************************************************************
+ * activity-console-update-freq
+ * *************************************************************************/
+#ifdef FEATURE_ACTIVITY_CONSOLE
+ case hash_activity_console_update_freq :
+ config->activity_freq = atoi(arg);
+ if (config->activity_freq < 1)
+ config->activity_freq = 5;
+ continue;
+#endif /* def FEATURE_ACTIVITY_CONSOLE */
+
/* *************************************************************************
* admin-address email-address
* *************************************************************************/
#endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
+/* *************************************************************************
+ * image-blocker-custom-file
+ * *************************************************************************/
+ case hash_image_blocker_custom_file :
+ freez(config->image_blocker_data);
+ freez(config->image_blocker_format);
+ config->image_blocker_length = 0;
+ image_path = make_path(config->confdir, arg);
+
+ /*
+ * Load up the custom image bitmap file
+ */
+ if (NULL == (imagefp = fopen(image_path, "rb")))
+ {
+ /*
+ * If we can't open the user's requested image, complain
+ */
+ log_error(LOG_LEVEL_ERROR, "Unable to load custom blocker image: %s.", image_path);
+ }
+ else
+ {
+ if (stat(image_path, statbuf) == 0)
+ {
+ file_size = statbuf->st_size;
+ image_buf = zalloc(file_size);
+ if (image_buf != NULL)
+ {
+ bytes_read = fread(image_buf,1,file_size,imagefp);
+ if (bytes_read > 0)
+ {
+ config->image_blocker_data = image_buf;
+ config->image_blocker_length = file_size;
+ /*
+ * Ensure we can look into files for file signatures
+ */
+ if (file_size > 10)
+ {
+ /*
+ * Snoop into the binary data for a filetype signature
+ */
+ if (memcmp(image_buf,"GIF",3) == 0)
+ config->image_blocker_format = IMAGE_MIMETYPE_GIF;
+ else if (memcmp(&image_buf[6],"JFIF",4) == 0)
+ config->image_blocker_format = IMAGE_MIMETYPE_JPG;
+ else if (memcmp(&image_buf[1],"PNG",3) == 0)
+ config->image_blocker_format = IMAGE_MIMETYPE_PNG;
+ else
+ {
+ log_error(LOG_LEVEL_ERROR, "Unsupported custom image file type.");
+ freez(config->image_blocker_data);
+ }
+ }
+ else
+ freez(config->image_blocker_data);
+ }
+ else
+ {
+ log_error(LOG_LEVEL_ERROR, "Unable to read custom blocker image: %s", image_path, bytes_read, file_size);
+ freez(image_buf);
+ config->image_blocker_length = 0;
+ }
+ }
+ else
+ log_error(LOG_LEVEL_ERROR, "Unable to allocate memory for custom blocker image: %s.", image_path);
+ }
+ else
+ log_error(LOG_LEVEL_ERROR, "Unable to get statistics on custom blocker image file: %s", image_path);
+ }
+ freez(image_path);
+ /*
+ * If our load failed for some reason, just give the default
+ * checkerboard pattern
+ */
+ if (config->image_blocker_data == NULL)
+ {
+ log_error(LOG_LEVEL_ERROR, "Custom blocker image processing failed; defaulting to \"pattern\".");
+ config->image_blocker_data = (char*)image_pattern_data;
+ config->image_blocker_length = image_pattern_length;
+ config->image_blocker_format = BUILTIN_IMAGE_MIMETYPE;
+ }
+ continue;
/* *************************************************************************
* Warnings about unsupported features
}
#endif /* def FEATURE_COOKIE_JAR */
+#ifdef FEATURE_ACTIVITY_CONSOLE
+ if ( NULL == config->activity_address )
+ {
+ config->activity_address = strdup( ACTIVTY_ADDR_DEFAULT );
+ }
+
+ if ( NULL != config->activity_address )
+ {
+ if (NULL != (p = strchr(config->activity_address, ':')))
+ {
+ *p++ = '\0';
+ if (*p)
+ {
+ config->activity_port = atoi(p);
+ }
+ }
+
+ if (config->activity_port <= 0)
+ {
+ *--p = ':';
+ log_error(LOG_LEVEL_ERROR, "invalid activity port spec %s", config->activity_address);
+ }
+ if (*config->activity_address == '\0')
+ {
+ config->activity_address = NULL;
+ }
+ }
+ log_error(LOG_LEVEL_INFO, "Sending statistics updates to %s, port %d.", config->activity_address, config->activity_port);
+#endif /* def FEATURE_ACTIVITY_CONSOLE */
+
if ( NULL == config->haddr )
{
config->haddr = strdup( HADDR_DEFAULT );
/* FIXME: this is a kludge for win32 */
#if defined(_WIN32) && !defined (_WIN_CONSOLE)
- g_actions_file = config->actions_file[0]; /* FIXME only works for first action file */
+ g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
+ g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
g_re_filterfile = config->re_filterfile;
#ifdef FEATURE_TRUST