OwnCode/HttpFetcher/http-fetcher-orig/HttpFetcher.cpp
/*
 * Changes the User Agent.  Returns 0 on success, -1 on error.
 */
Changes the User Agent.  Returns 0 on success, -1 on error.
Changes the User Agent . Returns 0 on success - 1 on error .
int http_setUserAgent(const char *newAgent)
{
    static int freeOldAgent = 0; 
    char *tmp;
    if (newAgent == NULL) {
        if (freeOldAgent) free(userAgent);
        userAgent = NULL;
        hideUserAgent = 1;
    } else {
        tmp = (char *)malloc(strlen(newAgent));
        if (tmp == NULL) {
            errorSource = ERRNO;
            return -1;
        }
        if (freeOldAgent) free(userAgent);
        userAgent = tmp;
        strcpy(userAgent, newAgent);
        freeOldAgent = 1;
        hideUserAgent = 0;
    }
    return 0;
}
int http_setUserAgent ( const char * newAgent ) { static int freeOldAgent = 0 ; char * tmp ; if ( newAgent == NULL ) { if ( freeOldAgent ) free ( userAgent ) ; userAgent = NULL ; hideUserAgent = 1 ; } else { tmp = ( char * ) malloc ( strlen ( newAgent ) ) ; if ( tmp == NULL ) { errorSource = ERRNO ; return -1 ; } if ( freeOldAgent ) free ( userAgent ) ; userAgent = tmp ; strcpy ( userAgent , newAgent ) ; freeOldAgent = 1 ; hideUserAgent = 0 ; } return 0 ; }
Changes the User Agent.
Changes the User Agent .
/* Indicates previous malloc's */