static void metadata_cache_update(FileData *fd, const gchar *key, const GList *values) { GList *work; work = fd->cached_metadata; while (work) { GList *entry = work->data; gchar *entry_key = entry->data; if (strcmp(entry_key, key) == 0) { /* key found - just replace values */ GList *old_values = entry->next; entry->next = NULL; old_values->prev = NULL; string_list_free(old_values); work->data = g_list_append(entry, string_list_copy(values)); DEBUG_1("updated %s %s\n", key, fd->path); return; } work = work->next; } /* key not found - prepend new entry */ fd->cached_metadata = g_list_prepend(fd->cached_metadata, g_list_prepend(string_list_copy(values), g_strdup(key))); DEBUG_1("added %s %s\n", key, fd->path); }
static void rc_free(void *renderer) { RendererClutter *rc = (RendererClutter *)renderer; GtkWidget *widget = gtk_bin_get_child(GTK_BIN(rc->pr)); rc_remove_pending_updates(rc); rc_overlay_free_all(rc); if (widget) { /* widget still exists */ clutter_actor_destroy(rc->group); if (clutter_group_get_n_children(CLUTTER_GROUP(rc->stage)) == 0) { DEBUG_1("destroy %p", rc->widget); /* this was the last user */ gtk_widget_destroy(rc->widget); } else { DEBUG_1("keep %p", rc->widget); g_object_unref(G_OBJECT(rc->widget)); } } g_free(rc); }
void DS18B20_sample(){ #ifdef DEBUG_DS18B20_POLLER DEBUG_1("Starting"); #endif #ifdef DEBUG_DS18B20_POLLER DEBUG_5("Requesting Temperatures"); #endif char buf[25]; ds_sensors.requestTemperatures(); for (int i=0; i < ds_count; i++){ #ifdef DEBUG_DS18B20_POLLER DEBUG_5("Logging DSB Pin"); #endif sprintf(buf, "DS18B20.%d", i); logMessage(buf, ds_sensors.getTempCByIndex(i), "Degrees/C"); #ifdef DEBUG_DS18B20_POLLER DEBUG_5("Logged DSB Pin"); #endif } #ifdef DEBUG_DS18B20_POLLER DEBUG_2("Requested Temperatures"); #endif #ifdef DEBUG_DS18B20_POLLER DEBUG_1("Finished"); #endif }
void layout_image_lirc_init(LayoutWindow *lw) { gint flags; gboolean lirc_verbose = (get_debug_level() >= 2); lirc_fd = lirc_init(GQ_APPNAME_LC, lirc_verbose); if (lirc_fd == -1) { DEBUG_1("Initializing LIRC... failed"); return; } DEBUG_1("Initializing LIRC... OK"); if (lirc_readconfig(NULL, &config, NULL) == -1) { lirc_deinit(); g_fprintf(stderr, _("could not read LIRC config file\n" "please read the documentation of LIRC to \n" "know how to create a proper config file\n")); fflush(stderr); DEBUG_1("Failed to read LIRC config file"); return; } if (lirc_verbose) fflush(stderr); gio_chan = g_io_channel_unix_new(lirc_fd); input_tag = g_io_add_watch(gio_chan, G_IO_IN, lirc_input_callback, lw); fcntl(lirc_fd, F_SETOWN, getpid()); flags = fcntl(lirc_fd, F_GETFL, 0); if (flags != -1) fcntl(lirc_fd, F_SETFL, flags|O_NONBLOCK); }
static ColorManCache *color_man_cache_new(ColorManProfileType in_type, const gchar *in_file, guchar *in_data, guint in_data_len, ColorManProfileType out_type, const gchar *out_file, guchar *out_data, guint out_data_len, gboolean has_alpha) { ColorManCache *cc; color_man_lib_init(); cc = g_new0(ColorManCache, 1); cc->refcount = 1; cc->profile_in_type = in_type; cc->profile_in_file = g_strdup(in_file); cc->profile_out_type = out_type; cc->profile_out_file = g_strdup(out_file); cc->has_alpha = has_alpha; cc->profile_in = color_man_cache_load_profile(cc->profile_in_type, cc->profile_in_file, in_data, in_data_len); cc->profile_out = color_man_cache_load_profile(cc->profile_out_type, cc->profile_out_file, out_data, out_data_len); if (!cc->profile_in || !cc->profile_out) { DEBUG_1("failed to load color profile for %s: %d %s", (!cc->profile_in) ? "input" : "screen", (!cc->profile_in) ? cc->profile_in_type : cc->profile_out_type, (!cc->profile_in) ? cc->profile_in_file : cc->profile_out_file); color_man_cache_unref(cc); return NULL; } cc->transform = cmsCreateTransform(cc->profile_in, (has_alpha) ? TYPE_RGBA_8 : TYPE_RGB_8, cc->profile_out, (has_alpha) ? TYPE_RGBA_8 : TYPE_RGB_8, INTENT_PERCEPTUAL, 0); if (!cc->transform) { DEBUG_1("failed to create color profile transform"); color_man_cache_unref(cc); return NULL; } if (cc->profile_in_type != COLOR_PROFILE_MEM && cc->profile_out_type != COLOR_PROFILE_MEM ) { cm_cache_list = g_list_append(cm_cache_list, cc); color_man_cache_ref(cc); } return cc; }
void DS18B20_init(){ #ifdef DEBUG_DS18B20_POLLER DEBUG_1("Starting"); #endif ds_sensors.begin(); ds_count = ds_sensors.getDeviceCount(); #ifdef DEBUG_DS18B20_POLLER DEBUG_1("Finished"); #endif }
void flush_ethernet_logger(){ #ifdef DEBUG_ETHERNET_LOGGER DEBUG_1("Starting"); #endif // Nothing needs to be done. #ifdef DEBUG_ETHERNET_LOGGER DEBUG_1("Finishing"); #endif }
void ITG3200_init(){ #ifdef DEBUG_ITG3200_POLLER DEBUG_1("Starting"); #endif Wire.begin(); delay(1000); itg.init(ITG3200_ADDR_AD0_HIGH); #ifdef DEBUG_ITG3200_POLLER DEBUG_1("Finished"); #endif }
/** * Queries the mode and pid, and checks for given length */ bool query(int mode, int pid, int expectedLength) { DEBUG("query()"); //Flush invalid and echoed data flush(); //Reset rxPos rxPos = 0; //Send query if (mode < 16) serial->print("0"); serial->print(mode, HEX); if (pid < 16) serial->print("0"); serial->print(pid, HEX); serial->print( F("\r") ); //Loop until either expected size or timeout reached int len = fillBuffer(cbuf, 5000); //Evaluate buffer if (len > 0) { //Buffer filled, parse it int dataLen = parse(cbuf, len); DEBUG_1("dataLen == "); DEBUG_1(dataLen); DEBUG_NL(); //Check received bytes if (dataLen == expectedLength) { //size match DEBUG("query() size match"); return true; } else if (dataLen > expectedLength) { //oversized DEBUG("query() oversized"); return false; } } else return false; }
/* Run a command like system() but may output debug messages. */ int runcmd(gchar *cmd) { #if 1 return system(cmd); return 0; #else /* For debugging purposes */ int retval = -1; FILE *in; DEBUG_1("Running command: %s", cmd); in = popen(cmd, "r"); if (in) { int status; const gchar *msg; gchar buf[2048]; while (fgets(buf, sizeof(buf), in) != NULL ) { DEBUG_1("Output: %s", buf); } status = pclose(in); if (WIFEXITED(status)) { msg = "Command terminated with exit code"; retval = WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { msg = "Command was killed by signal"; retval = WTERMSIG(status); } else { msg = "pclose() returned"; retval = status; } DEBUG_1("%s : %d\n", msg, retval); } return retval; #endif }
/** * Flushes all incoming data */ void flush() { DEBUG("Flush()"); while (serial->available() > 0) { char c = serial->read(); DEBUG_HEX(c); if (c != '\n' && c != '\r') { DEBUG_1(","); DEBUG_1(c); } DEBUG_1(":"); } DEBUG_NL(); }
static gboolean format_raw_parse(FormatRawEntry *entry, guchar *data, const guint len, guint *image_offset, guint *exif_offset) { guint io = 0; guint eo = 0; gboolean found; if (!entry || !entry->func_parse) return FALSE; DEBUG_1("RAW using file parser for %s", entry->description); found = entry->func_parse(data, len, &io, &eo); if (!found || io >= len - 4 || eo >= len) { return FALSE; } if (image_offset) *image_offset = io; if (exif_offset) *exif_offset = eo; return TRUE; }
static gint cache_manager_standard_clean_clear_cb(gpointer data) { CleanData *cd = data; if (cd->list) { FileData *next_fd; next_fd = cd->list->data; cd->list = g_list_remove(cd->list, next_fd); DEBUG_1("thumb removed: %s", next_fd->path); unlink_file(next_fd->path); file_data_unref(next_fd); cd->count_done++; if (cd->count_total != 0) { gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress), (gdouble)cd->count_done / cd->count_total); } return TRUE; } cd->idle_id = 0; cache_manager_standard_clean_done(cd); return FALSE; }
static void collection_notify_cb(FileData *fd, NotifyType type, gpointer data) { CollectionData *cd = data; if (!(type & NOTIFY_CHANGE) || !fd->change) return; DEBUG_1("Notify collection: %s %04x", fd->path, type); switch (fd->change->type) { case FILEDATA_CHANGE_MOVE: case FILEDATA_CHANGE_RENAME: collection_rename(cd, fd); break; case FILEDATA_CHANGE_COPY: break; case FILEDATA_CHANGE_DELETE: while (collection_remove(cd, fd)); break; case FILEDATA_CHANGE_UNSPECIFIED: case FILEDATA_CHANGE_WRITE_METADATA: break; } }
void collect_manager_flush(void) { collect_manager_timer_push(TRUE); DEBUG_1("collection manager flushing"); while (collect_manager_process_cb(NULL)); }
static void cache_file_remove(const gchar *path) { if (path && isfile(path) && !unlink_file(path)) { DEBUG_1("Failed to remove cache file %s", path); } }
static void cache_maint_copied(FileData *fd) { gchar *dest_base; gchar *src_cache; mode_t mode = 0755; src_cache = cache_find_location(CACHE_TYPE_METADATA, fd->change->source); if (!src_cache) return; dest_base = cache_get_location(CACHE_TYPE_METADATA, fd->change->dest, FALSE, &mode); if (recursive_mkdir_if_not_exists(dest_base, mode)) { gchar *path; path = cache_get_location(CACHE_TYPE_METADATA, fd->change->dest, TRUE, NULL); if (!copy_file(src_cache, path)) { DEBUG_1("failed to copy metadata %s to %s", src_cache, path); } g_free(path); } g_free(dest_base); g_free(src_cache); }
static void collect_manager_process_actions(gint max) { if (collection_manager_action_list) DEBUG_1("collection manager processing actions"); while (collection_manager_action_list != NULL && max > 0) { CollectManagerAction *action; GList *work; action = collection_manager_action_list->data; work = collection_manager_entry_list; while (work) { CollectManagerEntry *entry; entry = work->data; work = work->next; if (action->type == COLLECTION_MANAGER_UPDATE) { collect_manager_entry_add_action(entry, action); } else if (action->oldpath && action->newpath && strcmp(action->newpath, entry->path) == 0) { /* convert action to standard add format */ g_free(action->newpath); if (action->type == COLLECTION_MANAGER_ADD) { action->newpath = action->oldpath; action->oldpath = NULL; } else if (action->type == COLLECTION_MANAGER_REMOVE) { action->newpath = NULL; } collect_manager_entry_add_action(entry, action); } max--; } if (action->type != COLLECTION_MANAGER_UPDATE && action->oldpath && action->newpath) { log_printf("collection manager failed to %s %s for collection %s\n", (action->type == COLLECTION_MANAGER_ADD) ? "add" : "remove", action->oldpath, action->newpath); } if (collection_manager_action_tail == collection_manager_action_list) { collection_manager_action_tail = NULL; } collection_manager_action_list = g_list_remove(collection_manager_action_list, action); collect_manager_action_unref(action); } }
static void bar_pane_keywords_notify_cb(FileData *fd, NotifyType type, gpointer data) { PaneKeywordsData *pkd = data; if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pkd->fd) { DEBUG_1("Notify pane_keywords: %s %04x", fd->path, type); bar_pane_keywords_update(pkd); } }
static void bar_pane_exif_notify_cb(FileData *fd, NotifyType type, gpointer data) { PaneExifData *ped = data; if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == ped->fd) { DEBUG_1("Notify pane_exif: %s %04x", fd->path, type); bar_pane_exif_update(ped); } }
static gboolean collect_manager_timer_cb(gpointer data) { DEBUG_1("collection manager timer expired"); g_idle_add_full(G_PRIORITY_LOW, collect_manager_process_cb, NULL, NULL); collection_manager_timer_id = 0; return FALSE; }
void histogram_notify_cb(FileData *fd, NotifyType type, gpointer data) { if ((type & NOTIFY_REREAD) && fd->histmap) { DEBUG_1("Notify histogram: %s %04x", fd->path, type); histmap_free(fd->histmap); fd->histmap = NULL; } }
static void bar_pane_comment_notify_cb(FileData *fd, NotifyType type, gpointer data) { PaneCommentData *pcd = data; if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pcd->fd) { DEBUG_1("Notify pane_comment: %s %04x", fd->path, type); bar_pane_comment_update(pcd); } }
gboolean load_options(ConfOptions *options) { gboolean success; gchar *rc_path; if (isdir(GQ_SYSTEM_WIDE_DIR)) { rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL); success = load_config_from_file(rc_path, TRUE); DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed"); g_free(rc_path); } rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL); success = load_config_from_file(rc_path, TRUE); DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed"); g_free(rc_path); return(success); }
static void options_parse_global_end(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, gpointer data, GError **error) { #ifndef HAVE_EXIV2 /* some options do not work without exiv2 */ options->metadata.save_in_image_file = FALSE; options->metadata.save_legacy_format = TRUE; options->metadata.write_orientation = FALSE; DEBUG_1("compiled without Exiv2 - disabling XMP write support"); #endif }
void log_ethernet_logger(const char * name, const char * value, const char * unit){ #ifdef DEBUG_ETHERNET_LOGGER DEBUG_1("Starting"); #endif #ifdef ETHERNET_ENABLE_SERVER eth_server.print(millis(),DEC); eth_server.write(","); eth_server.write(name); eth_server.write(","); eth_server.write(value); eth_server.write(","); eth_server.write(unit); eth_server.println(","); #endif #ifdef ETHERNET_ENABLE_MQTT if (!mqtt_client.connected()){ #ifdef ETHERNET_MQTT_USER mqtt_client.connect(ETHERNET_MQTT_CLIENT, ETHERNET_MQTT_USER, "ETHERNET_MQTT_PASS"); #else mqtt_client.connect(ETHERNET_MQTT_CLIENT); #endif if (!mqtt_client.connected()){ return; } } char *nbuf; char *vbuf; int len; nbuf=(char*)malloc(sizeof(char)*(strlen(name)+1)); vbuf=(char*)malloc(sizeof(char)*(strlen(name)+1)); strcpy(nbuf, name); strcpy(vbuf,value); mqtt_client.publish(nbuf, vbuf); free(nbuf); free(vbuf); #endif #ifdef DEBUG_ETHERNET_LOGGER DEBUG_1("Finishing"); #endif }
void ITG3200_sample(){ #ifdef DEBUG_ITG3200_POLLER DEBUG_1("Starting"); #endif float x,y,z; if (itg.isRawDataReady()){ itg.readGyro(&x,&y,&z); logMessage("Gyro.ITG3200.X",x, "Degrees*1000/Second"); logMessage("Gyro.ITG3200.Y",y, "Degrees*1000/Second"); logMessage("Gyro.ITG3200.Z",z, "Degrees*1000/Second"); } #ifdef DEBUG_ITG3200_POLLER DEBUG_1("Finished"); #endif }
void collection_unref(CollectionData *cd) { cd->ref--; DEBUG_1("collection \"%s\" ref count = %d", cd->name, cd->ref); if (cd->ref < 1) { collection_free(cd); } }
static gboolean collect_manager_process_cb(gpointer data) { if (collection_manager_action_list) collect_manager_refresh(); collect_manager_process_actions(COLLECT_MANAGER_ACTIONS_PER_IDLE); if (collection_manager_action_list) return TRUE; if (collect_manager_process_entry_list()) return TRUE; DEBUG_1("collection manager is up to date"); return FALSE; }
static void cache_file_move(const gchar *src, const gchar *dest) { if (!dest || !src || !isfile(src)) return; if (!move_file(src, dest)) { DEBUG_1("Failed to move cache file \"%s\" to \"%s\"", src, dest); /* we remove it anyway - it's stale */ unlink_file(src); } }