diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2013-07-08 16:57:59 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-07-08 16:57:59 +0000 |
commit | b838c922272f9fe793a25e5c93423e63273e0cde (patch) | |
tree | 2fc7bae3797f75aac3a7e71490ee11e476b56a23 /src | |
parent | b6ee0d8d5d1cbf1e228f7a8f636ab3c6a7661333 (diff) |
Removed dead code
Diffstat (limited to 'src')
-rw-r--r-- | src/htsback.c | 1 | ||||
-rw-r--r-- | src/htslib.c | 133 | ||||
-rw-r--r-- | src/htslib.h | 5 |
3 files changed, 17 insertions, 122 deletions
diff --git a/src/htsback.c b/src/htsback.c index 54c0637..e9e780e 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -3012,7 +3012,6 @@ void back_wait(struct_back * sback, httrackp * opt, cache_back * cache, } else retour_fread = (int) http_xfread1(&(back[i].r), (int) max_read_bytes); - // retour_fread=http_fread1(&(back[i].r)); } else retour_fread = READ_EOF; // interruption ou annulation interne (peut ne pas être une erreur) diff --git a/src/htslib.c b/src/htslib.c index aac4e25..4e549e4 100644 --- a/src/htslib.c +++ b/src/htslib.c @@ -625,36 +625,6 @@ void hts_init_htsblk(htsblk * r) { r->totalsize = -1; } -// Récupération d'un fichier http sur le net. -// Renvoie une adresse sur le bloc de mémoire, ou bien -// NULL si un retour.msgeur (buffer retour.msg) est survenue. -// -// Une adresse de structure htsmsg peut être transmise pour -// suivre l'évolution du chargement si le process a été lancé -// en background - -htsblk httpget(httrackp * opt, char *url) { - char BIGSTK adr[HTS_URLMAXSIZE * 2]; // adresse - char BIGSTK fil[HTS_URLMAXSIZE * 2]; // chemin - - // séparer URL en adresse+chemin - if (ident_url_absolute(url, adr, fil) == -1) { - htsblk retour; - - hts_init_htsblk(&retour); - //memset(&retour, 0, sizeof(htsblk)); // effacer - // retour prédéfini: erreur - retour.adr = NULL; - retour.size = 0; - retour.msg[0] = '\0'; - retour.statuscode = STATUSCODE_INVALID; - strcpybuff(retour.msg, "Error invalid URL"); - return retour; - } - - return xhttpget(opt, adr, fil); -} - // ouvre une liaison http, envoie une requète GET et réceptionne le header // retour: socket T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour) { @@ -1789,80 +1759,6 @@ HTSEXT_API void infostatuscode(char *msg, int statuscode) { } } -// identique au précédent, sauf que l'on donne adr+fil et non url complète -htsblk xhttpget(httrackp * opt, char *adr, char *fil) { - T_SOC soc; - htsblk retour; - - hts_init_htsblk(&retour); - //memset(&retour, 0, sizeof(htsblk)); - soc = http_fopen(opt, adr, fil, &retour); - - if (soc != INVALID_SOCKET) { - http_fread(soc, &retour); -#if HTS_DEBUG_CLOSESOCK - DEBUG_W("xhttpget: deletehttp\n"); -#endif - if (retour.soc != INVALID_SOCKET) - deletehttp(&retour); // fermer - retour.soc = INVALID_SOCKET; - } - return retour; -} - -// variation sur un thème... -// réceptionne uniquement un en-tête (HEAD) -// retourne dans xx.adr l'adresse pointant sur le bloc de mémoire de l'en tête -htsblk http_gethead(httrackp * opt, char *adr, char *fil) { - T_SOC soc; - htsblk retour; - - hts_init_htsblk(&retour); - //memset(&retour, 0, sizeof(htsblk)); - soc = http_xfopen(opt, 1, 0, 1, NULL, adr, fil, &retour); // HEAD, pas de traitement en-tête - - if (soc != INVALID_SOCKET) { - http_fread(soc, &retour); // réception en-tête -#if HTS_DEBUG_CLOSESOCK - DEBUG_W("http_gethead: deletehttp\n"); -#endif - if (retour.soc != INVALID_SOCKET) - deletehttp(&retour); // fermer - retour.soc = INVALID_SOCKET; - } - return retour; -} - -// oui ca ressemble vachement à xhttpget - en étant sobre on peut voir LA différence.. - -// lecture sur une socket ouverte, le header a déja été envoyé dans le cas de GET -// il ne reste plus qu'à lire les données -// (pour HEAD le header est lu ici!) -void http_fread(T_SOC soc, htsblk * retour) { - //int bufl=TAILLE_BUFFER; // 8Ko de buffer - - if (retour) - retour->soc = soc; - if (soc != INVALID_SOCKET) { - // fonction de lecture d'une socket (plus propre) - while(http_fread1(retour) != -1) ; - soc = retour->soc; - if (retour->adr == NULL) { - if (strnotempty(retour->msg) == 0) - sprintf(retour->msg, "Unable to read"); - return; // erreur - } -#if HDEBUG - printf("Ok, données reçues\n"); -#endif - - return; - - } - - return; -} - // check if data is available int check_readinput(htsblk * r) { if (r->soc != INVALID_SOCKET) { @@ -1905,14 +1801,6 @@ int check_readinput_t(T_SOC soc, int timeout) { return 0; } -// lecture d'un bloc sur une socket (ou un fichier!) -// >=0 : nombre d'octets lus -// <0 : fin ou erreur -HTS_INLINE LLint http_fread1(htsblk * r) { - //int bufl=TAILLE_BUFFER; // taille d'un buffer max. - return http_xfread1(r, TAILLE_BUFFER); -} - // idem, sauf qu'ici on peut choisir la taille max de données à recevoir // SI bufl==0 alors le buffer est censé être de 8kos, et on recoit par bloc de lignes // en éliminant les cr (ex: header), arrêt si double-lf @@ -2383,12 +2271,25 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, // connexion non bloquante? if (!waitconnect) { - unsigned long p = 1; // non bloquant - #ifdef _WIN32 - ioctlsocket(soc, FIONBIO, &p); + unsigned long p = 1; // non bloquant + if (ioctlsocket(soc, FIONBIO, &val)) { + const int last_errno = WSAGetLastError(); + snprintf(retour->msg, sizeof(retour->msg), + "Non-blocking socket failed: %s", strerror(last_errno)); + deletesoc(soc); + return INVALID_SOCKET; + } #else - ioctl(soc, FIONBIO, &p); + const int flags = fcntl(soc, F_GETFL, 0); + unsigned long p = 1; // non bloquant + if (flags == -1 /*|| fcntl(soc, F_SETFL, flags | O_NONBLOCK) == -1*/ + || ioctl(soc, FIONBIO, &p) != 0) { + snprintf(retour->msg, sizeof(retour->msg), + "Non-blocking socket failed: %s", strerror(errno)); + deletesoc(soc); + return INVALID_SOCKET; + } #endif } // Connexion au serveur lui même diff --git a/src/htslib.h b/src/htslib.h index ca9b614..354b4cc 100644 --- a/src/htslib.h +++ b/src/htslib.h @@ -266,7 +266,6 @@ T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect, int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, char *adr, char *fil, char *referer_adr, char *referer_fil, htsblk * retour); -htsblk httpget(httrackp * opt, char *url); //int newhttp(char* iadr,char* err=NULL); T_SOC newhttp(httrackp * opt, const char *iadr, htsblk * retour, int port, @@ -279,8 +278,6 @@ htsblk http_location(httrackp * opt, char *adr, char *fil, char *loc); htsblk http_test(httrackp * opt, char *adr, char *fil, char *loc); int check_readinput(htsblk * r); int check_readinput_t(T_SOC soc, int timeout); -void http_fread(T_SOC soc, htsblk * retour); -LLint http_fread1(htsblk * r); void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour, char *rcvd); void treatfirstline(htsblk * retour, char *rcvd); @@ -290,8 +287,6 @@ HTSEXT_API void infostatuscode(char *msg, int statuscode); #endif // sous-fonctions -htsblk xhttpget(httrackp * opt, char *adr, char *fil); -htsblk http_gethead(httrackp * opt, char *adr, char *fil); LLint http_xfread1(htsblk * r, int bufl); HTS_INLINE t_hostent *hts_gethostbyname2(httrackp * opt, const char *iadr, void *v_buffer, const char **error); |