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 }
static void end_element(GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) { GQParserData *parser_data = user_data; GQParserFuncData *func = parser_data->parse_func_stack->data; DEBUG_2("end %s", element_name); if (func->end_func) func->end_func(parser_data, context, element_name, func->data, error); options_parse_func_pop(parser_data); }
static void start_element(GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error) { GQParserData *parser_data = user_data; GQParserFuncData *func = parser_data->parse_func_stack->data; DEBUG_2("start %s", element_name); if (func->start_func) func->start_func(parser_data, context, element_name, attribute_names, attribute_values, func->data, error); }
EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, gboolean consider_sidecars, gchar **output) { EditorFlags flags = 0; const gchar *p; GString *result = NULL; gboolean escape = FALSE; gboolean single_quotes = FALSE; gboolean double_quotes = FALSE; DEBUG_2("editor_command_parse: %s %d %d", editor->key, consider_sidecars, !!output); if (output) result = g_string_new(""); if (editor->exec == NULL || editor->exec[0] == '\0') { flags |= EDITOR_ERROR_EMPTY; goto err; } p = editor->exec; /* skip leading whitespaces if any */ while (g_ascii_isspace(*p)) p++; /* command */ while (*p) { if (escape) { escape = FALSE; if (output) result = g_string_append_c(result, *p); } else if (*p == '\\') { if (!single_quotes) escape = TRUE; if (output) result = g_string_append_c(result, *p); } else if (*p == '\'') { if (output) result = g_string_append_c(result, *p); if (!single_quotes && !double_quotes) single_quotes = TRUE; else if (single_quotes) single_quotes = FALSE; } else if (*p == '"') { if (output) result = g_string_append_c(result, *p); if (!single_quotes && !double_quotes) double_quotes = TRUE; else if (double_quotes) double_quotes = FALSE; } else if (*p == '%' && p[1]) { gchar *pathl = NULL; p++; switch (*p) { case 'f': /* single file */ case 'u': /* single url */ flags |= EDITOR_FOR_EACH; if (flags & EDITOR_SINGLE_COMMAND) { flags |= EDITOR_ERROR_INCOMPATIBLE; goto err; } if (list) { /* use the first file from the list */ if (!list->data) { flags |= EDITOR_ERROR_NO_FILE; goto err; } pathl = editor_command_path_parse((FileData *)list->data, consider_sidecars, (*p == 'f') ? PATH_FILE : PATH_FILE_URL, editor); if (!output) { /* just testing, check also the rest of the list (like with F and U) any matching file is OK */ GList *work = list->next; while (!pathl && work) { FileData *fd = work->data; pathl = editor_command_path_parse(fd, consider_sidecars, (*p == 'f') ? PATH_FILE : PATH_FILE_URL, editor); work = work->next; } } if (!pathl) { flags |= EDITOR_ERROR_NO_FILE; goto err; } if (output) { result = append_quoted(result, pathl, single_quotes, double_quotes); } g_free(pathl); } break; case 'F': case 'U': flags |= EDITOR_SINGLE_COMMAND; if (flags & (EDITOR_FOR_EACH | EDITOR_DEST)) { flags |= EDITOR_ERROR_INCOMPATIBLE; goto err; } if (list) { /* use whole list */ GList *work = list; gboolean ok = FALSE; while (work) { FileData *fd = work->data; pathl = editor_command_path_parse(fd, consider_sidecars, (*p == 'F') ? PATH_FILE : PATH_FILE_URL, editor); if (pathl) { ok = TRUE; if (output) { ok = TRUE; if (work != list) g_string_append_c(result, ' '); result = append_quoted(result, pathl, single_quotes, double_quotes); } g_free(pathl); } work = work->next; } if (!ok) { flags |= EDITOR_ERROR_NO_FILE; goto err; } } break; case 'i': if (editor->icon && *editor->icon) { if (output) { result = g_string_append(result, "--icon "); result = append_quoted(result, editor->icon, single_quotes, double_quotes); } } break; case 'c': if (output) { result = append_quoted(result, editor->name, single_quotes, double_quotes); } break; case 'k': if (output) { result = append_quoted(result, editor->file, single_quotes, double_quotes); } break; case '%': /* %% = % escaping */ if (output) result = g_string_append_c(result, *p); break; case 'd': case 'D': case 'n': case 'N': case 'v': case 'm': /* deprecated according to spec, ignore */ break; default: flags |= EDITOR_ERROR_SYNTAX; goto err; } } else { if (output) result = g_string_append_c(result, *p); } p++; } if (!(flags & (EDITOR_FOR_EACH | EDITOR_SINGLE_COMMAND))) flags |= EDITOR_NO_PARAM; if (output) { *output = g_string_free(result, FALSE); DEBUG_3("Editor cmd: %s", *output); } return flags; err: if (output) { g_string_free(result, TRUE); *output = NULL; } return flags; }
static gchar *editor_command_path_parse(const FileData *fd, gboolean consider_sidecars, PathType type, const EditorDescription *editor) { GString *string; gchar *pathl; const gchar *p = NULL; DEBUG_2("editor_command_path_parse: %s %d %d %s", fd->path, consider_sidecars, type, editor->key); string = g_string_new(""); if (type == PATH_FILE || type == PATH_FILE_URL) { GList *work = editor->ext_list; if (!work) p = fd->path; else { while (work) { GList *work2; gchar *ext = work->data; work = work->next; if (strcmp(ext, "*") == 0 || g_ascii_strcasecmp(ext, fd->extension) == 0) { p = fd->path; break; } work2 = consider_sidecars ? fd->sidecar_files : NULL; while (work2) { FileData *sfd = work2->data; work2 = work2->next; if (g_ascii_strcasecmp(ext, sfd->extension) == 0) { p = sfd->path; break; } } if (p) break; } if (!p) return NULL; } } else if (type == PATH_DEST) { if (fd->change && fd->change->dest) p = fd->change->dest; else p = ""; } g_assert(p); string = g_string_append(string, p); if (type == PATH_FILE_URL) g_string_prepend(string, "file://"); pathl = path_from_utf8(string->str); g_string_free(string, TRUE); if (pathl && !pathl[0]) /* empty string case */ { g_free(pathl); pathl = NULL; } DEBUG_2("editor_command_path_parse: return %s", pathl); return pathl; }