int main() { printf("Hello from main.c\n"); call_external(); return 0; }
PRIVATE int8_t addTorrentToTM(const auto_handle *ah, const void* t_data, uint32_t t_size, const char *fname, const char *folder) { int8_t success = -1; torrent_id_t tid; char url[MAX_URL_LEN]; if (!ah->use_transmission) { if(saveFile(fname, t_data, t_size) == 0) { success = 1; } else { success = -1; } } else if(ah->transmission_version == AM_TRANSMISSION_EXTERNAL) { /* transmssion version set to external */ if (saveFile(fname, t_data, t_size) == 0) { if (call_external(ah->transmission_external, fname) != 0) { dbg_printf(P_ERROR, "[addTorrentToTM] %s: Error adding torrent to Transmission-external", fname); success = -1; } else { success = 1; } unlink(fname); } else { success = -1; } } else if (ah->transmission_version == AM_TRANSMISSION_1_2) { if (saveFile(fname, t_data, t_size) == 0) { if (call_transmission(ah->transmission_path, fname) == -1) { dbg_printf(P_ERROR, "[addTorrentToTM] %s: Error adding torrent to Transmission", fname); } else { success = 1; } unlink(fname); } } else if (ah->transmission_version == AM_TRANSMISSION_1_3) { snprintf( url, MAX_URL_LEN, "http://%s:%d/transmission/rpc", (ah->host != NULL) ? ah->host : AM_DEFAULT_HOST, ah->rpc_port); tid = uploadTorrent(t_data, t_size, url, ah->auth, ah->start_torrent, folder); if(tid > 0) { /* tid > 0: torrent ID --> torrent was added to TM */ success = 1; if(ah->upspeed > 0) { changeUploadSpeed(url, ah->auth, tid, ah->upspeed, ah->rpc_version); } } else if(tid == 0) { /* duplicate torrent */ success = 0; } else { /* torrent was not added */ success = -1; } } return success; }