char* dv_fmt(dvalue_t* val) { char* out; switch (val->t) { case INTEGER: out = malloc(20); snprintf(out, 20, "%lld", val->d.i); return out; case FLOAT: out = malloc(20); snprintf(out, 20, "%f", val->d.f); return out; case BOOL: if (val->d.b) { return strdup("true"); } else { return strdup("false"); } case STRING: return strdup(val->d.s); case SYMBOL: out = malloc(20); out[0] = ':'; strcpy(out + 1, symbol_decode(val->d.sym)); return out; case OP: return strdup(val->d.s); case LIST: return da_fmt(val->d.a); default: return strdup("Unknown value"); } }
static void handle_symbol(char *infile) { int img_count = 0; gchar *outfile = DMTX_SYMBOL_OUTPUT; gchar *data; gsize len; img_count = symbol_decode(infile, outfile); if (img_count == 1) { /* assuming successful decode */ printf( "Decoded dmtx symbol %s to file %s\n", infile, outfile); } else { printf("Failed to decode dmtx symbol\n"); return; } /* test file */ if (!g_file_test(outfile, G_FILE_TEST_IS_REGULAR)) { printf("No valid file found"); return; } /* parse xml file containing bdaddr */ if (g_file_get_contents(outfile, &data, &len, NULL) == FALSE) { printf("Couldn't load XML file %s\n", outfile); return; } /* Send symbol data to gdbus routines */ //dmtxplugin_gdbus_create_device(data); /* SSP version */ dmtxplugin_gdbus_create_paired_oob_device(data); g_free(data); }