--- tethereal.c.ori 2006-07-08 14:31:50.000000000 +0200 +++ tethereal.c 2006-09-23 22:37:56.000000000 +0200 @@ -261,6 +261,7 @@ fprintf(output, "\n"); fprintf(output, "Processing:\n"); fprintf(output, " -R packet filter in Ethereal display filter syntax\n"); + fprintf(output, " -A file Use file as input for the Ethereal display filter syntax\n"); fprintf(output, " -n disable all name resolutions (def: all enabled)\n"); fprintf(output, " -N enable specific name resolution(s): \"mntC\"\n"); fprintf(output, " -d %s ...\n", decode_as_arg_template); @@ -693,8 +694,9 @@ char badopt; GLogLevelFlags log_flags; int status; + FILE *fp; -#define OPTSTRING_INIT "a:b:c:d:Df:F:hi:lLnN:o:pqr:R:s:St:T:vVw:xX:y:z:" +#define OPTSTRING_INIT "a:A:b:c:d:Df:F:hi:lLnN:o:pqr:R:s:St:T:vVw:xX:y:z:" #ifdef HAVE_LIBPCAP #ifdef _WIN32 #define OPTSTRING_WIN32 "B:" @@ -987,7 +989,27 @@ case 'r': /* Read capture file xxx */ cf_name = g_strdup(optarg); break; + case 'A': /* Read file filter syntax */ + fp = fopen(g_strdup(optarg), "r"); + if (! fp) { + cmdarg_err("file not found: %s", optarg); + exit(1); + } + char line[32768], line2[32768]; + strcat(line2,"( "); + while( fgets(line, sizeof(line), fp) ) + { + strncat(line2,line,strlen(line)-1); /* remove carriage return */ + strcat(line2," ) or ( "); + } + fclose(fp); + strcpy(line,""); + strncat(line,line2,strlen(line2)-6); /* remove ' or ( '*/ + cmdarg_err("load filter= %s", line); /* debug */ + rfilter = line; + break; case 'R': /* Read file filter */ rfilter = optarg; break; case 'S': /* show packets in real time */