#! /bin/sh /usr/share/dpatch/dpatch-run ## 99_axel-user-agent.dpatch by feanor (http://kldp.org/node/91234) ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Add -U and --user-agent options to specify user-agent ## DP: from the command line. @DPATCH@ diff -urNad axel-1.1.orig/conf.c axel-1.1/conf.c --- axel-1.1.orig/conf.c 2008-02-22 02:53:34.000000000 +0900 +++ axel-1.1/conf.c 2008-02-22 02:55:57.000000000 +0900 @@ -138,6 +138,8 @@ conf->search_amount = 15; conf->search_top = 3; + strncpy( conf->user_agent, USER_AGENT, MAX_STRING ); + conf->interfaces = malloc( sizeof( if_t ) ); memset( conf->interfaces, 0, sizeof( if_t ) ); conf->interfaces->next = conf->interfaces; diff -urNad axel-1.1.orig/conf.h axel-1.1/conf.h --- axel-1.1.orig/conf.h 2008-02-22 02:53:09.000000000 +0900 +++ axel-1.1/conf.h 2008-02-22 02:53:27.000000000 +0900 @@ -44,6 +44,8 @@ int search_threads; int search_amount; int search_top; + + char user_agent[MAX_STRING]; } conf_t; int conf_loadfile( conf_t *conf, char *file ); diff -urNad axel-1.1.orig/conn.c axel-1.1/conn.c --- axel-1.1.orig/conn.c 2008-02-22 03:02:07.000000000 +0900 +++ axel-1.1/conn.c 2008-02-22 03:10:27.000000000 +0900 @@ -255,7 +255,7 @@ snprintf( s, MAX_STRING, "%s%s", conn->dir, conn->file ); conn->http->firstbyte = conn->currentbyte; conn->http->lastbyte = conn->lastbyte; - http_get( conn->http, s ); + http_get( conn->http, s, conn->conf->user_agent ); } return( 1 ); } diff -urNad axel-1.1.orig/http.h axel-1.1/http.h --- axel-1.1.orig/http.h 2002-01-25 08:18:23.000000000 -0600 +++ axel-1.1/http.h 2008-02-22 02:15:05.000000000 -0600 @@ -42,7 +42,7 @@ int http_connect( http_t *conn, int proto, char *proxy, char *host, int port, char *user, char *pass ); void http_disconnect( http_t *conn ); -void http_get( http_t *conn, char *lurl ); +void http_get( http_t *conn, char *lurl, char *user_agent ); void http_addheader( http_t *conn, char *format, ... ); int http_exec( http_t *conn ); char *http_header( http_t *conn, char *header ); diff -urNad axel-1.1.orig/http.c axel-1.1/http.c --- axel-1.1.orig/http.c 2008-02-22 03:03:27.000000000 +0900 +++ axel-1.1/http.c 2008-02-22 03:11:24.000000000 +0900 @@ -90,7 +90,7 @@ conn->fd = -1; } -void http_get( http_t *conn, char *lurl ) +void http_get( http_t *conn, char *lurl, char *user_agent ) { *conn->request = 0; if( conn->proxy ) @@ -103,7 +103,7 @@ http_addheader( conn, "GET %s HTTP/1.0", lurl ); http_addheader( conn, "Host: %s", conn->host ); } - http_addheader( conn, "User-Agent: %s", USER_AGENT ); + http_addheader( conn, "User-Agent: %s", user_agent ); if( *conn->auth ) http_addheader( conn, "Authorization: Basic %s", conn->auth ); if( conn->firstbyte ) diff -urNad axel-1.1.orig/text.c axel-1.1/text.c --- axel-1.1.orig/text.c 2008-02-22 02:51:04.000000000 +0900 +++ axel-1.1/text.c 2008-02-22 03:23:46.000000000 +0900 @@ -52,6 +52,7 @@ { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "alternate", 0, NULL, 'a' }, + { "user-agent", 1, NULL, 'U' }, { NULL, 0, NULL, 0 } }; #endif @@ -88,7 +89,7 @@ { int option; - option = getopt_long( argc, argv, "s:n:o:S::NqvhHVa", axel_options, NULL ); + option = getopt_long( argc, argv, "s:n:o:S::NqvhHVaU:", axel_options, NULL ); if( option == -1 ) break; @@ -147,6 +148,9 @@ return( 1 ); } break; + case 'U': + strncpy( conf->user_agent, optarg, MAX_STRING ); + break; default: print_help(); return( 1 ); @@ -537,6 +541,7 @@ "--quiet\t\t\t-q\tLeave stdout alone\n" "--verbose\t\t-v\tMore status information\n" "--alternate\t\t-a\tAlternate progress indicator\n" + "--user-agent\t\t-U x\tSpecify user agent\n" "--help\t\t\t-h\tThis information\n" "--version\t\t-V\tVersion information\n" "\n"