summaryrefslogtreecommitdiffstats
path: root/src/afc.c
diff options
context:
space:
mode:
authorGravatar Aaron Burghardt2014-03-27 10:07:09 -0400
committerGravatar Aaron Burghardt2014-03-27 21:40:43 -0400
commit2342dc5b4ef148b993fbe3816f3facdef8365546 (patch)
tree69f812d91b2fc07db0fad5dcba6c80d2f8b6849e /src/afc.c
parentee82e861a8c942b5013accd7589cf898d1f97167 (diff)
downloadlibimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.gz
libimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.bz2
Moved Doxygen comments from source files to public headers.
Conflicts: include/libimobiledevice/afc.h
Diffstat (limited to 'src/afc.c')
-rw-r--r--src/afc.c212
1 files changed, 0 insertions, 212 deletions
diff --git a/src/afc.c b/src/afc.c
index dd75558..b5203f1 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -95,18 +95,6 @@ afc_error_t afc_client_new_with_service_client(service_client_t service_client,
95 return AFC_E_SUCCESS; 95 return AFC_E_SUCCESS;
96} 96}
97 97
98/**
99 * Makes a connection to the AFC service on the device.
100 *
101 * @param device The device to connect to.
102 * @param service The service descriptor returned by lockdownd_start_service.
103 * @param client Pointer that will be set to a newly allocated afc_client_t
104 * upon successful return.
105 *
106 * @return AFC_E_SUCCESS on success, AFC_E_INVALID_ARG if device or service is
107 * invalid, AFC_E_MUX_ERROR if the connection cannot be established,
108 * or AFC_E_NO_MEM if there is a memory allocation problem.
109 */
110afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client) 98afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client)
111{ 99{
112 if (!device || !service || service->port == 0) 100 if (!device || !service || service->port == 0)
@@ -126,19 +114,6 @@ afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t serv
126 return err; 114 return err;
127} 115}
128 116
129/**
130 * Starts a new AFC service on the specified device and connects to it.
131 *
132 * @param device The device to connect to.
133 * @param client Pointer that will point to a newly allocated
134 * afc_client_t upon successful return. Must be freed using
135 * afc_client_free() after use.
136 * @param label The label to use for communication. Usually the program name.
137 * Pass NULL to disable sending the label in requests to lockdownd.
138 *
139 * @return AFC_E_SUCCESS on success, or an AFC_E_* error
140 * code otherwise.
141 */
142afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, const char* label) 117afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, const char* label)
143{ 118{
144 afc_error_t err = AFC_E_UNKNOWN_ERROR; 119 afc_error_t err = AFC_E_UNKNOWN_ERROR;
@@ -146,12 +121,6 @@ afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, co
146 return err; 121 return err;
147} 122}
148 123
149/**
150 * Frees up an AFC client. If the connection was created by the
151 * client itself, the connection will be closed.
152 *
153 * @param client The client to free.
154 */
155afc_error_t afc_client_free(afc_client_t client) 124afc_error_t afc_client_free(afc_client_t client)
156{ 125{
157 if (!client || !client->afc_packet) 126 if (!client || !client->afc_packet)
@@ -432,16 +401,6 @@ static char **make_strings_list(char *tokens, uint32_t length)
432 return list; 401 return list;
433} 402}
434 403
435/**
436 * Gets a directory listing of the directory requested.
437 *
438 * @param client The client to get a directory listing from.
439 * @param dir The directory to list. (must be a fully-qualified path)
440 * @param list A char list of files in that directory, terminated by an empty
441 * string or NULL if there was an error.
442 *
443 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
444 */
445afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list) 404afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list)
446{ 405{
447 uint32_t bytes = 0; 406 uint32_t bytes = 0;
@@ -478,17 +437,6 @@ afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***lis
478 return ret; 437 return ret;
479} 438}
480 439
481/**
482 * Get device information for a connected client. The device information
483 * returned is the device model as well as the free space, the total capacity
484 * and blocksize on the accessed disk partition.
485 *
486 * @param client The client to get device info for.
487 * @param infos A char ** list of parameters as given by AFC or NULL if there
488 * was an error.
489 *
490 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
491 */
492afc_error_t afc_get_device_info(afc_client_t client, char ***infos) 440afc_error_t afc_get_device_info(afc_client_t client, char ***infos)
493{ 441{
494 uint32_t bytes = 0; 442 uint32_t bytes = 0;
@@ -526,17 +474,6 @@ afc_error_t afc_get_device_info(afc_client_t client, char ***infos)
526 return ret; 474 return ret;
527} 475}
528 476
529/**
530 * Get a specific key of the device info list for a client connection.
531 * Known key values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize.
532 * This is a helper function for afc_get_device_info().
533 *
534 * @param client The client to get device info for.
535 * @param key The key to get the value of.
536 * @param value The value for the key if successful or NULL otherwise.
537 *
538 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
539 */
540afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value) 477afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value)
541{ 478{
542 afc_error_t ret = AFC_E_INTERNAL_ERROR; 479 afc_error_t ret = AFC_E_INTERNAL_ERROR;
@@ -564,14 +501,6 @@ afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char *
564 return ret; 501 return ret;
565} 502}
566 503
567/**
568 * Deletes a file or directory.
569 *
570 * @param client The client to use.
571 * @param path The path to delete. (must be a fully-qualified path)
572 *
573 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
574 */
575afc_error_t afc_remove_path(afc_client_t client, const char *path) 504afc_error_t afc_remove_path(afc_client_t client, const char *path)
576{ 505{
577 uint32_t bytes = 0; 506 uint32_t bytes = 0;
@@ -600,15 +529,6 @@ afc_error_t afc_remove_path(afc_client_t client, const char *path)
600 return ret; 529 return ret;
601} 530}
602 531
603/**
604 * Renames a file or directory on the device.
605 *
606 * @param client The client to have rename.
607 * @param from The name to rename from. (must be a fully-qualified path)
608 * @param to The new name. (must also be a fully-qualified path)
609 *
610 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
611 */
612afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to) 532afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to)
613{ 533{
614 char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); 534 char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t)));
@@ -638,15 +558,6 @@ afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *t
638 return ret; 558 return ret;
639} 559}
640 560
641/**
642 * Creates a directory on the device.
643 *
644 * @param client The client to use to make a directory.
645 * @param dir The directory's path. (must be a fully-qualified path, I assume
646 * all other mkdir restrictions apply as well)
647 *
648 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
649 */
650afc_error_t afc_make_directory(afc_client_t client, const char *dir) 561afc_error_t afc_make_directory(afc_client_t client, const char *dir)
651{ 562{
652 uint32_t bytes = 0; 563 uint32_t bytes = 0;
@@ -671,17 +582,6 @@ afc_error_t afc_make_directory(afc_client_t client, const char *dir)
671 return ret; 582 return ret;
672} 583}
673 584
674/**
675 * Gets information about a specific file.
676 *
677 * @param client The client to use to get the information of the file.
678 * @param path The fully-qualified path to the file.
679 * @param infolist Pointer to a buffer that will be filled with a NULL-terminated
680 * list of strings with the file information.
681 * Set to NULL before calling this function.
682 *
683 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
684 */
685afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***infolist) 585afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***infolist)
686{ 586{
687 char *received = NULL; 587 char *received = NULL;
@@ -712,19 +612,6 @@ afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***inf
712 return ret; 612 return ret;
713} 613}
714 614
715/**
716 * Opens a file on the device.
717 *
718 * @param client The client to use to open the file.
719 * @param filename The file to open. (must be a fully-qualified path)
720 * @param file_mode The mode to use to open the file. Can be AFC_FILE_READ or
721 * AFC_FILE_WRITE; the former lets you read and write,
722 * however, and the second one will *create* the file,
723 * destroying anything previously there.
724 * @param handle Pointer to a uint64_t that will hold the handle of the file
725 *
726 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
727 */
728idevice_error_t 615idevice_error_t
729afc_file_open(afc_client_t client, const char *filename, 616afc_file_open(afc_client_t client, const char *filename,
730 afc_file_mode_t file_mode, uint64_t *handle) 617 afc_file_mode_t file_mode, uint64_t *handle)
@@ -772,17 +659,6 @@ afc_file_open(afc_client_t client, const char *filename,
772 return ret; 659 return ret;
773} 660}
774 661
775/**
776 * Attempts to the read the given number of bytes from the given file.
777 *
778 * @param client The relevant AFC client
779 * @param handle File handle of a previously opened file
780 * @param data The pointer to the memory region to store the read data
781 * @param length The number of bytes to read
782 * @param bytes_read The number of bytes actually read.
783 *
784 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
785 */
786idevice_error_t 662idevice_error_t
787afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read) 663afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read)
788{ 664{
@@ -837,17 +713,6 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length,
837 return ret; 713 return ret;
838} 714}
839 715
840/**
841 * Writes a given number of bytes to a file.
842 *
843 * @param client The client to use to write to the file.
844 * @param handle File handle of previously opened file.
845 * @param data The data to write to the file.
846 * @param length How much data to write.
847 * @param bytes_written The number of bytes actually written to the file.
848 *
849 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
850 */
851idevice_error_t 716idevice_error_t
852afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written) 717afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written)
853{ 718{
@@ -881,12 +746,6 @@ afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t
881 return ret; 746 return ret;
882} 747}
883 748
884/**
885 * Closes a file on the device.
886 *
887 * @param client The client to close the file with.
888 * @param handle File handle of a previously opened file.
889 */
890afc_error_t afc_file_close(afc_client_t client, uint64_t handle) 749afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
891{ 750{
892 uint32_t bytes = 0; 751 uint32_t bytes = 0;
@@ -915,18 +774,6 @@ afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
915 return ret; 774 return ret;
916} 775}
917 776
918/**
919 * Locks or unlocks a file on the device.
920 *
921 * makes use of flock on the device, see
922 * http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/flock.2.html
923 *
924 * @param client The client to lock the file with.
925 * @param handle File handle of a previously opened file.
926 * @param operation the lock or unlock operation to perform, this is one of
927 * AFC_LOCK_SH (shared lock), AFC_LOCK_EX (exclusive lock),
928 * or AFC_LOCK_UN (unlock).
929 */
930afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation) 777afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation)
931{ 778{
932 uint32_t bytes = 0; 779 uint32_t bytes = 0;
@@ -961,16 +808,6 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op
961 return ret; 808 return ret;
962} 809}
963 810
964/**
965 * Seeks to a given position of a pre-opened file on the device.
966 *
967 * @param client The client to use to seek to the position.
968 * @param handle File handle of a previously opened.
969 * @param offset Seek offset.
970 * @param whence Seeking direction, one of SEEK_SET, SEEK_CUR, or SEEK_END.
971 *
972 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
973 */
974afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence) 811afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence)
975{ 812{
976 uint32_t bytes = 0; 813 uint32_t bytes = 0;
@@ -1004,15 +841,6 @@ afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset,
1004 return ret; 841 return ret;
1005} 842}
1006 843
1007/**
1008 * Returns current position in a pre-opened file on the device.
1009 *
1010 * @param client The client to use.
1011 * @param handle File handle of a previously opened file.
1012 * @param position Position in bytes of indicator
1013 *
1014 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1015 */
1016afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position) 844afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position)
1017{ 845{
1018 char *buffer = (char *) malloc(sizeof(char) * 8); 846 char *buffer = (char *) malloc(sizeof(char) * 8);
@@ -1047,18 +875,6 @@ afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *positi
1047 return ret; 875 return ret;
1048} 876}
1049 877
1050/**
1051 * Sets the size of a file on the device.
1052 *
1053 * @param client The client to use to set the file size.
1054 * @param handle File handle of a previously opened file.
1055 * @param newsize The size to set the file to.
1056 *
1057 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1058 *
1059 * @note This function is more akin to ftruncate than truncate, and truncate
1060 * calls would have to open the file before calling this, sadly.
1061 */
1062afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize) 878afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize)
1063{ 879{
1064 uint32_t bytes = 0; 880 uint32_t bytes = 0;
@@ -1090,15 +906,6 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new
1090 return ret; 906 return ret;
1091} 907}
1092 908
1093/**
1094 * Sets the size of a file on the device without prior opening it.
1095 *
1096 * @param client The client to use to set the file size.
1097 * @param path The path of the file to be truncated.
1098 * @param newsize The size to set the file to.
1099 *
1100 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1101 */
1102afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize) 909afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize)
1103{ 910{
1104 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); 911 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
@@ -1129,16 +936,6 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize
1129 return ret; 936 return ret;
1130} 937}
1131 938
1132/**
1133 * Creates a hard link or symbolic link on the device.
1134 *
1135 * @param client The client to use for making a link
1136 * @param linktype 1 = hard link, 2 = symlink
1137 * @param target The file to be linked.
1138 * @param linkname The name of link.
1139 *
1140 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1141 */
1142afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname) 939afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname)
1143{ 940{
1144 char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); 941 char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8));
@@ -1173,15 +970,6 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c
1173 return ret; 970 return ret;
1174} 971}
1175 972
1176/**
1177 * Sets the modification time of a file on the device.
1178 *
1179 * @param client The client to use to set the file size.
1180 * @param path Path of the file for which the modification time should be set.
1181 * @param mtime The modification time to set in nanoseconds since epoch.
1182 *
1183 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1184 */
1185afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime) 973afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime)
1186{ 974{
1187 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); 975 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));