diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-04-14 17:06:12 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-04-14 17:06:12 +0200 |
commit | a178ae6180e4844e89f6e040cbf040fed5f4df6a (patch) | |
tree | 016ec939606350b55f283a334e93c437ceb54aaa | |
parent | d7143e0f1ff45449f5e69adc1a42c72eddf642d8 (diff) | |
download | pcitool-a178ae6180e4844e89f6e040cbf040fed5f4df6a.tar.gz pcitool-a178ae6180e4844e89f6e040cbf040fed5f4df6a.tar.bz2 pcitool-a178ae6180e4844e89f6e040cbf040fed5f4df6a.tar.xz pcitool-a178ae6180e4844e89f6e040cbf040fed5f4df6a.zip |
Introduce pcilib_context_t type instead pointer to void
-rw-r--r-- | cli.c | 2 | ||||
-rw-r--r-- | ipecamera/image.c | 26 | ||||
-rw-r--r-- | ipecamera/image.h | 18 | ||||
-rw-r--r-- | pci.c | 2 | ||||
-rw-r--r-- | pcilib.h | 21 |
5 files changed, 35 insertions, 34 deletions
@@ -595,7 +595,7 @@ int Grab(pcilib_t *handle, const char *event, const char *output) { Error("Failed to open file \"%s\"", output); } - printf("Writting %i bytes into %s...\n", size, output); + printf("Writting %zu bytes into %s...\n", size, output); } else o = stdout; written = fwrite(data, 1, size, o); diff --git a/ipecamera/image.c b/ipecamera/image.c index 5d2021c..52adc86 100644 --- a/ipecamera/image.c +++ b/ipecamera/image.c @@ -102,7 +102,7 @@ struct ipecamera_s { } -void *ipecamera_init(pcilib_t *pcilib) { +pcilib_context_t *ipecamera_init(pcilib_t *pcilib) { int err = 0; ipecamera_t *ctx = malloc(sizeof(ipecamera_t)); @@ -139,10 +139,10 @@ void *ipecamera_init(pcilib_t *pcilib) { return (void*)ctx; } -void ipecamera_free(void *vctx) { +void ipecamera_free(pcilib_context_t *vctx) { if (vctx) { ipecamera_t *ctx = (ipecamera_t*)vctx; - ipecamera_stop(ctx); + ipecamera_stop(vctx); free(ctx); } } @@ -164,7 +164,7 @@ int ipecamera_set_buffer_size(ipecamera_t *ctx, int size) { } -int ipecamera_reset(void *vctx) { +int ipecamera_reset(pcilib_context_t *vctx) { int err; pcilib_t *pcilib; ipecamera_t *ctx = (ipecamera_t*)vctx; @@ -236,7 +236,7 @@ int ipecamera_reset(void *vctx) { return 0; } -int ipecamera_start(void *vctx, pcilib_event_t event_mask, pcilib_callback_t cb, void *user) { +int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_callback_t cb, void *user) { int err = 0; ipecamera_t *ctx = (ipecamera_t*)vctx; @@ -273,7 +273,7 @@ int ipecamera_start(void *vctx, pcilib_event_t event_mask, pcilib_callback_t cb, } if (err) { - ipecamera_stop(ctx); + ipecamera_stop(vctx); return err; } @@ -283,7 +283,7 @@ int ipecamera_start(void *vctx, pcilib_event_t event_mask, pcilib_callback_t cb, } -int ipecamera_stop(void *vctx) { +int ipecamera_stop(pcilib_context_t *vctx) { ipecamera_t *ctx = (ipecamera_t*)vctx; if (!ctx) { @@ -412,7 +412,7 @@ static int ipecamera_get_line(ipecamera_t *ctx, ipecamera_pixel_t *pbuf, ipecame sprintf(fname, "raw/line%04i", line); FILE *f = fopen(fname, "w"); if (f) { - fwrite(linebuf, 1, size, f); + (void)fwrite(linebuf, 1, size, f); fclose(f); } #endif @@ -449,7 +449,7 @@ static int ipecamera_get_line(ipecamera_t *ctx, ipecamera_pixel_t *pbuf, ipecame sprintf(fname, "raw/image"); f = fopen(fname, "a+"); if (f) { - fwrite(pbuf, 2, ctx->dim.width, f); + (void)fwrite(pbuf, 2, ctx->dim.width, f); fclose(f); } #endif @@ -491,7 +491,7 @@ static int ipecamera_get_image(ipecamera_t *ctx) { } -int ipecamera_trigger(void *vctx, pcilib_event_t event, size_t trigger_size, void *trigger_data) { +int ipecamera_trigger(pcilib_context_t *vctx, pcilib_event_t event, size_t trigger_size, void *trigger_data) { int err; pcilib_t *pcilib; ipecamera_t *ctx = (ipecamera_t*)vctx; @@ -532,7 +532,7 @@ static int ipecamera_resolve_event_id(ipecamera_t *ctx, pcilib_event_id_t evid) return buf_ptr; } -pcilib_event_id_t ipecamera_next_event(void *vctx, pcilib_event_t event_mask, const struct timespec *timeout) { +pcilib_event_id_t ipecamera_next_event(pcilib_context_t *vctx, pcilib_event_t event_mask, const struct timespec *timeout) { int buf_ptr; pcilib_event_id_t reported; ipecamera_t *ctx = (ipecamera_t*)vctx; @@ -567,7 +567,7 @@ pcilib_event_id_t ipecamera_next_event(void *vctx, pcilib_event_t event_mask, co return ctx->reported_id; } -void* ipecamera_get(void *vctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size) { +void* ipecamera_get(pcilib_context_t *vctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size) { int buf_ptr; ipecamera_t *ctx = (ipecamera_t*)vctx; @@ -608,7 +608,7 @@ void* ipecamera_get(void *vctx, pcilib_event_id_t event_id, pcilib_event_data_ty -int ipecamera_return(void *vctx, pcilib_event_id_t event_id) { +int ipecamera_return(pcilib_context_t *vctx, pcilib_event_id_t event_id) { ipecamera_t *ctx = (ipecamera_t*)vctx; if (!ctx) { diff --git a/ipecamera/image.h b/ipecamera/image.h index 245e450..0418be4 100644 --- a/ipecamera/image.h +++ b/ipecamera/image.h @@ -6,17 +6,17 @@ #include "ipecamera.h" #include "pcilib.h" -void *ipecamera_init(pcilib_t *pcilib); -void ipecamera_free(void *ctx); +pcilib_context_t *ipecamera_init(pcilib_t *pcilib); +void ipecamera_free(pcilib_context_t *ctx); -int ipecamera_reset(void *ctx); -int ipecamera_start(void *ctx, pcilib_event_t event_mask, pcilib_callback_t cb, void *user); -int ipecamera_stop(void *ctx); -int ipecamera_trigger(void *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data); -pcilib_event_id_t ipecamera_next_event(void *ctx, pcilib_event_t event_mask, const struct timespec *timeout); +int ipecamera_reset(pcilib_context_t *ctx); +int ipecamera_start(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_callback_t cb, void *user); +int ipecamera_stop(pcilib_context_t *ctx); +int ipecamera_trigger(pcilib_context_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data); +pcilib_event_id_t ipecamera_next_event(pcilib_context_t *ctx, pcilib_event_t event_mask, const struct timespec *timeout); -void* ipecamera_get(void *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size); -int ipecamera_return(void *ctx, pcilib_event_id_t event_id); +void* ipecamera_get(pcilib_context_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size); +int ipecamera_return(pcilib_context_t *ctx, pcilib_event_id_t event_id); @@ -98,7 +98,7 @@ const pci_board_info *pcilib_get_board_info(pcilib_t *ctx) { return &ctx->board_info; } -void *pcilib_get_implementation_context(pcilib_t *ctx) { +pcilib_context_t *pcilib_get_implementation_context(pcilib_t *ctx) { return ctx->event_ctx; } @@ -17,6 +17,7 @@ struct timespec { #define pcilib_datacpy pcilib_datacpy32 typedef struct pcilib_s pcilib_t; +typedef void pcilib_context_t; typedef uint8_t pcilib_bar_t; /**< Type holding the PCI Bar number */ typedef uint8_t pcilib_register_t; /**< Type holding the register ID within the Bank */ @@ -125,18 +126,18 @@ typedef struct { typedef int (*pcilib_callback_t)(pcilib_event_t event, pcilib_event_id_t event_id, void *user); typedef struct { - void *(*init)(pcilib_t *ctx); - void (*free)(void *ctx); + pcilib_context_t *(*init)(pcilib_t *ctx); + void (*free)(pcilib_context_t *ctx); - int (*reset)(void *ctx); + int (*reset)(pcilib_context_t *ctx); - int (*start)(void *ctx, pcilib_event_t event_mask, pcilib_callback_t callback, void *user); - int (*stop)(void *ctx); - int (*trigger)(void *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data); + int (*start)(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_callback_t callback, void *user); + int (*stop)(pcilib_context_t *ctx); + int (*trigger)(pcilib_context_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data); - pcilib_event_id_t (*next_event)(void *ctx, pcilib_event_t event_mask, const struct timespec *timeout); - void* (*get_data)(void *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size); - int (*return_data)(void *ctx, pcilib_event_id_t event_id); + pcilib_event_id_t (*next_event)(pcilib_context_t *ctx, pcilib_event_t event_mask, const struct timespec *timeout); + void* (*get_data)(pcilib_context_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size); + int (*return_data)(pcilib_context_t *ctx, pcilib_event_id_t event_id); } pcilib_event_api_description_t; typedef struct { @@ -158,7 +159,7 @@ extern pcilib_model_description_t pcilib_model[]; int pcilib_set_error_handler(void (*err)(const char *msg, ...), void (*warn)(const char *msg, ...)); pcilib_model_t pcilib_get_model(pcilib_t *ctx); -void *pcilib_get_implementation_context(pcilib_t *ctx); +pcilib_context_t *pcilib_get_implementation_context(pcilib_t *ctx); pcilib_t *pcilib_open(const char *device, pcilib_model_t model); void pcilib_close(pcilib_t *ctx); |