From f2b07bb85b2d28fd4e54df82658f00f4a621ece1 Mon Sep 17 00:00:00 2001 From: Lutz Mueller Date: Tue, 9 Jan 2001 22:48:03 +0000 Subject: [PATCH] extern "C" for c++ git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@1508 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/directory/directory.c | 60 ++--------------------------------- include/gphoto2.h | 10 +++++- libgphoto2/camera.c | 4 +++ 3 files changed, 16 insertions(+), 58 deletions(-) diff --git a/camlibs/directory/directory.c b/camlibs/directory/directory.c index d9dc3e971..e977728f7 100644 --- a/camlibs/directory/directory.c +++ b/camlibs/directory/directory.c @@ -87,8 +87,6 @@ int camera_init (Camera *camera) { camera->functions->file_get = camera_file_get; camera->functions->config_get = camera_config_get; camera->functions->config_set = camera_config_set; - camera->functions->file_put = camera_file_put; - camera->functions->file_delete = camera_file_delete; camera->functions->config = camera_config; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; @@ -269,17 +267,8 @@ int camera_config_set (Camera *camera, CameraWidget *window) { return (GP_OK); } -int camera_file_put (Camera *camera, CameraFile *file, char *folder) { - - return (GP_ERROR_NOT_SUPPORTED); -} - - -int camera_file_delete (Camera *camera, char *folder, char *filename) { - - return (GP_ERROR_NOT_SUPPORTED); -} - +/* DEPRECATED */ +/* This function is deprecated! Do not implement!*/ int camera_config (Camera *camera) { CameraWidget *window; @@ -294,50 +283,7 @@ int camera_config (Camera *camera) { camera_config_set (camera, window); return (GP_OK); -#if 0 - /* Example. shows when debugging is on */ -//FIXME: Syntax of gp_widget_value_get/set has changed! - - /* Create a new section for "Quality" */ - section = gp_widget_new(GP_WIDGET_SECTION, "Quality"); - gp_widget_append(window, section); - - /* Add the Resolution setting radio buttons */ - t = gp_widget_new(GP_WIDGET_RADIO, "Resolution"); - gp_widget_append(section, t); - gp_widget_choice_add(t, "Normal"); - gp_widget_choice_add(t, "High"); - gp_widget_choice_add(t, "Best"); - gp_widget_value_set(t, "High"); - - t = gp_widget_new(GP_WIDGET_TEXT, "Camera Name"); - gp_widget_append(section, t); - gp_widget_value_set(t, "hey there!"); - - t = gp_widget_new(GP_WIDGET_RANGE, "LCD Brightness"); - gp_widget_append(section, t); - gp_widget_range_set(t, 1.0, 7.0, 1.0); - gp_widget_value_set(t, "4.0"); - - /* Create a new section for "Flash/Lens" and append to window */ - section = gp_widget_new(GP_WIDGET_SECTION, "Flash/Lens"); - gp_widget_append(window, section); - - t = gp_widget_new(GP_WIDGET_MENU, "Flash Setting"); - gp_widget_append(section, t); - gp_widget_choice_add(t, "Auto"); - gp_widget_choice_add(t, "Red-eye"); - gp_widget_choice_add(t, "Force"); - gp_widget_choice_add(t, "None"); - gp_widget_value_set(t, "Red-eye"); - - t = gp_widget_new(GP_WIDGET_RADIO, "Lens Mode"); - gp_widget_append(section, t); - gp_widget_choice_add(t, "Normal"); - gp_widget_choice_add(t, "Macro"); - gp_widget_value_set(t, "Macro"); -#endif -} +} /* END DEPRECATED */ int camera_summary (Camera *camera, CameraText *summary) { diff --git a/include/gphoto2.h b/include/gphoto2.h index f6e2a08b4..a700a3584 100644 --- a/include/gphoto2.h +++ b/include/gphoto2.h @@ -6,7 +6,11 @@ */ #ifndef GPHOTO2_H -#define GPHOTO2_H +#define GPHOTO2_H 1 + +#ifdef __cplusplus +extern "C" { +#endif #ifdef OS2 #include @@ -30,4 +34,8 @@ #include #include +#ifdef __cplusplus +} +#endif + #endif diff --git a/libgphoto2/camera.c b/libgphoto2/camera.c index ab6bb49c0..39663159f 100644 --- a/libgphoto2/camera.c +++ b/libgphoto2/camera.c @@ -72,6 +72,8 @@ int gp_camera_new (Camera **camera, int camera_number) { int result; + if (camera == NULL) return (GP_ERROR_BAD_PARAMETERS); + if (camera_number >= glob_abilities_list->count) { gp_debug_printf(GP_DEBUG_LOW, "core", "camera_number too big"); return (GP_ERROR_MODEL_NOT_FOUND); @@ -91,6 +93,8 @@ int gp_camera_new (Camera **camera, int camera_number) (*camera)->frontend_data = NULL; (*camera)->session = glob_session_camera++; (*camera)->ref_count = 1; + if (!(*camera)->port || !(*camera)->abilities || !(*camera)->functions) + return (GP_ERROR_NO_MEMORY); /* Initialize function pointers to NULL.*/ (*camera)->functions->id = NULL;