summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--doc/api/gphoto2-api.sgml2
-rw-r--r--doc/api/gphoto2-sections.txt25
-rw-r--r--doc/api/tmpl/gphoto2-unused.sgml17
-rw-r--r--doc/api/tmpl/libgphoto2.sgml17
-rw-r--r--doc/api/tmpl/widget.sgml289
-rw-r--r--include/Makefile.am1
-rw-r--r--libgphoto2/Makefile.am3
-rw-r--r--libgphoto2/camera.c10
-rw-r--r--libgphoto2/gphoto2-abilities-list.c6
-rw-r--r--libgphoto2/gphoto2-abilities-list.h1
-rw-r--r--libgphoto2/gphoto2-filesys.c8
-rw-r--r--libgphoto2/gphoto2-list.c (renamed from libgphoto2/list.c)142
-rw-r--r--libgphoto2/gphoto2-list.h (renamed from include/gphoto2-list.h)9
14 files changed, 188 insertions, 355 deletions
diff --git a/ChangeLog b/ChangeLog
index aa6fbf133..4586ae5b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2001-10-14 Lutz Müller <urc8@rz.uni-karlsruhe.de>
+
+ * libgphoto2/gphoto2-list.[c,h]: Documented.
+
2001-10-13 Lutz Müller <urc8@rz.uni-karlsruhe.de>
* libgphoto2/gphoto2-abilities-list.[c,h]: Simplified, expose fewer
@@ -5,9 +9,12 @@
2001-10-12 Hans Ulrich Niedermann <gp@n-dimensional.de>
- * libgphoto2_port/libgphoto2_port/gp_port.c: more detailed debug output for *_write and *_read
- * libgphoto2_port/usb/libusb.c: removed the last fprintf, fixed missing "%s" in string
- * libgphoto2_port/usb/libusb.c: added call notification at GP_DEBUG_HIGH for most methods
+ * libgphoto2_port/libgphoto2_port/gp_port.c: more detailed debug
+ output for *_write and *_read
+ * libgphoto2_port/usb/libusb.c: removed the last fprintf, fixed
+ missing "%s" in string
+ * libgphoto2_port/usb/libusb.c: added call notification at
+ GP_DEBUG_HIGH for most methods
2001-10-12 Hans Ulrich Niedermann <gp@n-dimensional.de>
diff --git a/doc/api/gphoto2-api.sgml b/doc/api/gphoto2-api.sgml
index 8adee7c74..402879634 100644
--- a/doc/api/gphoto2-api.sgml
+++ b/doc/api/gphoto2-api.sgml
@@ -5,6 +5,7 @@
<!entity gphoto2-core SYSTEM "sgml/gphoto2-core.sgml">
<!entity gphoto2-camera SYSTEM "sgml/gphoto2-camera.sgml">
<!entity gphoto2-setting SYSTEM "sgml/gphoto2-setting.sgml">
+<!entity gphoto2-list SYSTEM "sgml/gphoto2-list.sgml">
]>
<book id="index">
@@ -83,6 +84,7 @@ locking of serial ports. GPhoto2 currently supports
<sect1 id="GeneralPurposeObjects">
<title>Objects used by both frontends and camera drivers</title>
&gphoto2-widget;
+ &gphoto2-list;
</sect1>
</chapter>
diff --git a/doc/api/gphoto2-sections.txt b/doc/api/gphoto2-sections.txt
index 37fc931d4..046d91ec5 100644
--- a/doc/api/gphoto2-sections.txt
+++ b/doc/api/gphoto2-sections.txt
@@ -29,6 +29,31 @@ gp_widget_changed
</SECTION>
<SECTION>
+<FILE>gphoto2-list</FILE>
+<TITLE>CameraList</TITLE>
+CameraList
+
+gp_list_new
+gp_list_ref
+gp_list_unref
+gp_list_free
+
+gp_list_count
+
+gp_list_set_name
+gp_list_set_value
+
+gp_list_get_name
+gp_list_get_value
+
+gp_list_append
+gp_list_populate
+gp_list_reset
+gp_list_sort
+
+</SECTION>
+
+<SECTION>
<FILE>gphoto2-filesys</FILE>
<TITLE>CameraFilesystem</TITLE>
CameraFilesystem
diff --git a/doc/api/tmpl/gphoto2-unused.sgml b/doc/api/tmpl/gphoto2-unused.sgml
deleted file mode 100644
index 0f33399a9..000000000
--- a/doc/api/tmpl/gphoto2-unused.sgml
+++ /dev/null
@@ -1,17 +0,0 @@
-<!-- ##### SECTION ./tmpl/libgphoto2.sgml:See_Also ##### -->
-<para>
-</para>
-
-
-<!-- ##### SECTION ./tmpl/libgphoto2.sgml:Short_Description ##### -->
-Library for accessing digital cameras.
-
-
-<!-- ##### SECTION ./tmpl/libgphoto2.sgml:Long_Description ##### -->
-<para>
-<filename>libgphoto2</filename> is the library that provides access
-to a wide range of digital camera models. The library is GUI
-independent.
-</para>
-
-
diff --git a/doc/api/tmpl/libgphoto2.sgml b/doc/api/tmpl/libgphoto2.sgml
deleted file mode 100644
index af07f949e..000000000
--- a/doc/api/tmpl/libgphoto2.sgml
+++ /dev/null
@@ -1,17 +0,0 @@
-<!-- ##### SECTION Title #### -->
-libgphoto2
-
-<!-- ##### SECTION Short_Description ##### -->
-Library for accessing digital cameras.
-
-<!-- ##### SECTION Long_Description ##### -->
-<para>
-<filename>libgphoto2</filename> is the library that provides access
-to a wide range of digital camera models. The library is GUI
-independent.
-</para>
-
-<!-- ##### SECTION See_Also ##### -->
-<para>
-</para>
-
diff --git a/doc/api/tmpl/widget.sgml b/doc/api/tmpl/widget.sgml
deleted file mode 100644
index 45f445734..000000000
--- a/doc/api/tmpl/widget.sgml
+++ /dev/null
@@ -1,289 +0,0 @@
-<!-- ##### SECTION Title ##### -->
-gphoto-widget
-
-<!-- ##### SECTION Short_Description ##### -->
-Widgets for GUI-independent access to camera configuration options.
-
-<!-- ##### SECTION Long_Description ##### -->
-<para>
-A GPWidget is a mechanism to access camera configuration options
-without having to rely on a GUI. When a frontend requests a
-configuration dialog through gp_*_config_get, the camera driver will
-do something like
-</para>
-<para>
- <example>
- <title>Creating a GPWidget</title>
- <programlisting>
- *window = gp_widget_new (GP_WIDGET_WINDOW,
- _("Configuration for Model XY"));
- return (GP_OK);
- </programlisting>
- </example>
-</para>
-<para>
-The frontend now traverses this widget and builds the configuration
-dialog.
-</para>
-<para>
- <example>
- <title>Traversing a GPWidget</title>
- <programlisting>
- int i, count, result;
- GPWidgetType type;
-
- count = gp_widget_count_children (window);
- if (count < 0)
- return (count);
- for (i = 0; i < count; i++) {
- result = gp_widget_get_type (window, &type);
- if (result < 0)
- return (result);
- switch (type) {
- case GP_WIDGET_TYPE_WINDOW:
- break;
- default:
- break;
- }
- }
- </programlisting>
- </example>
-</para>
-
-<!-- ##### SECTION See_Also ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### FUNCTION gp_widget_new ##### -->
-<para>
-
-</para>
-
-@type:
-@label:
-@widget:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_free ##### -->
-<para>
-
-</para>
-
-@widget:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_ref ##### -->
-<para>
-
-</para>
-
-@widget:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_unref ##### -->
-<para>
-
-</para>
-
-@widget:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_append ##### -->
-<para>
-
-</para>
-
-@parent:
-@child:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_prepend ##### -->
-<para>
-
-</para>
-
-@parent:
-@child:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_count_children ##### -->
-<para>
-
-</para>
-
-@parent:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_child ##### -->
-<para>
-
-</para>
-
-@parent:
-@child_number:
-@child:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_child_by_label ##### -->
-<para>
-
-</para>
-
-@parent:
-@child_label:
-@child:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_child_by_id ##### -->
-<para>
-
-</para>
-
-@parent:
-@id:
-@child:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_root ##### -->
-<para>
-
-</para>
-
-@widget:
-@root:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_set_info ##### -->
-<para>
-
-</para>
-
-@widget:
-@info:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_info ##### -->
-<para>
-
-</para>
-
-@widget:
-@info:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_id ##### -->
-<para>
-
-</para>
-
-@widget:
-@id:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_type ##### -->
-<para>
-
-</para>
-
-@widget:
-@type:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_label ##### -->
-<para>
-
-</para>
-
-@widget:
-@label:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_set_value ##### -->
-<para>
-
-</para>
-
-@widget:
-@value:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_value ##### -->
-<para>
-
-</para>
-
-@widget:
-@value:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_range ##### -->
-<para>
-
-</para>
-
-@range:
-@low:
-@high:
-@increment:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_add_choice ##### -->
-<para>
-
-</para>
-
-@widget:
-@choice:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_count_choices ##### -->
-<para>
-
-</para>
-
-@widget:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_get_choice ##### -->
-<para>
-
-</para>
-
-@widget:
-@choice_number:
-@choice:
-@Returns:
-
-
-<!-- ##### FUNCTION gp_widget_changed ##### -->
-<para>
-
-</para>
-
-@widget:
-@Returns:
-
-
diff --git a/include/Makefile.am b/include/Makefile.am
index 12746dfdd..64e89d7d5 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -8,7 +8,6 @@ gphotohead_HEADERS= \
gphoto2-debug.h \
gphoto2-file.h \
gphoto2-library.h \
- gphoto2-list.h \
gphoto2-setting.h \
gphoto2-result.h
diff --git a/libgphoto2/Makefile.am b/libgphoto2/Makefile.am
index b03eace60..f4d23a7cf 100644
--- a/libgphoto2/Makefile.am
+++ b/libgphoto2/Makefile.am
@@ -18,7 +18,7 @@ libgphoto2_la_SOURCES = \
gphoto2-filesys.c \
gamma.c gamma.h \
jpeg.c jpeg.h \
- list.c \
+ gphoto2-list.c \
pattrec.c pattrec.h \
result.c \
setting.c \
@@ -30,6 +30,7 @@ libgphoto2include_HEADERS = \
gphoto2-abilities-list.h\
gphoto2-core.h \
gphoto2-filesys.h \
+ gphoto2-list.h \
gphoto2-widget.h
pkgconfigdir = $(libdir)/pkgconfig
diff --git a/libgphoto2/camera.c b/libgphoto2/camera.c
index 49fac1099..1d4ee2b17 100644
--- a/libgphoto2/camera.c
+++ b/libgphoto2/camera.c
@@ -477,7 +477,7 @@ gp_camera_init (Camera *camera)
camera->library_handle = GP_SYSTEM_DLOPEN (camera->abilities->library);
if (!camera->library_handle) {
gp_camera_status (camera, "");
- return (GP_ERROR);
+ return (GP_ERROR_LIBRARY);
}
/* Initialize the camera */
@@ -630,7 +630,7 @@ gp_camera_folder_list_files (Camera *camera, const char *folder,
GP_DEBUG ("ENTER: gp_camera_folder_list_files");
CHECK_NULL (camera && folder && list);
- list->count = 0;
+ gp_list_reset (list);
/* Check first if the camera driver uses the filesystem */
CHECK_OPEN (camera);
@@ -648,7 +648,7 @@ if (list->count)
gp_debug_printf (GP_DEBUG_HIGH, "core", "Getting file list for "
"folder '%s'...", folder);
- list->count = 0;
+ gp_list_reset (list);
CHECK_RESULT_OPEN_CLOSE (camera, camera->functions->folder_list_files (
camera, folder, list));
CHECK_RESULT (gp_list_sort (list));
@@ -666,7 +666,7 @@ gp_camera_folder_list_folders (Camera *camera, const char* folder,
GP_DEBUG ("ENTER: gp_camera_folder_list_folders");
CHECK_NULL (camera && folder && list);
- list->count = 0;
+ gp_list_reset (list);
/* Check first if the camera driver uses the filesystem */
CHECK_OPEN (camera);
@@ -684,7 +684,7 @@ if (list->count)
gp_debug_printf (GP_DEBUG_HIGH, "core", "Getting folder list for "
"folder '%s'...", folder);
- list->count = 0;
+ gp_list_reset (list);
CHECK_RESULT_OPEN_CLOSE (camera, camera->functions->folder_list_folders(
camera, folder, list));
diff --git a/libgphoto2/gphoto2-abilities-list.c b/libgphoto2/gphoto2-abilities-list.c
index c429079f6..bf703ca04 100644
--- a/libgphoto2/gphoto2-abilities-list.c
+++ b/libgphoto2/gphoto2-abilities-list.c
@@ -39,6 +39,7 @@ struct _CameraAbilitiesList {
};
static int gp_abilities_list_lookup_id (CameraAbilitiesList *, const char *);
+static int gp_abilities_list_sort (CameraAbilitiesList *);
int
gp_abilities_list_new (CameraAbilitiesList **list)
@@ -278,7 +279,7 @@ gp_abilities_list_count (CameraAbilitiesList *list)
return (list->count);
}
-int
+static int
gp_abilities_list_sort (CameraAbilitiesList *list)
{
CameraAbilities *t;
@@ -346,11 +347,10 @@ gp_abilities_list_get_abilities (CameraAbilitiesList *list, int index,
{
CHECK_NULL (list && abilities);
- if (index > list->count)
+ if (index < 0 || index >= list->count)
return (GP_ERROR_BAD_PARAMETERS);
memcpy (abilities, list->abilities[index], sizeof (CameraAbilities));
return (GP_OK);
}
-
diff --git a/libgphoto2/gphoto2-abilities-list.h b/libgphoto2/gphoto2-abilities-list.h
index 577de57dd..c0f15e586 100644
--- a/libgphoto2/gphoto2-abilities-list.h
+++ b/libgphoto2/gphoto2-abilities-list.h
@@ -38,7 +38,6 @@ int gp_abilities_list_dump_libs (CameraAbilitiesList *list);
int gp_abilities_list_append (CameraAbilitiesList *list, CameraAbilities *);
int gp_abilities_list_count (CameraAbilitiesList *list);
-int gp_abilities_list_sort (CameraAbilitiesList *list);
int gp_abilities_list_lookup_model (CameraAbilitiesList *list, const char *m);
int gp_abilities_list_get_model (CameraAbilitiesList *list, int index,
diff --git a/libgphoto2/gphoto2-filesys.c b/libgphoto2/gphoto2-filesys.c
index 0e36c9a1c..a608ca975 100644
--- a/libgphoto2/gphoto2-filesys.c
+++ b/libgphoto2/gphoto2-filesys.c
@@ -588,7 +588,7 @@ gp_filesystem_list_files (CameraFilesystem *fs, const char *folder,
CHECK_NULL (fs && list && folder);
CHECK_ABS (folder);
- list->count = 0;
+ gp_list_reset (list);
/* Search the folder */
CHECK_RESULT (x = gp_filesystem_folder_number (fs, folder));
@@ -611,7 +611,7 @@ gp_filesystem_list_files (CameraFilesystem *fs, const char *folder,
" - %s", name);
CHECK_RESULT (gp_filesystem_append (fs, folder, name));
}
- list->count = 0;
+ gp_list_reset (list);
}
/* The folder is clean now */
@@ -656,7 +656,7 @@ gp_filesystem_list_folders (CameraFilesystem *fs, const char *folder,
CHECK_NULL (fs && folder && list);
CHECK_ABS (folder);
- list->count = 0;
+ gp_list_reset (list);
/* Search the folder */
CHECK_RESULT (x = gp_filesystem_folder_number (fs, folder));
@@ -675,7 +675,7 @@ gp_filesystem_list_folders (CameraFilesystem *fs, const char *folder,
strcat (buf, name);
CHECK_RESULT (append_folder (fs, buf));
}
- list->count = 0;
+ gp_list_reset (list);
}
for (x = 0; x < fs->count; x++)
diff --git a/libgphoto2/list.c b/libgphoto2/gphoto2-list.c
index 27c764ab1..8dbd86f7b 100644
--- a/libgphoto2/list.c
+++ b/libgphoto2/gphoto2-list.c
@@ -29,6 +29,14 @@
#define CHECK_NULL(r) {if (!(r)) return (GP_ERROR_BAD_PARAMETERS);}
#define CHECK_RESULT(result) {int r = (result); if (r < 0) return (r);}
+/**
+ * gp_list_new:
+ * @list:
+ *
+ * Creates a new #CameraList.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_new (CameraList **list)
{
@@ -37,7 +45,6 @@ gp_list_new (CameraList **list)
*list = malloc (sizeof (CameraList));
if (!*list)
return (GP_ERROR_NO_MEMORY);
-
memset (*list, 0, sizeof (CameraList));
(*list)->ref_count = 1;
@@ -45,6 +52,14 @@ gp_list_new (CameraList **list)
return (GP_OK);
}
+/**
+ * gp_list_ref:
+ * @list: a #CameraList
+ *
+ * Increments the reference count of the @list.
+ *
+ * Return value: a gphoto2 error code.
+ **/
int
gp_list_ref (CameraList *list)
{
@@ -55,6 +70,15 @@ gp_list_ref (CameraList *list)
return (GP_OK);
}
+/**
+ * gp_list_unref:
+ * @list: a #CameraList
+ *
+ * Decrements the reference count of the @list. If there are no references
+ * left, the @list will be freed.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_unref (CameraList *list)
{
@@ -68,6 +92,14 @@ gp_list_unref (CameraList *list)
return (GP_OK);
}
+/**
+ * gp_list_free:
+ * @list: the #CameraList to be freed
+ *
+ * Frees the @list. It is recommended to use #gp_list_unref instead.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_free (CameraList *list)
{
@@ -78,16 +110,34 @@ gp_list_free (CameraList *list)
return (GP_OK);
}
+/**
+ * gp_list_reset:
+ * @list: a #CameraList
+ *
+ * Resets the @list and removes all entries.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
-gp_list_remove_all (CameraList *list)
+gp_list_reset (CameraList *list)
{
CHECK_NULL (list);
- list->count = 0;
+ gp_list_reset (list);
return (GP_OK);
}
+/**
+ * gp_list_append:
+ * @list: a #CameraList
+ * @name: the name of the entry to append
+ * @value: the value of the entry to append
+ *
+ * Appends @name and @value to the @list.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_append (CameraList *list, const char *name, const char *value)
{
@@ -97,9 +147,11 @@ gp_list_append (CameraList *list, const char *name, const char *value)
return (GP_ERROR_NO_MEMORY);
if (name)
- strcpy (list->entry[list->count].name, name);
+ strncpy (list->entry[list->count].name, name,
+ sizeof (list->entry[list->count].name));
if (value)
- strcpy (list->entry[list->count].value, value);
+ strncpy (list->entry[list->count].value, value,
+ sizeof (list->entry[list->count].value));
list->count++;
@@ -120,6 +172,14 @@ exchange (CameraList *list, int x, int y)
strcpy (list->entry[y].value, value);
}
+/**
+ * gp_list_sort:
+ * @list: a #CameraList
+ *
+ * Sorts the @list entries with respect to the names.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_sort (CameraList *list)
{
@@ -137,6 +197,14 @@ gp_list_sort (CameraList *list)
return (GP_OK);
}
+/**
+ * gp_list_count:
+ * @list: a #CameraList
+ *
+ * Counts the entries in the @list.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_count (CameraList *list)
{
@@ -145,12 +213,22 @@ gp_list_count (CameraList *list)
return (list->count);
}
+/**
+ * gp_list_get_name:
+ * @list: a #CameraList
+ * @index: index of the entry
+ * @name:
+ *
+ * Retreives the @name of entry with @index.
+ *
+ * Return value: a gphoto2 error code.
+ **/
int
gp_list_get_name (CameraList *list, int index, const char **name)
{
CHECK_NULL (list && name);
- if (index >= list->count)
+ if (index < 0 || index >= list->count)
return (GP_ERROR_BAD_PARAMETERS);
*name = list->entry[index].name;
@@ -158,12 +236,22 @@ gp_list_get_name (CameraList *list, int index, const char **name)
return (GP_OK);
}
+/**
+ * gp_list_get_value:
+ * @list: a #CameraList
+ * @index: index of the entry
+ * @value:
+ *
+ * Retreives the value of entry with @index.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_get_value (CameraList *list, int index, const char **value)
{
CHECK_NULL (list && value);
- if (index >= list->count)
+ if (index < 0 || index >= list->count)
return (GP_ERROR_BAD_PARAMETERS);
*value = list->entry[index].value;
@@ -171,12 +259,22 @@ gp_list_get_value (CameraList *list, int index, const char **value)
return (GP_OK);
}
+/**
+ * gp_list_set_value:
+ * @list: a #CameraList
+ * @index: index of the entry
+ * @value: the value to be set
+ *
+ * Sets the @value of an entry.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_set_value (CameraList *list, int index, const char *value)
{
CHECK_NULL (list && value);
- if (index >= list->count)
+ if (index < 0 || index >= list->count)
return (GP_ERROR_BAD_PARAMETERS);
strcpy (list->entry[index].value, value);
@@ -184,6 +282,16 @@ gp_list_set_value (CameraList *list, int index, const char *value)
return (GP_OK);
}
+/**
+ * gp_list_set_name:
+ * @list: a #CameraList
+ * @index: index of entry
+ * @name: name to be set
+ *
+ * Sets the name of an entry.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_set_name (CameraList *list, int index, const char *name)
{
@@ -197,6 +305,20 @@ gp_list_set_name (CameraList *list, int index, const char *name)
return (GP_OK);
}
+/**
+ * gp_list_populate:
+ * @list: a #CameraList
+ * @format: the format
+ * @count: number of entries to be added to the @list
+ *
+ * Adds @count entries to the list. Typically, this function is called by
+ * a camera driver when there is no way of retreiving the real name of a
+ * picture. In this case, when asked for a file list
+ * (see #CameraFilesystemListFunc), the list is populated with dummy
+ * names generated by this function.
+ *
+ * Return value: a gphoto2 error code
+ **/
int
gp_list_populate (CameraList *list, const char *format, int count)
{
@@ -205,9 +327,9 @@ gp_list_populate (CameraList *list, const char *format, int count)
CHECK_NULL (list && format);
- list->count = 0;
+ gp_list_reset (list);
for (x = 0; x < count; x++) {
- sprintf (buf, format, x + 1);
+ snprintf (buf, sizeof (buf), format, x + 1);
CHECK_RESULT (gp_list_append (list, buf, NULL));
}
diff --git a/include/gphoto2-list.h b/libgphoto2/gphoto2-list.h
index 0ded55e91..21903c7d5 100644
--- a/include/gphoto2-list.h
+++ b/libgphoto2/gphoto2-list.h
@@ -38,10 +38,11 @@ int gp_list_ref (CameraList *list);
int gp_list_unref (CameraList *list);
int gp_list_free (CameraList *list);
-int gp_list_count (CameraList*);
-int gp_list_append (CameraList*, const char *name, const char *value);
-int gp_list_remove_all (CameraList*);
-int gp_list_sort (CameraList*);
+int gp_list_count (CameraList *list);
+int gp_list_append (CameraList *list,
+ const char *name, const char *value);
+int gp_list_reset (CameraList *list);
+int gp_list_sort (CameraList *list);
int gp_list_get_name (CameraList *list, int index, const char **name);
int gp_list_get_value (CameraList *list, int index, const char **value);