--- tshark.c.ori 2007-05-27 17:20:05.000000000 +0200 +++ tshark.c 2007-05-28 13:06:00.000000000 +0200 @@ -261,6 +261,7 @@ fprintf(output, "\n"); fprintf(output, "Processing:\n"); fprintf(output, " -R packet filter in Wireshark display filter syntax\n"); + fprintf(output, " -A file Use file as input for the Wireshark 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); @@ -695,8 +696,9 @@ GLogLevelFlags log_flags; int status; int optind_initial; + FILE *fp; -#define OPTSTRING_INIT "a:b:c:d:Df:F:G:hi:lLnN:o:pqr:R:s:St:T:vVw:xX:y:z:" +#define OPTSTRING_INIT "a:A:b:c:d:Df:F:G:hi:lLnN:o:pqr:R:s:St:T:vVw:xX:y:z:" #ifdef HAVE_LIBPCAP #ifdef _WIN32 #define OPTSTRING_WIN32 "B:" @@ -1022,6 +1024,30 @@ 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) ) + { + if(!strncmp(line,"#",1)) + { + //cmdarg_err("line= %s", line); /* debug */ + continue; + } + 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;