Exemplo n.º 1
0
static void addSerializedBinary(DFBuffer *result, DFBuffer *data, const char *filename)
{
    if (data != NULL) {
        char *str = binaryToString(data);
        DFBufferFormat(result,"#item %s\n",filename);
        DFBufferFormat(result,"%s",str);
        free(str);
    }
}
Exemplo n.º 2
0
int btosFile(const char *inFilename, const char *outFilename, DFError **error)
{
    DFBuffer *data = readData(inFilename,error);
    if (data == NULL)
        return 0;
    char *str = binaryToString(data);
    int ok = writeString(str,outFilename,error);
    free(str);
    DFBufferRelease(data);
    return ok;
}
Exemplo n.º 3
0
static int convertSimIoFcp(RIL_SIM_IO_Response *sr, char **cvt)
{
    int err;
    /* size_t pos; */
    size_t fcplen;
    struct ts_51011_921_resp resp;
    void *cvt_buf = NULL;

    if (!sr->simResponse || !cvt) {
        err = -EINVAL;
        goto error;
    }

    fcplen = strlen(sr->simResponse);
    if ((fcplen == 0) || (fcplen & 1)) {
        err = -EINVAL;
        goto error;
    }

    err = fcp_to_ts_51011(sr->simResponse, fcplen, &resp);
    if (err < 0)
        goto error;

    cvt_buf = malloc(sizeof(resp) * 2 + 1);
    if (!cvt_buf) {
        err = -ENOMEM;
        goto error;
    }

    err = binaryToString((unsigned char*)(&resp),
                   sizeof(resp), cvt_buf);
    if (err < 0)
        goto error;

    /* cvt_buf ownership is moved to the caller */
    *cvt = cvt_buf;
    cvt_buf = NULL;

finally:
    return err;

error:
    free(cvt_buf);
    goto finally;
}