Skip to content

Commit

Permalink
Allow to disable warnings from command line in yarac
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Nov 28, 2013
1 parent d8bbf79 commit 6c43287
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions yarac.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ limitations under the License.
#endif


int show_warnings = TRUE;


void show_help()
{
printf("usage: yarac [OPTION]... [RULE_FILE]... OUTPUT_FILE\n");
printf("options:\n");
printf(" -d <identifier>=<value> define external variable.\n");
printf(" -w disable warnings.\n");
printf(" -v show version information.\n");
printf("\nReport bugs to: <%s>\n", PACKAGE_BUGREPORT);
}
Expand Down Expand Up @@ -74,14 +78,18 @@ int process_cmd_line(
char c;
opterr = 0;

while ((c = getopt (argc, (char**) argv, "vd:")) != -1)
while ((c = getopt (argc, (char**) argv, "wvd:")) != -1)
{
switch (c)
{
case 'v':
printf("%s\n", PACKAGE_STRING);
return 0;

case 'w':
show_warnings = FALSE;
break;

case 'd':
equal_sign = strchr(optarg, '=');

Expand Down Expand Up @@ -142,9 +150,14 @@ void report_error(
const char* message)
{
if (error_level == YARA_ERROR_LEVEL_ERROR)
{
fprintf(stderr, "%s(%d): error: %s\n", file_name, line_number, message);
}
else
fprintf(stderr, "%s(%d): warning: %s\n", file_name, line_number, message);
{
if (show_warnings)
fprintf(stderr, "%s(%d): warning: %s\n", file_name, line_number, message);
}
}


Expand Down

0 comments on commit 6c43287

Please sign in to comment.