Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdlib.h>
00022 #include <string.h>
00023 #include <glib.h>
00024 #include "sigrok.h"
00025 #include "sigrok-internal.h"
00026
00027 static int data(struct sr_output *o, const uint8_t *data_in,
00028 uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
00029 {
00030 uint8_t *outbuf;
00031
00032
00033 (void)o;
00034
00035 if (!data_in) {
00036 sr_err("binary out: %s: data_in was NULL", __func__);
00037 return SR_ERR_ARG;
00038 }
00039
00040 if (!length_out) {
00041 sr_err("binary out: %s: length_out was NULL", __func__);
00042 return SR_ERR_ARG;
00043 }
00044
00045 if (length_in == 0) {
00046 sr_err("binary out: %s: length_in was 0", __func__);
00047 return SR_ERR_ARG;
00048 }
00049
00050 if (!(outbuf = g_try_malloc0(length_in))) {
00051 sr_err("binary out: %s: outbuf malloc failed", __func__);
00052 return SR_ERR_MALLOC;
00053 }
00054
00055 memcpy(outbuf, data_in, length_in);
00056 *data_out = outbuf;
00057 *length_out = length_in;
00058
00059 return SR_OK;
00060 }
00061
00062 SR_PRIV struct sr_output_format output_binary = {
00063 .id = "binary",
00064 .description = "Raw binary",
00065 .df_type = SR_DF_LOGIC,
00066 .init = NULL,
00067 .data = data,
00068 .event = NULL,
00069 };