Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • anders_blomdell/labcomm
  • klaren/labcomm
  • tommyo/labcomm
  • erikj/labcomm
  • sven/labcomm
5 results
Select Git revision
Show changes
Showing
with 1613 additions and 71 deletions
......@@ -93,6 +93,25 @@ struct labcomm2014_memory {
void *context;
};
/*
* sample_ref/signature helpers
*/
static const inline
struct labcomm2014_signature *labcomm2014_sample_ref_to_signature(
const struct labcomm2014_sample_ref *sample_ref
)
{
return (struct labcomm2014_signature *)sample_ref;
}
static const inline
struct labcomm2014_sample_ref *labcomm2014_signature_to_sample_ref(
const struct labcomm2014_signature *signature
)
{
return (struct labcomm2014_sample_ref *)signature;
}
/*
* Semi private decoder declarations
*/
......@@ -185,23 +204,38 @@ int labcomm2014_reader_ioctl(struct labcomm2014_reader *r,
const struct labcomm2014_signature *signature,
uint32_t ioctl_action, va_list args);
struct labcomm2014_decoder {
void *context;
struct labcomm2014_reader *reader;
struct labcomm2014_error_handler *error;
struct labcomm2014_memory *memory;
struct labcomm2014_scheduler *scheduler;
int reader_allocated;
int version_ok;
labcomm2014_error_handler_callback on_error;
labcomm2014_handle_new_datatype_callback on_new_datatype;
void (*free)(struct labcomm2014_decoder *d);
int (*decode_one)(struct labcomm2014_decoder *d);
int (*ref_register)(struct labcomm2014_decoder *d,
const struct labcomm2014_signature *s);
/*
* Non typesafe registration function to be called from
* generated labcomm2014_decoder_register_* functions.
*/
int labcomm2014_internal_decoder_register(
struct labcomm2014_decoder *d,
int (*sample_register)(struct labcomm2014_decoder *d,
const struct labcomm2014_signature *s,
labcomm2014_decoder_function decoder,
labcomm2014_handler_function handler,
void *context);
int labcomm2014_internal_decoder_ioctl(struct labcomm2014_decoder *decoder,
const struct labcomm2014_signature *signature,
int (*ioctl)(struct labcomm2014_decoder *d,
const struct labcomm2014_signature *s,
uint32_t ioctl_action, va_list args);
const struct labcomm2014_signature *labcomm2014_internal_decoder_index_to_signature(
const struct labcomm2014_sample_ref *(*index_to_sample_ref)(
struct labcomm2014_decoder *decoder, int index);
const struct labcomm2014_sample_ref *(*ref_get)(
struct labcomm2014_decoder *d,
const struct labcomm2014_signature *signature);
};
#if __BYTE_ORDER == __LITTLE_ENDIAN
......@@ -232,7 +266,7 @@ const struct labcomm2014_signature *labcomm2014_internal_decoder_index_to_signat
if (r->error < 0) { \
return 0; \
} \
} \
} > \
((unsigned char*)(&result))[i] = r->data[r->pos]; \
r->pos++; \
} \
......@@ -353,6 +387,38 @@ struct labcomm2014_writer {
int error;
};
struct labcomm2014_encoder {
void *context;
struct labcomm2014_writer *writer;
struct labcomm2014_error_handler *error;
struct labcomm2014_memory *memory;
struct labcomm2014_scheduler *scheduler;
void (*free)(struct labcomm2014_encoder *e);
int (*type_register)(struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature);
int (*type_bind)(struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature,
char has_deps);
int (*sample_register)(struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature,
labcomm2014_encoder_function encode);
int (*ref_register)(struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature);
int (*encode)(struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature,
labcomm2014_encoder_function encode,
void *value);
int (*ioctl)(struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature,
uint32_t ioctl_action, va_list args);
int (*sample_ref_to_index)(struct labcomm2014_encoder *e,
const struct labcomm2014_sample_ref *s);
const struct labcomm2014_sample_ref *(*ref_get)(
struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature);
};
int labcomm2014_writer_alloc(struct labcomm2014_writer *w,
struct labcomm2014_writer_action_context *action_context);
int labcomm2014_writer_free(struct labcomm2014_writer *w,
......@@ -370,33 +436,6 @@ int labcomm2014_writer_ioctl(struct labcomm2014_writer *w,
int index, const struct labcomm2014_signature *signature,
uint32_t ioctl_action, va_list args);
int labcomm2014_internal_encoder_type_register(
struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature);
int labcomm2014_internal_encoder_type_bind(
struct labcomm2014_encoder *e,
const struct labcomm2014_signature *signature,
char has_deps);
int labcomm2014_internal_encoder_register(
struct labcomm2014_encoder *encoder,
const struct labcomm2014_signature *signature,
labcomm2014_encoder_function encode);
int labcomm2014_internal_encode(
struct labcomm2014_encoder *encoder,
const struct labcomm2014_signature *signature,
labcomm2014_encoder_function encode,
void *value);
int labcomm2014_internal_encoder_ioctl(struct labcomm2014_encoder *encoder,
const struct labcomm2014_signature *signature,
uint32_t ioctl_action, va_list args);
int labcomm2014_internal_encoder_signature_to_index(
struct labcomm2014_encoder *encoder, const struct labcomm2014_signature *signature);
int labcomm2014_internal_sizeof(const struct labcomm2014_signature *signature,
void *v);
......
/*
labcomm2014_renaming.c -- functions intended for renaming
encoders and decoders
Copyright 2015 Anders Blomdell <anders.blomdell@control.lth.se>
This file is part of LabComm.
LabComm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LabComm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "labcomm2014_renaming.h"
#include <string.h>
char *labcomm2014_renaming_prefix(struct labcomm2014_memory *m,
char *name, void *context)
{
char *result, *prefix = context;
int length;
length = strlen(name) + strlen(prefix) + 1;
result = labcomm2014_memory_alloc(m, 0, length);
if (result != NULL) {
strcpy(result, prefix);
strcat(result, name);
}
return result;
}
char *labcomm2014_renaming_suffix(struct labcomm2014_memory *m,
char *name, void *context)
{
return labcomm2014_renaming_prefix(m, context, name);
}
This diff is collapsed.
This diff is collapsed.
/*
labcomm2014_renaming_decoder.h -- a stacked decoder that renames samples
Copyright 2015 Anders Blomdell <anders.blomdell@control.lth.se>
This file is part of LabComm.
LabComm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LabComm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LABCOMM2014_RENAMING_DECODER_H__
#define __LABCOMM2014_RENAMING_DECODER_H__
#include "labcomm2014.h"
#include "labcomm2014_renaming.h"
struct labcomm2014_decoder *labcomm2014_renaming_decoder_new(
struct labcomm2014_decoder *d,
struct labcomm2014_renaming_registry *r,
char *(*rename)(struct labcomm2014_memory *m, char *name, void *context),
void *context);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.