diff options
author | Bastien Nocera | 2009-08-01 15:04:27 +0100 |
---|---|---|
committer | Matt Colyer | 2009-08-03 08:58:33 -0700 |
commit | d5da1a93f977688d621f3f3650ee0a7a51e2b373 (patch) | |
tree | 34bfbb67f40d0f58f900201e88d110124f2009d6 /src/AFC.c | |
parent | eb5d285ed474f0cc20b968e4a5d590a3b35e52a7 (diff) | |
download | libimobiledevice-d5da1a93f977688d621f3f3650ee0a7a51e2b373.tar.gz libimobiledevice-d5da1a93f977688d621f3f3650ee0a7a51e2b373.tar.bz2 |
Add afc_get_device_info_field() helper function
For use in front-end applications, also serves to document
the available keys.
Diffstat (limited to 'src/AFC.c')
-rw-r--r-- | src/AFC.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -468,6 +468,35 @@ afc_error_t afc_get_device_info(afc_client_t client, char ***infos) return ret; } +/** Get a specific field of the device info for a client connection to phone. + * Known values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize. This is + * a helper function for afc_get_device_info(). + * + * @param client The client to get device info for. + * @param field The field to get the information for + * + * @return A char * or NULL if there was an error. + */ +char * afc_get_device_info_field(afc_client_t client, const char *field) +{ + char *ret = NULL; + char **kvps, **ptr; + + if (field == NULL || afc_get_device_info(client, &kvps) != AFC_E_SUCCESS) + return NULL; + + for (ptr = kvps; *ptr; ptr++) { + if (!strcmp(*ptr, field)) { + ret = strdup(*(ptr+1)); + break; + } + } + + g_strfreev(kvps); + + return ret; +} + /** Deletes a file or directory. * * @param client The client to use. |