diff options
Diffstat (limited to 'src/afc.c')
| -rw-r--r-- | src/afc.c | 42 |
1 files changed, 21 insertions, 21 deletions
| @@ -611,7 +611,7 @@ afc_error_t afc_remove_path(afc_client_t client, const char *path) | |||
| 611 | */ | 611 | */ |
| 612 | afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to) | 612 | afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to) |
| 613 | { | 613 | { |
| 614 | char *send = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); | 614 | char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); |
| 615 | uint32_t bytes = 0; | 615 | uint32_t bytes = 0; |
| 616 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 616 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| 617 | 617 | ||
| @@ -621,10 +621,10 @@ afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *t | |||
| 621 | afc_lock(client); | 621 | afc_lock(client); |
| 622 | 622 | ||
| 623 | /* Send command */ | 623 | /* Send command */ |
| 624 | memcpy(send, from, strlen(from) + 1); | 624 | memcpy(buffer, from, strlen(from) + 1); |
| 625 | memcpy(send + strlen(from) + 1, to, strlen(to) + 1); | 625 | memcpy(buffer + strlen(from) + 1, to, strlen(to) + 1); |
| 626 | ret = afc_dispatch_packet(client, AFC_OP_RENAME_PATH, send, strlen(to)+1 + strlen(from)+1, NULL, 0, &bytes); | 626 | ret = afc_dispatch_packet(client, AFC_OP_RENAME_PATH, buffer, strlen(to)+1 + strlen(from)+1, NULL, 0, &bytes); |
| 627 | free(send); | 627 | free(buffer); |
| 628 | 628 | ||
| 629 | if (ret != AFC_E_SUCCESS) { | 629 | if (ret != AFC_E_SUCCESS) { |
| 630 | afc_unlock(client); | 630 | afc_unlock(client); |
| @@ -1101,7 +1101,7 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new | |||
| 1101 | */ | 1101 | */ |
| 1102 | afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize) | 1102 | afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize) |
| 1103 | { | 1103 | { |
| 1104 | char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); | 1104 | char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); |
| 1105 | uint32_t bytes = 0; | 1105 | uint32_t bytes = 0; |
| 1106 | uint64_t size_requested = htole64(newsize); | 1106 | uint64_t size_requested = htole64(newsize); |
| 1107 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1107 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| @@ -1112,10 +1112,10 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize | |||
| 1112 | afc_lock(client); | 1112 | afc_lock(client); |
| 1113 | 1113 | ||
| 1114 | /* Send command */ | 1114 | /* Send command */ |
| 1115 | memcpy(send, &size_requested, 8); | 1115 | memcpy(buffer, &size_requested, 8); |
| 1116 | memcpy(send + 8, path, strlen(path) + 1); | 1116 | memcpy(buffer + 8, path, strlen(path) + 1); |
| 1117 | ret = afc_dispatch_packet(client, AFC_OP_TRUNCATE, send, 8 + strlen(path) + 1, NULL, 0, &bytes); | 1117 | ret = afc_dispatch_packet(client, AFC_OP_TRUNCATE, buffer, 8 + strlen(path) + 1, NULL, 0, &bytes); |
| 1118 | free(send); | 1118 | free(buffer); |
| 1119 | 1119 | ||
| 1120 | if (ret != AFC_E_SUCCESS) { | 1120 | if (ret != AFC_E_SUCCESS) { |
| 1121 | afc_unlock(client); | 1121 | afc_unlock(client); |
| @@ -1141,7 +1141,7 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize | |||
| 1141 | */ | 1141 | */ |
| 1142 | afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname) | 1142 | afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname) |
| 1143 | { | 1143 | { |
| 1144 | char *send = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); | 1144 | char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); |
| 1145 | uint32_t bytes = 0; | 1145 | uint32_t bytes = 0; |
| 1146 | uint64_t type = htole64(linktype); | 1146 | uint64_t type = htole64(linktype); |
| 1147 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1147 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| @@ -1156,11 +1156,11 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c | |||
| 1156 | debug_info("linkname: %s, length:%d", linkname, strlen(linkname)); | 1156 | debug_info("linkname: %s, length:%d", linkname, strlen(linkname)); |
| 1157 | 1157 | ||
| 1158 | /* Send command */ | 1158 | /* Send command */ |
| 1159 | memcpy(send, &type, 8); | 1159 | memcpy(buffer, &type, 8); |
| 1160 | memcpy(send + 8, target, strlen(target) + 1); | 1160 | memcpy(buffer + 8, target, strlen(target) + 1); |
| 1161 | memcpy(send + 8 + strlen(target) + 1, linkname, strlen(linkname) + 1); | 1161 | memcpy(buffer + 8 + strlen(target) + 1, linkname, strlen(linkname) + 1); |
| 1162 | ret = afc_dispatch_packet(client, AFC_OP_MAKE_LINK, send, 8 + strlen(linkname) + 1 + strlen(target) + 1, NULL, 0, &bytes); | 1162 | ret = afc_dispatch_packet(client, AFC_OP_MAKE_LINK, buffer, 8 + strlen(linkname) + 1 + strlen(target) + 1, NULL, 0, &bytes); |
| 1163 | free(send); | 1163 | free(buffer); |
| 1164 | if (ret != AFC_E_SUCCESS) { | 1164 | if (ret != AFC_E_SUCCESS) { |
| 1165 | afc_unlock(client); | 1165 | afc_unlock(client); |
| 1166 | return AFC_E_NOT_ENOUGH_DATA; | 1166 | return AFC_E_NOT_ENOUGH_DATA; |
| @@ -1184,7 +1184,7 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c | |||
| 1184 | */ | 1184 | */ |
| 1185 | afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime) | 1185 | afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime) |
| 1186 | { | 1186 | { |
| 1187 | char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); | 1187 | char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); |
| 1188 | uint32_t bytes = 0; | 1188 | uint32_t bytes = 0; |
| 1189 | uint64_t mtime_loc = htole64(mtime); | 1189 | uint64_t mtime_loc = htole64(mtime); |
| 1190 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1190 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| @@ -1195,10 +1195,10 @@ afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mt | |||
| 1195 | afc_lock(client); | 1195 | afc_lock(client); |
| 1196 | 1196 | ||
| 1197 | /* Send command */ | 1197 | /* Send command */ |
| 1198 | memcpy(send, &mtime_loc, 8); | 1198 | memcpy(buffer, &mtime_loc, 8); |
| 1199 | memcpy(send + 8, path, strlen(path) + 1); | 1199 | memcpy(buffer + 8, path, strlen(path) + 1); |
| 1200 | ret = afc_dispatch_packet(client, AFC_OP_SET_FILE_TIME, send, 8 + strlen(path) + 1, NULL, 0, &bytes); | 1200 | ret = afc_dispatch_packet(client, AFC_OP_SET_FILE_TIME, buffer, 8 + strlen(path) + 1, NULL, 0, &bytes); |
| 1201 | free(send); | 1201 | free(buffer); |
| 1202 | if (ret != AFC_E_SUCCESS) { | 1202 | if (ret != AFC_E_SUCCESS) { |
| 1203 | afc_unlock(client); | 1203 | afc_unlock(client); |
| 1204 | return AFC_E_NOT_ENOUGH_DATA; | 1204 | return AFC_E_NOT_ENOUGH_DATA; |
