libgphoto2 photo camera library (libgphoto2) API 2.4.14

- Main Page
- Related Pages
- Data Structures
- Files
- Directories

- File List
- Globals

Data Structures | Defines | Functions

# gphoto2-port-info-list.c File Reference

`#include "config.h"`
`#include <gphoto2/gphoto2-port-info-list.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <stdio.h>`
`#include <ltdl.h>`
`#include <gphoto2/gphoto2-port-result.h>`
`#include <gphoto2/gphoto2-port-library.h>`
`#include <gphoto2/gphoto2-port-log.h>`

## Data Structures
struct | _GPPortInfoList
## Defines
#define | _GNU_SOURCE
#define | textdomain(String) (String)
#define | gettext(String) (String)
#define | dgettext(Domain, Message) (Message)
#define | dcgettext(Domain, Message, Type) (Message)
#define | bindtextdomain(Domain, Directory) (Domain)
#define | bind_textdomain_codeset(Domain, codeset) (codeset)
#define | _(String) (String)
#define | N_(String) (String)
#define | ngettext(String1, String2, Count) ((Count==1)?String1:String2)
#define | CHECK_NULL(x) {if (!(x)) return (GP_ERROR_BAD_PARAMETERS);}
#define | CR(x) {int r=(x);if (r<0) return (r);}
#define | IOLIBDIR_ENV "IOLIBS"
## Functions
const char * | gp_port_message_codeset (const char *codeset)
| Specify codeset for translations.
int | gp_port_info_list_new (GPPortInfoList **list)
| Create a new GPPortInfoList.
int | gp_port_info_list_free (GPPortInfoList *list)
| Free a GPPortInfo list.
int | gp_port_info_list_append (GPPortInfoList *list, GPPortInfo info)
| Append a portinfo to the port information list.
int | gp_port_info_list_load (GPPortInfoList *list)
| Load system ports.
int | gp_port_info_list_count (GPPortInfoList *list)
| Number of ports in the list.
int | gp_port_info_list_lookup_path (GPPortInfoList *list, const char *path)
| Lookup a specific path in the list.
int | gp_port_info_list_lookup_name (GPPortInfoList *list, const char *name)
| Look up a name in the list.
int | gp_port_info_list_get_info (GPPortInfoList *list, int n, GPPortInfo *info)
| Get port information of specific entry.

## Detailed Description

Author:
  Copyright 2001 Lutz Müller <lutz@users.sf.net>

License
  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

  This library 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 Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

## Define Documentation

#define IOLIBDIR_ENV "IOLIBS"

IOLIBDIR_ENV:

Name of the environment variable which may contain the path where to look for the IO libs. If this environment variable is not defined, use the compiled-in default constant.

Referenced by gp_port_info_list_load().

## Function Documentation

int gp_port_info_list_append | ( | GPPortInfoList * | list,
|  | GPPortInfo | info
| ) |  |

Append a portinfo to the port information list.

Parameters:

  list | a #GPPortInfoList
  info | the info to append

Appends an entry to the list. This function is typically called by an io-driver during #gp_port_library_list. If you leave info.name blank, gp_port_info_list_lookup_path will try to match non-existent paths against info.path and - if successfull - will append this entry to the list.

Note:
  This returns index - number of generic entries, not the correct index.

Returns:
  A non-negative number or a gphoto2 error code

References GP_ERROR_NO_MEMORY, and _GPPortInfo::name.

Referenced by gp_port_info_list_lookup_path().

int gp_port_info_list_count | ( | GPPortInfoList * | list | ) |

Number of ports in the list.

Parameters:

  list | a #GPPortInfoList

Returns the number of entries in the passed list.

Returns:
  The number of entries or a gphoto2 error code

References gp_log(), GP_LOG_DEBUG, and _GPPortInfo::name.

Referenced by gp_abilities_list_detect().

int gp_port_info_list_free | ( | GPPortInfoList * | list | ) |

Free a GPPortInfo list.

Parameters:

  list | a #GPPortInfoList

Frees a GPPortInfoList structure and its internal data structures.

Returns:
  a gphoto2 error code

References GP_OK.

Referenced by gp_camera_init().

int gp_port_info_list_get_info | ( | GPPortInfoList * | list,
|  | int | n,
|  | GPPortInfo * | info
| ) |  |

Get port information of specific entry.

Parameters:

  list | a #GPPortInfoList
  n | the index of the entry
  info | the returned information

Retreives an entry from the list and stores it into info.

Returns:
  a gphoto2 error code

References GP_ERROR_BAD_PARAMETERS, gp_log(), GP_LOG_DEBUG, GP_OK, and _GPPortInfo::name.

Referenced by gp_abilities_list_detect(), and gp_camera_init().

int gp_port_info_list_load | ( | GPPortInfoList * | list | ) |

Load system ports.

Parameters:

  list | a #GPPortInfoList

Searches the system for io-drivers and appends them to the list. You would normally call this function once after gp_port_info_list_new and then use this list in order to supply gp_port_set_info with parameters or to do autodetection.

Returns:
  a gphoto2 error code

References gp_log(), GP_LOG_DEBUG, GP_OK, and IOLIBDIR_ENV.

Referenced by gp_camera_init().

int gp_port_info_list_lookup_name | ( | GPPortInfoList * | list,
|  | const char * | name
| ) |  |

Look up a name in the list.

Parameters:

  list | a #GPPortInfoList
  name | a name

Looks for an entry in the list with the exact given name.

Returns:
  The index of the entry or a gphoto2 error code

References GP_ERROR_UNKNOWN_PORT, gp_log(), GP_LOG_DEBUG, and _GPPortInfo::name.

int gp_port_info_list_lookup_path | ( | GPPortInfoList * | list,
|  | const char * | path
| ) |  |

Lookup a specific path in the list.

Parameters:

  list | a #GPPortInfoList
  path | a path

Looks for an entry in the list with the supplied path. If no exact match can be found, a regex search will be performed in the hope some driver claimed ports like "serial:*".

Returns:
  The index of the entry or a gphoto2 error code

References GP_ERROR_UNKNOWN_PORT, gp_log(), GP_LOG_DEBUG, GP_LOG_ERROR, gp_port_info_list_append(), _GPPortInfo::name, and _GPPortInfo::path.

Referenced by gp_camera_init().

int gp_port_info_list_new | ( | GPPortInfoList ** | list | ) |

Create a new GPPortInfoList.

Parameters:

  list | pointer to a GPPortInfoList* which is allocated

Creates a new list which can later be filled with port infos (GPPortInfo) using gp_port_info_list_load.

Returns:
  a gphoto2 error code

References GP_ERROR_NO_MEMORY, and GP_OK.

Referenced by gp_camera_init().

const char* gp_port_message_codeset | ( | const char * | codeset | ) |

Specify codeset for translations.

This function specifies the codeset that are used for the translated strings that are passed back by the libgphoto2_port functions.

This function is called by the gp_message_codeset() function, there is no need to call it yourself.

Parameters:

  codeset | new codeset to use

Returns:
  the previous codeset

Referenced by gp_message_codeset().