void check_for_changes(char *path) { chdir(path); File_t *file_list_one = first_run(path); // FilesInDirectory(path); for (;;) { sleep(changes_interval); if (debugging) { puts("PING!"); } File_t *file_list_two = files_in_directory(path); compare_file_lists(file_list_one, file_list_two); file_list_free(file_list_one); if (run_once) { file_list_free(file_list_two); return; } file_list_one = file_list_two; } }
void init() { Serial.begin(115200); debug("Starting..."); pinMode(FIRST_RUN_PIN, INPUT); web_run(); if(digitalRead(FIRST_RUN_PIN) && AppSettings.load()){ debugf("SSID:%s PASS:%s", AppSettings.ssid.c_str(), AppSettings.password.c_str()); WifiStation.config(AppSettings.ssid.c_str(), AppSettings.password.c_str()); WifiStation.waitConnection(on_wifi_connected); driver_init(); } else { first_run(); } }
void file_init (Conf *config) { char *buffer; char *key, *val; FILE *fd; char *old_version = NULL; buffer = CONFIG_FILE; if ((fd = fopen (buffer, "r")) == NULL) { first_run (buffer); if ((fd = fopen (buffer, "r")) == NULL) { exit(1); } } c2_free (buffer); /* Start reading the file */ for (;;) { if ((key = fd_get_word (fd)) == NULL) break; if ((val = fd_get_word (fd)) == NULL) break; if (fd_move_to (fd, '\n', 1, TRUE, TRUE) == EOF) fseek (fd, -1, SEEK_CUR); if (streq (key, "empty_garbage")) { config->empty_garbage = atoi (val); c2_free (val); } else if (streq (key, "account")) { load_account (&config->account_head, val); } else if (streq (key, "mailbox")) { c2_mailbox_load (&config->mailbox_head, val); } else if (streq (key, "check_timeout")) { config->check_timeout = atoi (val); c2_free (val); } else if (streq (key, "check_at_start")) { config->check_at_start = atoi (val); c2_free (val); } else if (streq (key, "use_outbox")) { config->use_outbox = atoi (val); c2_free (val); } else if (streq (key, "use_persistent_smtp_connection")) { config->use_persistent_smtp_connection = atoi (val); c2_free (val); } else if (streq (key, "persistent_smtp_address")) { config->persistent_smtp_address = val; } else if (streq (key, "persistent_smtp_port")) { config->persistent_smtp_port = atoi (val); c2_free (val); } else if (streq (key, "prepend_char_on_re")) { c2_free (config->prepend_char_on_re); config->prepend_char_on_re = val; } else if (streq (key, "message_bigger")) { config->message_bigger = atoi (val); c2_free (val); } else if (streq (key, "timeout")) { config->timeout = atoi (val); c2_free (val); } else if (streq (key, "mark_as_read")) { config->mark_as_read = atoi (val); c2_free (val); } #ifdef BUILD_ADDRESS_BOOK else if (streq (key, "addrbook_init")) { config->addrbook_init = atoi (val); c2_free (val); } #endif else if (streq (key, "color_reply_original_message")) { sscanf (val, "%dx%dx%d", (int *) &config->color_reply_original_message.red, (int *) &config->color_reply_original_message.green, (int *) &config->color_reply_original_message.blue); c2_free (val); } else if (streq (key, "color_misc_body")) { sscanf (val, "%dx%dx%d", (int *) &config->color_misc_body.red, (int *) &config->color_misc_body.green, (int *) &config->color_misc_body.blue); c2_free (val); } else if (streq (key, "cronosII")) { if (strne (val+2, VERSION)) { old_version = g_strdup (val+2); } } else { buffer = g_strdup_printf (_("Unknown command in config file: %s"), key); cronos_error (ERROR_INTERNAL, buffer, ERROR_WARNING); c2_free (val); } c2_free (key); } fclose (fd); if (old_version) { pthread_t thread; pthread_create (&thread, NULL, PTHREAD_FUNC (c2_version_difference), old_version); } }