summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AFC.c13
-rw-r--r--src/initconf.c4
-rw-r--r--src/iphone.c6
-rw-r--r--src/lockdown.c5
-rw-r--r--src/lockdown.h2
-rw-r--r--src/usbmux.c9
-rw-r--r--src/usbmux.h2
-rw-r--r--src/userpref.c9
-rw-r--r--src/userpref.h2
9 files changed, 27 insertions, 25 deletions
diff --git a/src/AFC.c b/src/AFC.c
index aefb971..a1f7a08 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -23,6 +23,7 @@
23#include "AFC.h" 23#include "AFC.h"
24 24
25 25
26
26// This is the maximum size an AFC data packet can be 27// This is the maximum size an AFC data packet can be
27const int MAXIMUM_PACKET_SIZE = (2 << 15) - 32; 28const int MAXIMUM_PACKET_SIZE = (2 << 15) - 32;
28 29
@@ -555,7 +556,7 @@ iphone_error_t iphone_afc_mkdir(iphone_afc_client_t client, const char *dir)
555 * @return A pointer to an AFCFile struct containing the information received, 556 * @return A pointer to an AFCFile struct containing the information received,
556 * or NULL on failure. 557 * or NULL on failure.
557 */ 558 */
558iphone_afc_file_t afc_get_file_info(iphone_afc_client_t client, const char *path) 559static iphone_afc_file_t afc_get_file_info(iphone_afc_client_t client, const char *path)
559{ 560{
560 char *received, **list; 561 char *received, **list;
561 iphone_afc_file_t my_file; 562 iphone_afc_file_t my_file;
@@ -794,7 +795,9 @@ iphone_afc_write_file(iphone_afc_client_t client, iphone_afc_file_t file,
794{ 795{
795 char *acknowledgement = NULL; 796 char *acknowledgement = NULL;
796 const int MAXIMUM_WRITE_SIZE = 1 << 15; 797 const int MAXIMUM_WRITE_SIZE = 1 << 15;
797 uint32_t zero = 0, bytes_loc = 0, segments = (length / MAXIMUM_WRITE_SIZE), current_count = 0, i = 0; 798 uint32_t zero = 0, current_count = 0, i = 0;
799 uint32_t segments = (length / MAXIMUM_WRITE_SIZE);
800 int bytes_loc = 0;
798 char *out_buffer = NULL; 801 char *out_buffer = NULL;
799 802
800 if (!client || !client->afc_packet || !client->connection || !file || !bytes) 803 if (!client || !client->afc_packet || !client->connection || !file || !bytes)
@@ -925,7 +928,8 @@ iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, iphone_afc_file
925iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_t file, int seekpos) 928iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_t file, int seekpos)
926{ 929{
927 char *buffer = (char *) malloc(sizeof(char) * 24); 930 char *buffer = (char *) malloc(sizeof(char) * 24);
928 uint32_t seekto = 0, bytes = 0, zero = 0; 931 uint32_t seekto = 0, zero = 0;
932 int bytes = 0;
929 933
930 if (seekpos < 0) 934 if (seekpos < 0)
931 seekpos = file->size - abs(seekpos); 935 seekpos = file->size - abs(seekpos);
@@ -978,7 +982,8 @@ iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_
978iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, iphone_afc_file_t file, uint32_t newsize) 982iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, iphone_afc_file_t file, uint32_t newsize)
979{ 983{
980 char *buffer = (char *) malloc(sizeof(char) * 16); 984 char *buffer = (char *) malloc(sizeof(char) * 16);
981 uint32_t bytes = 0, zero = 0; 985 int bytes = 0;
986 uint32_t zero = 0;
982 987
983 afc_lock(client); 988 afc_lock(client);
984 989
diff --git a/src/initconf.c b/src/initconf.c
index 00d78e2..538f344 100644
--- a/src/initconf.c
+++ b/src/initconf.c
@@ -35,7 +35,7 @@
35 * 35 *
36 * @param key The pointer to the desired location of the new key. 36 * @param key The pointer to the desired location of the new key.
37 */ 37 */
38void generate_key(gpointer key) 38static void generate_key(gpointer key)
39{ 39{
40 gnutls_x509_privkey_generate(*((gnutls_x509_privkey_t *) key), GNUTLS_PK_RSA, 2048, 0); 40 gnutls_x509_privkey_generate(*((gnutls_x509_privkey_t *) key), GNUTLS_PK_RSA, 2048, 0);
41 g_thread_exit(0); 41 g_thread_exit(0);
@@ -43,7 +43,7 @@ void generate_key(gpointer key)
43 43
44/** Simple function that generates a spinner until the mutex is released. 44/** Simple function that generates a spinner until the mutex is released.
45 */ 45 */
46void progress_bar(gpointer mutex) 46static void progress_bar(gpointer mutex)
47{ 47{
48 const char *spinner = "|/-\\|/-\\"; 48 const char *spinner = "|/-\\|/-\\";
49 int i = 0; 49 int i = 0;
diff --git a/src/iphone.c b/src/iphone.c
index b7f6cc4..32d27f6 100644
--- a/src/iphone.c
+++ b/src/iphone.c
@@ -42,7 +42,7 @@
42 * descriptor on return. 42 * descriptor on return.
43 * @return IPHONE_E_SUCCESS if ok, otherwise an error code. 43 * @return IPHONE_E_SUCCESS if ok, otherwise an error code.
44 */ 44 */
45iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t * device) 45static iphone_error_t iphone_get_specific_device(unsigned int bus_n, int dev_n, iphone_device_t * device)
46{ 46{
47 struct usb_bus *bus, *busses; 47 struct usb_bus *bus, *busses;
48 struct usb_device *dev; 48 struct usb_device *dev;
@@ -146,7 +146,7 @@ iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t
146 */ 146 */
147iphone_error_t iphone_get_device(iphone_device_t * device) 147iphone_error_t iphone_get_device(iphone_device_t * device)
148{ 148{
149 struct usb_bus *bus, *busses; 149 struct usb_bus *bus;
150 struct usb_device *dev; 150 struct usb_device *dev;
151 151
152 usb_init(); 152 usb_init();
@@ -214,7 +214,7 @@ int send_to_phone(iphone_device_t phone, char *data, int datalen)
214 } else { 214 } else {
215 return bytes; 215 return bytes;
216 } 216 }
217 217 /* Should not be reached */
218 return -1; 218 return -1;
219} 219}
220 220
diff --git a/src/lockdown.c b/src/lockdown.c
index 5b83fb9..c6d5f80 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include "usbmux.h" 22#include "usbmux.h"
23#include "utils.h"
23#include "iphone.h" 24#include "iphone.h"
24#include "lockdown.h" 25#include "lockdown.h"
25#include "userpref.h" 26#include "userpref.h"
@@ -41,8 +42,6 @@ const ASN1_ARRAY_TYPE pkcs1_asn1_tab[] = {
41 {0, 0, 0} 42 {0, 0, 0}
42}; 43};
43 44
44
45
46/** Creates a lockdownd client for the give iPhone. 45/** Creates a lockdownd client for the give iPhone.
47 * 46 *
48 * @param phone The iPhone to create a lockdownd client for 47 * @param phone The iPhone to create a lockdownd client for
@@ -235,7 +234,7 @@ iphone_error_t lockdownd_hello(iphone_lckd_client_t control)
235 * 234 *
236 * @return IPHONE_E_SUCCESS on success. 235 * @return IPHONE_E_SUCCESS on success.
237 */ 236 */
238iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, char *req_string, 237iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, char *req_string,
239 gnutls_datum_t * value) 238 gnutls_datum_t * value)
240{ 239{
241 if (!control || !req_key || !value || value->data) 240 if (!control || !req_key || !value || value->data)
diff --git a/src/lockdown.h b/src/lockdown.h
index 18e13aa..8ca8a7f 100644
--- a/src/lockdown.h
+++ b/src/lockdown.h
@@ -41,7 +41,7 @@ struct iphone_lckd_client_int {
41 41
42iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone); 42iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone);
43iphone_error_t lockdownd_hello(iphone_lckd_client_t control); 43iphone_error_t lockdownd_hello(iphone_lckd_client_t control);
44iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, char *req_string, 44iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, char *req_string,
45 gnutls_datum_t * value); 45 gnutls_datum_t * value);
46iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t control, char **uid); 46iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t control, char **uid);
47iphone_error_t lockdownd_get_device_public_key(iphone_lckd_client_t control, gnutls_datum_t * public_key); 47iphone_error_t lockdownd_get_device_public_key(iphone_lckd_client_t control, gnutls_datum_t * public_key);
diff --git a/src/usbmux.c b/src/usbmux.c
index f0499fa..427b880 100644
--- a/src/usbmux.c
+++ b/src/usbmux.c
@@ -26,6 +26,7 @@
26#include <string.h> 26#include <string.h>
27 27
28#include "usbmux.h" 28#include "usbmux.h"
29#include "utils.h"
29 30
30static iphone_umux_client_t *connlist = NULL; 31static iphone_umux_client_t *connlist = NULL;
31static int clients = 0; 32static int clients = 0;
@@ -57,7 +58,7 @@ usbmux_tcp_header *new_mux_packet(uint16_t s_port, uint16_t d_port)
57 * 58 *
58 * @return A USBMux header 59 * @return A USBMux header
59 */ 60 */
60usbmux_version_header *version_header() 61usbmux_version_header *version_header(void)
61{ 62{
62 usbmux_version_header *version = (usbmux_version_header *) malloc(sizeof(usbmux_version_header)); 63 usbmux_version_header *version = (usbmux_version_header *) malloc(sizeof(usbmux_version_header));
63 version->type = 0; 64 version->type = 0;
@@ -76,7 +77,7 @@ usbmux_version_header *version_header()
76 * 77 *
77 * @param connection The connection to delete from the tracking list. 78 * @param connection The connection to delete from the tracking list.
78 */ 79 */
79void delete_connection(iphone_umux_client_t connection) 80static void delete_connection(iphone_umux_client_t connection)
80{ 81{
81 iphone_umux_client_t *newlist = (iphone_umux_client_t *) malloc(sizeof(iphone_umux_client_t) * (clients - 1)); 82 iphone_umux_client_t *newlist = (iphone_umux_client_t *) malloc(sizeof(iphone_umux_client_t) * (clients - 1));
82 int i = 0, j = 0; 83 int i = 0, j = 0;
@@ -105,7 +106,7 @@ void delete_connection(iphone_umux_client_t connection)
105 * @param connection The connection to add to the global list of connections. 106 * @param connection The connection to add to the global list of connections.
106 */ 107 */
107 108
108void add_connection(iphone_umux_client_t connection) 109static void add_connection(iphone_umux_client_t connection)
109{ 110{
110 iphone_umux_client_t *newlist = 111 iphone_umux_client_t *newlist =
111 (iphone_umux_client_t *) realloc(connlist, sizeof(iphone_umux_client_t) * (clients + 1)); 112 (iphone_umux_client_t *) realloc(connlist, sizeof(iphone_umux_client_t) * (clients + 1));
@@ -178,7 +179,7 @@ iphone_error_t iphone_mux_new_client(iphone_device_t device, uint16_t src_port,
178iphone_error_t iphone_mux_free_client(iphone_umux_client_t client) 179iphone_error_t iphone_mux_free_client(iphone_umux_client_t client)
179{ 180{
180 if (!client || !client->phone) 181 if (!client || !client->phone)
181 return; 182 return IPHONE_E_INVALID_ARG;
182 183
183 client->header->tcp_flags = 0x04; 184 client->header->tcp_flags = 0x04;
184 client->header->scnt = htonl(client->header->scnt); 185 client->header->scnt = htonl(client->header->scnt);
diff --git a/src/usbmux.h b/src/usbmux.h
index 4b18e07..bea83f7 100644
--- a/src/usbmux.h
+++ b/src/usbmux.h
@@ -52,7 +52,7 @@ typedef struct {
52 uint32_t type, length, major, minor, allnull; 52 uint32_t type, length, major, minor, allnull;
53} usbmux_version_header; 53} usbmux_version_header;
54 54
55usbmux_version_header *version_header(); 55usbmux_version_header *version_header(void);
56 56
57 57
58#endif 58#endif
diff --git a/src/userpref.c b/src/userpref.c
index b707957..3e5eb06 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -39,7 +39,7 @@
39 39
40/** Creates a freedesktop compatible configuration directory for libiphone. 40/** Creates a freedesktop compatible configuration directory for libiphone.
41 */ 41 */
42inline void create_config_dir() 42static void create_config_dir(void)
43{ 43{
44 gchar *config_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, NULL); 44 gchar *config_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, NULL);
45 45
@@ -56,7 +56,7 @@ inline void create_config_dir()
56 * 56 *
57 * @return The string containing the HostID or NULL 57 * @return The string containing the HostID or NULL
58 */ 58 */
59char *get_host_id() 59char *get_host_id(void)
60{ 60{
61 char *host_id = NULL; 61 char *host_id = NULL;
62 gchar *config_file; 62 gchar *config_file;
@@ -92,9 +92,6 @@ int is_device_known(char *uid)
92{ 92{
93 int ret = 0; 93 int ret = 0;
94 gchar *config_file; 94 gchar *config_file;
95 GKeyFile *key_file;
96 gchar **devices_list, **pcur, *keyfilepath, *stored_key;
97 GIOChannel *keyfile;
98 95
99 /* first get config file */ 96 /* first get config file */
100 gchar *device_file = g_strconcat(uid, ".pem", NULL); 97 gchar *device_file = g_strconcat(uid, ".pem", NULL);
@@ -143,7 +140,7 @@ int store_device_public_key(char *uid, gnutls_datum_t public_key)
143 * 140 *
144 * @return 1 if the file contents where read successfully and 0 otherwise. 141 * @return 1 if the file contents where read successfully and 0 otherwise.
145 */ 142 */
146int read_file_in_confdir(char *file, gnutls_datum_t * data) 143static int read_file_in_confdir(const char *file, gnutls_datum_t * data)
147{ 144{
148 gboolean success; 145 gboolean success;
149 gsize size; 146 gsize size;
diff --git a/src/userpref.h b/src/userpref.h
index 450549f..7e606eb 100644
--- a/src/userpref.h
+++ b/src/userpref.h
@@ -28,7 +28,7 @@
28 * 28 *
29 * @return the HostID if exist in config file. Returns NULL otherwise. 29 * @return the HostID if exist in config file. Returns NULL otherwise.
30 */ 30 */
31char *get_host_id(); 31char *get_host_id(void);
32 32
33/** 33/**
34 * Determine if we already paired this device. 34 * Determine if we already paired this device.