diff options
| author | 2009-08-01 15:04:27 +0100 | |
|---|---|---|
| committer | 2009-08-01 18:51:05 +0200 | |
| commit | 14868dc30c7e59f9838a6b67e2e15673f0f1557b (patch) | |
| tree | 34bfbb67f40d0f58f900201e88d110124f2009d6 /src/AFC.c | |
| parent | f5bec85063c0a05085f9c03fb2d76ba6a1d1c92d (diff) | |
| download | libimobiledevice-14868dc30c7e59f9838a6b67e2e15673f0f1557b.tar.gz libimobiledevice-14868dc30c7e59f9838a6b67e2e15673f0f1557b.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) | |||
| 468 | return ret; | 468 | return ret; |
| 469 | } | 469 | } |
| 470 | 470 | ||
| 471 | /** Get a specific field of the device info for a client connection to phone. | ||
| 472 | * Known values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize. This is | ||
| 473 | * a helper function for afc_get_device_info(). | ||
| 474 | * | ||
| 475 | * @param client The client to get device info for. | ||
| 476 | * @param field The field to get the information for | ||
| 477 | * | ||
| 478 | * @return A char * or NULL if there was an error. | ||
| 479 | */ | ||
| 480 | char * afc_get_device_info_field(afc_client_t client, const char *field) | ||
| 481 | { | ||
| 482 | char *ret = NULL; | ||
| 483 | char **kvps, **ptr; | ||
| 484 | |||
| 485 | if (field == NULL || afc_get_device_info(client, &kvps) != AFC_E_SUCCESS) | ||
| 486 | return NULL; | ||
| 487 | |||
| 488 | for (ptr = kvps; *ptr; ptr++) { | ||
| 489 | if (!strcmp(*ptr, field)) { | ||
| 490 | ret = strdup(*(ptr+1)); | ||
| 491 | break; | ||
| 492 | } | ||
| 493 | } | ||
| 494 | |||
| 495 | g_strfreev(kvps); | ||
| 496 | |||
| 497 | return ret; | ||
| 498 | } | ||
| 499 | |||
| 471 | /** Deletes a file or directory. | 500 | /** Deletes a file or directory. |
| 472 | * | 501 | * |
| 473 | * @param client The client to use. | 502 | * @param client The client to use. |
