Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_list_find_by_name ( CameraList list,
int *  index,
const char *  name 
)

Retrieves the index of an arbitrary entry with name.

Parameters:
list a CameraList
index pointer to the result index (may be NULL, only set if found)
name name of the entry
Returns:
a gphoto2 error code: GP_OK if found.
No guarantees as to the speed of the search, or in what sequence the list is searched.

Definition at line 338 of file gphoto2-list.c.

References CHECK_LIST, CHECK_NULL, GP_ERROR, and GP_OK.

{
      int i;
      CHECK_LIST (list);
      CHECK_NULL (name);

      /* We search backwards because our only known user
       * camlibs/ptp2/library.c thinks this is faster
       */
      for (i=list->count-1; i >= 0; i--) {
        if (0==strcmp(list->entry[i].name, name)) {
          if (index) {
            (*index) = i;
          }
          return (GP_OK);
        }
      }

      return (GP_ERROR);
}


Generated by  Doxygen 1.6.0   Back to index