示例#1
0
int
main(int argc, char **argv) {

	++argv, --argc;

	init_globals();

	if(argc <= 0) {
		yyin = stdin;
		proc_file();
	}
	else {
		for( ; argc > 0; ++argv, --argc ) {
			if( (yyin = fopen( argv[0], "r")) == NULL) {
				perror(argv[0]);
				continue;
			}
			proc_file();
			fclose(yyin);
		}
	}
		
	display_report(1);
	display_report(2);
	
	bistree_destroy(&tree);	

	return(0);
};
示例#2
0
  // Salt python path with the current executable path of the /proc filesystem
  // is available.
static QString getBasePath (void)
{ 
  int pid = getpid();
  QString proc_name = QString("/proc/%1/exe").arg(pid);
  QString base_path;
  QFile proc_file(proc_name);
  if (proc_file.exists ())
    {
      QFileInfo info(proc_name);
      if (info.isSymLink ())
	{
	  QString link_target = info.symLinkTarget();
	  QString compilation_path = link_target.section ('/', -2, -2);
	  if (compilation_path == ".libs")
	    {
	      base_path += link_target.section('/', 0, -3);
	    }
	  else
	    {
	      base_path += link_target.section('/', 0, -2);
	      base_path += "/../lib/rfgis";
	    }
	}
    }
  return base_path;
}
示例#3
0
int read_execpath (pid_t pid, char * path)
{
	ssize_t nb = 0;
	std::string proc_file("/proc/");
	std::stringstream out;
	
	out << (double) pid;
	proc_file += out.str() + "/exe";
	
	
	if((nb = readlink(proc_file.c_str(), path, PATH_MAX)) <= 0) {
		return 1;
	}
	path[nb] = '\0';
	return nb;
}
示例#4
0
/**
 * file name walk callback.  Walk the contents of each file 
 * that is found.
 */
static TSK_WALK_RET_ENUM
dir_act(TSK_FS_FILE * fs_file, const char *path, void *ptr)
{
	fprintf(stdout,
		"file systems file name: %s\n", fs_file->name->name);

    /* Ignore NTFS System files */
    if ((TSK_FS_TYPE_ISNTFS(fs_file->fs_info->ftype))
        && (fs_file->name->name[0] == '$'))
        return TSK_WALK_CONT;

    /* If the name has corresponding metadata, then walk it */
    if (fs_file->meta) {
        proc_file(fs_file, path);
    }

    return TSK_WALK_CONT;
}
示例#5
0
/* Returns:
 * CFG_KEY_FOUND: key retrieved
 * CFG_KEY_NOT_FOUND: key not found
 * CFG_MISC_ERROR: misc error
 * CFG_FILE_OPEN_ERROR: file not opened
 * CFG_INVALID_FILE_PERMS: invalid file permissions
 */
int
parse_key_file(char *filename, cfg_file_key_handler cfk_service, void *user_data)
{
int result = CFG_KEY_FOUND;
FILE *fp;

fp = fopen(filename, "r");
if (!fp)
	{
	result = CFG_FILE_OPEN_ERROR;
	}
else
	{
	result = proc_file(fp, cfk_service, user_data);
	fclose(fp);
	}

return result;
}
示例#6
0
文件: fips_aesavs.c 项目: sqs/openssl
/*--------------------------------------------------
  Processes either a single file or 
  a set of files whose names are passed in a file.
  A single file is specified as:
    aes_test -f xxx.req
  A set of files is specified as:
    aes_test -d xxxxx.xxx
  The default is: -d req.txt
--------------------------------------------------*/
int main(int argc, char **argv)
    {
    char *rqlist = "req.txt", *rspfile = NULL;
    FILE *fp = NULL;
    char fn[250] = "", rfn[256] = "";
    int f_opt = 0, d_opt = 1;
    fips_algtest_init();

    if (argc > 1)
	{
	if (strcasecmp(argv[1], "-d") == 0)
	    {
	    d_opt = 1;
	    }
	else if (strcasecmp(argv[1], "-f") == 0)
	    {
	    f_opt = 1;
	    d_opt = 0;
	    }
	else
	    {
	    printf("Invalid parameter: %s\n", argv[1]);
	    return 0;
	    }
	if (argc < 3)
	    {
	    printf("Missing parameter\n");
	    return 0;
	    }
	if (d_opt)
	    rqlist = argv[2];
	else
	    {
	    strcpy(fn, argv[2]);
	    rspfile = argv[3];
	    }
	}
    if (d_opt)
	{ /* list of files (directory) */
	if (!(fp = fopen(rqlist, "r")))
	    {
	    printf("Cannot open req list file\n");
	    return -1;
	    }
	while (fgets(fn, sizeof(fn), fp))
	    {
	    strtok(fn, "\r\n");
	    strcpy(rfn, fn);
	    if (VERBOSE)
		printf("Processing: %s\n", rfn);
	    if (proc_file(rfn, rspfile))
		{
		printf(">>> Processing failed for: %s <<<\n", rfn);
		EXIT(1);
		}
	    }
	fclose(fp);
	}
    else /* single file */
	{
	if (VERBOSE)
	    printf("Processing: %s\n", fn);
	if (proc_file(fn, rspfile))
	    {
	    printf(">>> Processing failed for: %s <<<\n", fn);
	    }
	}
    EXIT(0);
    return 0;
    }
