extern int blkid_probe_chain_copy_vals(blkid_probe pr, struct blkid_chain *chn,
struct blkid_prval *vals, int nvals);
extern struct blkid_prval *blkid_probe_assign_value(blkid_probe pr, const char *name);
+extern int blkid_probe_reset_last_value(blkid_probe pr);
extern void blkid_probe_append_vals(blkid_probe pr, struct blkid_prval *vals, int nvals);
extern struct blkid_chain *blkid_probe_get_chain(blkid_probe pr);
return v;
}
+int blkid_probe_reset_last_value(blkid_probe pr)
+{
+ struct blkid_prval *v;
+
+ if (pr == NULL || pr->nvals == 0)
+ return -1;
+
+ v = &pr->vals[pr->nvals - 1];
+
+ DBG(DEBUG_LOWPROBE,
+ printf("un-assigning %s [%s]\n", v->name, v->chain->driver->name));
+
+ memset(v, 0, sizeof(struct blkid_prval));
+ pr->nvals--;
+
+ return 0;
+
+}
+
int blkid_probe_set_value(blkid_probe pr, const char *name,
unsigned char *data, size_t len)
{
len = vsnprintf((char *) v->data, sizeof(v->data), fmt, ap);
if (len <= 0) {
- pr->nvals--; /* reset the latest assigned value */
+ blkid_probe_reset_last_value(pr);
return -1;
}
v->len = len + 1;
v->data[len] = '\0';
v->len = blkid_rtrim_whitespace(v->data) + 1;
+ if (v->len == 1)
+ blkid_probe_reset_last_value(pr);
return 0;
}
blkid_encode_to_utf8(enc, v->data, sizeof(v->data), label, len);
v->len = blkid_rtrim_whitespace(v->data) + 1;
+ if (v->len == 1)
+ blkid_probe_reset_last_value(pr);
return 0;
}