示例#1
0
int main(int argc, char *argv[])
{
    int i;

    if (argc > 1)
    {
        for (i = 1; i < argc; i++)
        {
            if (argv[i][0] == '-' && argv[i][1] == 's')
                MDString(argv[i] + 2);
            else if (strcmp(argv[i], "-t") == 0)
                MDTimeTrial();
            else if (strcmp(argv[i], "-x") == 0)
                MDTestSuite();
            else
                MDFile(argv[i]);
        }
    }
    else
    {
        MDFilter();
    }

    return (0);
}
示例#2
0
文件: mddriver.c 项目: bcw104/MD5
/* Main driver.

Arguments (may be any combination):
-sstring - digests string
-t       - runs time trial
-ct		 - runs time trial in convert number mode
-x       - runs test script
-h		 - print help info
--help   - print help info
filename - digests file
(none)   - digests standard input
*/
int main (int argc, char *argv[])
{
	if (argc > 1) {
		if (strcmp(argv[1], "-s") == 0) {
			if (argc == 3)
				MDString(argv[2]);
			else
				MDString("");
		} else if (strcmp(argv[1], "-t") == 0)
			//MDTimeTrial();
			MDWordTime();
		else if (strcmp(argv[1], "-ct") == 0)
			MDWordTimeConvert();
		else if (strcmp(argv[1], "-x") == 0)
			MDTestSuite();
		else if (strcmp(argv[1], "-c") == 0)
			MDCrypt("8f14e45fceea167a5a36dedd4bea2543");
		else if (strcmp(argv[1], "-h") == 0)
			PrintInfo();
		else if (strcmp(argv[1], "--help") == 0)
			PrintInfo();
		else
			MDFile(argv[1]);    
	} else
		MDFilter();

	return 0;
}
示例#3
0
/* Main driver.

   Arguments (may be any combination):
     -sstring - digests string
     -t       - runs time trial
     -x       - runs test script
     filename - digests file
     (none)   - digests standard input
 */
int main (int argc, char **argv)
{
    int i;

    apr_initialize();
    atexit(apr_terminate);

    if (apr_pool_create(&local_pool, NULL) != APR_SUCCESS)
        exit(-1);

    apr_file_open_stdin(&in, local_pool); 
    apr_file_open_stdout(&out, local_pool); 
    apr_file_open_stderr(&err, local_pool); 

    if (argc > 1)
    {
        for (i = 1; i < argc; i++)
            if (argv[i][0] == '-' && argv[i][1] == 's')
                MDString(argv[i] + 2);
            else if (strcmp(argv[i], "-t") == 0)
                MDTimeTrial();
            else if (strcmp (argv[i], "-x") == 0)
                MDTestSuite();
            else
                MDFile(argv[i]);
    }
    else
        MDFilter();

    return 0;
}
示例#4
0
文件: mddriver.c 项目: TimLand/datacl
int main (
	int argc,
	char **argv
)
{
  int status = 0;
  int i;

  if (argc > 1) {
    for (i = 1; i < argc; i++)
      if (argv[i][0] == '-' && argv[i][1] == 's') {
	MDString (argv[i] + 2);
}
      else if (strcmp (argv[i], "-t") == 0) {
	MDTimeTrial ();
}j
      else if (strcmp (argv[i], "-x") == 0) {
	MDTestSuite ();
}
      else {
	status = MDFile (argv[i]);
 	conditional_BYE(status);
}
  }
  else {
示例#5
0
int main(int argc, char *argv[])
{
    MDTestSuite();
    return 0;
}
示例#6
0
文件: md5.c 项目: hmatyschok/MeshBSD
/* Main driver.

Arguments (may be any combination):
  -sstring - digests string
  -t       - runs time trial
  -x       - runs test script
  filename - digests file
  (none)   - digests standard input
 */
int
main(int argc, char *argv[])
{
	int	ch;
	char   *p;
	char	buf[HEX_DIGEST_LENGTH];
	int	failed;
 	unsigned	digest;
 	const char*	progname;

 	if ((progname = strrchr(argv[0], '/')) == NULL)
 		progname = argv[0];
 	else
 		progname++;

 	for (digest = 0; digest < sizeof(Algorithm)/sizeof(*Algorithm); digest++)
 		if (strcasecmp(Algorithm[digest].progname, progname) == 0)
 			break;

 	if (digest == sizeof(Algorithm)/sizeof(*Algorithm))
 		digest = 0;

	failed = 0;
	checkAgainst = NULL;
	checksFailed = 0;
	while ((ch = getopt(argc, argv, "c:pqrs:tx")) != -1)
		switch (ch) {
		case 'c':
			checkAgainst = optarg;
			break;
		case 'p':
			MDFilter(&Algorithm[digest], 1);
			break;
		case 'q':
			qflag = 1;
			break;
		case 'r':
			rflag = 1;
			break;
		case 's':
			sflag = 1;
			MDString(&Algorithm[digest], optarg);
			break;
		case 't':
			MDTimeTrial(&Algorithm[digest]);
			break;
		case 'x':
			MDTestSuite(&Algorithm[digest]);
			break;
		default:
			usage(&Algorithm[digest]);
		}
	argc -= optind;
	argv += optind;

	if (*argv) {
		do {
			p = Algorithm[digest].File(*argv, buf);
			if (!p) {
				warn("%s", *argv);
				failed++;
			} else {
				if (qflag)
					printf("%s", p);
				else if (rflag)
					printf("%s %s", p, *argv);
				else
					printf("%s (%s) = %s",
					    Algorithm[digest].name, *argv, p);
				if (checkAgainst && strcmp(checkAgainst,p))
				{
					checksFailed++;
					if (!qflag)
						printf(" [ Failed ]");
				}
				printf("\n");
			}
		} while (*++argv);
	} else if (!sflag && (optind == 1 || qflag || rflag))
		MDFilter(&Algorithm[digest], 0);

	if (failed != 0)
		return (1);
	if (checksFailed != 0)
		return (2);

	return (0);
}