#endif
#include "../config.h"
-
int debug = FALSE;
int statistics = FALSE;
};
-void logmsg(char *prefix, FILE *out, const char *format, va_list args)
+static void logmsg(char *prefix, FILE *out, const char *format, va_list args)
{
if (prefix)
fprintf(out, "%s", prefix);
fprintf(out, "\n");
}
-void DBG(const char *format, ...)
+static void DBG(const char *format, ...)
{
va_list args;
va_end(args);
}
-void ERR(const char *format, ...)
+static void ERR(const char *format, ...)
{
va_list args;
va_end(args);
}
-int sr_log(void *cb_data, int loglevel, const char *format, va_list args)
+static int sr_log(void *cb_data, int loglevel, const char *format, va_list args)
{
(void)cb_data;
return SRD_OK;
}
-int srd_log(void *cb_data, int loglevel, const char *format, va_list args)
+static int srd_log(void *cb_data, int loglevel, const char *format, va_list args)
{
(void)cb_data;
return SRD_OK;
}
-void usage(char *msg)
+static void usage(char *msg)
{
if (msg)
fprintf(stderr, "%s\n", msg);
/* This is a neutered version of libsigrokdecode's py_str_as_str(). It
* does no error checking, but then the only strings it processes are
* generated by Python's repr(), so are known good. */
-char *py_str_as_str(const PyObject *py_str)
+static char *py_str_as_str(const PyObject *py_str)
{
PyObject *py_encstr;
char *str, *outstr;
{
struct srd_proto_data_binary *pdb;
struct output *op;
+ GString *out;
+ unsigned int i;
DBG("Binary output from %s", pdata->pdo->di->inst_id);
op = cb_data;
*/
return;
- if (write(op->outfd, pdb->data, pdb->size) == -1)
+ out = g_string_sized_new(128);
+ g_string_printf(out, "%"PRIu64"-%"PRIu64" %s:",
+ pdata->start_sample, pdata->end_sample,
+ pdata->pdo->di->inst_id);
+ for (i = 0; i < pdb->size; i++) {
+ g_string_append_printf(out, " %.2x", pdb->data[i]);
+ }
+ g_string_append(out, "\n");
+ if (write(op->outfd, out->str, out->len) == -1)
ERR("SRD_OUTPUT_BINARY callback write failure!");
}
}
-int get_stats(int stats[2])
-{
- FILE *f;
- size_t len;
- int tmp;
- char *buf;
-
- stats[0] = stats[1] = -1;
- if (!(f = fopen("/proc/self/status", "r")))
- return FALSE;
- len = 128;
- buf = malloc(len);
- while (getline(&buf, &len, f) != -1) {
- if (strcasestr(buf, "vmpeak:")) {
- stats[0] = strtoul(buf + 10, NULL, 10);
- } else if (strcasestr(buf, "vmsize:")) {
- tmp = strtoul(buf + 10, NULL, 10);
- if (tmp > stats[0])
- stats[0] = tmp;
- } else if (strcasestr(buf, "vmhwm:")) {
- stats[1] = strtoul(buf + 6, NULL, 10);
- } else if (strcasestr(buf, "vmrss:")) {
- tmp = strtoul(buf + 10, NULL, 10);
- if (tmp > stats[0])
- stats[0] = tmp;
- }
- }
- free(buf);
- fclose(f);
-
- return TRUE;
-}
-
static int run_testcase(char *infile, GSList *pdlist, struct output *op)
{
struct srd_session *sess;
/* Only annotations and binary can have a class. */
return FALSE;
idx = 0;
- while(l) {
+ while (l) {
decoder_class = l->data;
if (!strcmp(decoder_class[0], op->class)) {
op->class_idx = idx;
pdlist = NULL;
opt_infile = NULL;
pd = NULL;
- while((c = getopt(argc, argv, "dP:p:o:i:O:f:S")) != -1) {
+ while ((c = getopt(argc, argv, "dP:p:o:i:O:f:S")) != -1) {
switch(c) {
case 'd':
debug = TRUE;
return ret;
}
-
-