示例#7
0
/*
 ****************************************************************
 *	Informa sobre o uso de disco				*
 ****************************************************************
 */
int
main (int argc, const char *argv[])
{
	int		opt;

	/*
	 *	Analisa as opções.
	 */
	while ((opt = getopt (argc, argv, "damb:.sp:P:vgNH")) != EOF)
	{
		switch (opt)
		{
		    case 'd':			/* Somente total */
			dflag++;
			break;

		    case 'a':			/* Para cada arquivo */
			aflag++;
			break;

		    case 'm':			/* Em MB */
			mflag++;
			break;

		    case 'b':			/* Tamanho do bloco */
			blkmask = getintmask (optarg);
			blkmask_given++;
			break;

		    case '.':			/* Não ignora ".old" ... */
			dotflag++;
			break;

		    case 's':			/* Padrões = 	*.[cshryv] e */
			put_s_option ();
			break;

		    case 'p':		/* Padrões de inclusão */
			put_p_option ((char *)optarg, inc_pat, &inc_pati);
			break;

		    case 'P':		/* Padrões de exclusão */
			put_p_option ((char *)optarg, exc_pat, &exc_pati);
			break;

		    case 'v':			/* Verbose */
			vflag++;
			break;

		    case 'g':			/* Debug */
			gflag++;
			break;

		    case 'N':			/* Nomes do <stdin> */
			Nflag++;
			break;

		    case 'H':			/* Help */
			help ();

		    default:			/* Erro */
			fputc ('\n', stderr);
			help ();

		}	/* end switch */

	}	/* end while */

	argv += optind;

	printf (du_title, mflag ? "MB" : "KB");

	/*
	 *	Analisa as <árvores>
	 */
	if (*argv == NOSTR) 		/* Não foram dadas <árvores> */
	{
		if (Nflag)
		{
			char		*area = alloca (512);

			while (fngets (area, 512, stdin) != NOSTR)
				proc_file (area);
		}
		else
		{
			proc_file (".");
		}
	}
	else				/* Foram dadas <árvores> */
	{
		if (Nflag)
		{
			char		*area = alloca (512);

			error ("Os argumentos supérfluos serão ignorados");

			while (fngets (area, 512, stdin) != NOSTR)
				proc_file (area);
		}
		else
		{
			for (/* vazio */; *argv; argv++)
				proc_file (*argv);
		}
	}

	/*
	 *	Se foram dados mais de uma <árvore>, dá o total geral
	 */
	if (files > 1)
		printf (du_fmt, edit_sz_value (TOTAL), "TOTAL");

	return (ret);

}	/* end du */
示例#8
0
/*--------------------------------------------------
  Processes either a single file or 
  a set of files whose names are passed in a file.
  A single file is specified as:
    aes_test -f xxx.req
  A set of files is specified as:
    aes_test -d xxxxx.xxx
  The default is: -d req.txt
--------------------------------------------------*/
int main(int argc, char **argv)
    {
    char *rqlist = "req.txt";
    FILE *fp = NULL;
    char fn[250] = "", rfn[256] = "";
    int f_opt = 0, d_opt = 1;

#ifdef OPENSSL_FIPS
    if(!FIPS_mode_set(1))
	{
	ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE));
	EXIT(1);
	}
#endif
    ERR_load_crypto_strings();
    if (argc > 1)
	{
	if (strcasecmp(argv[1], "-d") == 0)
	    {
	    d_opt = 1;
	    }
	else if (strcasecmp(argv[1], "-f") == 0)
	    {
	    f_opt = 1;
	    d_opt = 0;
	    }
	else
	    {
	    printf("Invalid parameter: %s\n", argv[1]);
	    return 0;
	    }
	if (argc < 3)
	    {
	    printf("Missing parameter\n");
	    return 0;
	    }
	if (d_opt)
	    rqlist = argv[2];
	else
	    strcpy(fn, argv[2]);
	}
    if (d_opt)
	{ /* list of files (directory) */
	if (!(fp = fopen(rqlist, "r")))
	    {
	    printf("Cannot open req list file\n");
	    return -1;
	    }
	while (fgets(fn, sizeof(fn), fp))
	    {
	    strtok(fn, "\r\n");
	    strcpy(rfn, fn);
	    printf("Processing: %s\n", rfn);
	    if (proc_file(rfn))
		{
		printf(">>> Processing failed for: %s <<<\n", rfn);
		EXIT(1);
		}
	    }
	fclose(fp);
	}
    else /* single file */
	{
	printf("Processing: %s\n", fn);
	if (proc_file(fn))
	    {
	    printf(">>> Processing failed for: %s <<<\n", fn);
	    }
	}
    EXIT(0);
    return 0;
    }