示例#1
0
int
main(int argc, char **argv)
{
	GDBM_FILE dbf;
	datum key, next, value;
	int i;

	while ((i = getopt(argc, argv, "py")) != -1) {
		switch (i) {
		case 'p':
			pflag = 1;
			break;
		case 'y':
			yflag = 1;
			break;
		default:
			fprintf(stderr, "Usage: %s [-p] [-y] file [...]\n",
				strchr(argv[0], '/') ?
				strrchr(argv[0], '/') + 1 : argv[0]);
			return 1;
			break;
		}
	}
	for (i = optind; i < argc; i++) {
		dbf = gdbm_open(argv[i], 0, GDBM_READER, 0600, NULL);
		if (dbf == NULL) {
			fprintf(stderr, "Error opening `%s': %s\n", argv[i],
				gdbm_errno ? gdbm_strerror(gdbm_errno) :
				strerror(errno));
			return 1;
		}
		dump_start(argc - optind, argv[i]);
		key = gdbm_firstkey(dbf);
		while (key.dptr != NULL) {
			value = gdbm_fetch(dbf, key);
			if (value.dptr != NULL) {
				dump_entry(key, value);
				free(value.dptr);
			}
			next = gdbm_nextkey(dbf, key);
			free(key.dptr);
			key = next;
		}
		dump_end();
		gdbm_close(dbf);
	}
	return 0;
}
示例#2
0
文件: petool.cpp 项目: analyst004/pe
int main(int argc, char* argv[])
{
  if (argc!=2) {
    show_usage();
    return 0;
  }

  //while(true) {
  MAPPED_FILE view = {0};
  if( 0 != map_file( argv[1], &view ) ) {
    printf( "open file failed: %s\n", argv[2]);
    return -1;
  }

  int pe = pe_open((const char*)view.data, view.size);
  if (pe == INVALID_PE) {
    printf( "file is not pe format");
    return -1;
  }

  dump_entry(pe);
  dump_version(pe);
  dump_section(pe);
  dump_export(pe);
  dump_import(pe);
  dump_overlay(pe);
  dump_resource(pe);

  char path[256] = {0};
  strcat(getcwd(path, sizeof(path) - 1), "\\sample.ico");
  dump_icon(pe, path);

  pe_close(pe);

  unmap_file(&view);
  //}
 
  system("pause");
  return 0;
}
示例#3
0
/*
 * list [displayname ...]
 */
static int
do_list (const char *inputfilename, int lineno, int argc, const char **argv)
{
    struct _list_data ld;

    ld.fp = stdout;
    ld.numeric = (argv[0][0] == 'n');

    if (argc == 1) {
	register AuthList *l;

	if (xauth_head) {
	    for (l = xauth_head; l; l = l->next) {
		dump_entry (inputfilename, lineno, l->auth, (char *) &ld);
	    }
	}
	return 0;
    }

    return iterdpy (inputfilename, lineno, 1, argc, argv,
		    dump_entry, NULL, (char *) &ld);
}
static int dump_section (FILE * f, struct ConfigVTable * h, SectionHandle s, unsigned
      int indent)
{
   unsigned int sectionsize;
   size_t count;
   unsigned int i;
   int ret = 1;
   SectionEntry * entries = 0;

   ret = mymin (ret, cf_getSectionSize (h, s, &sectionsize));
   if (ret < 0)
      return ret;

   count = sectionsize;
  
   entries = (SectionEntry*)malloc (sizeof (SectionEntry) * sectionsize);

   ret = mymin(ret, cf_listSection (h, s, &entries[0], &count));

   if (ret < 0)
      goto fail;

   assert(sectionsize == count);

   for (i=0; i<count; ++i)
   {
      show_indent (f,indent);
      if (ret >= 0)
      {
         ret = mymin (ret, dump_entry (f, h, s, indent, &entries[i]));
      }
      free ((void*)entries[i].name);
   }

fail:
   free (entries);
   return ret;
}
示例#5
0
文件: btrace.c 项目: 0xffea/MINIX3
static void btrace_dump(char *file)
{
  int i, r, infd;

  if ((infd = open(file, O_RDONLY)) < 0) {
	perror("open");
	exit(EXIT_FAILURE);
  }

  for (;;) {
	if ((r = read(infd, (char *) buf, sizeof(buf))) <= 0)
		break;

	r /= sizeof(buf[0]);

	for (i = 0; i < r; i++)
		dump_entry(&buf[i]);
  }

  if (r < 0) perror("read");

  close(infd);
}
示例#6
0
文件: newlems2.c 项目: HCMID/morpheus
is_verb(char *stem)
{
	if( !strcmp(stem+strlen(stem)-4,"eu/w") ) {
		dump_entry(stem,4,"euw",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-7,"eu/omai") ) {
		dump_entry(stem,7,"euw mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-4,"u/nw") ) {
		dump_entry(stem,4,"unw",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-7,"u/nomai") ) {
		dump_entry(stem,7,"unw mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-3,"e/w") ) {
		dump_entry(stem,3,"ew_denom",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-6,"e/omai") ) {
		dump_entry(stem,6,"ew_denom mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-3,"o/w") ) {
		dump_entry(stem,3,"ow_denom",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-6,"o/omai") ) {
		dump_entry(stem,6,"ow_denom mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-4,"u/zw") ) {
		dump_entry(stem,4,"uzw",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-7,"u/zomai") ) {
		dump_entry(stem,7,"uzw mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-4,"i/zw") ) {
		dump_entry(stem,4,"izw",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-7,"i/zomai") ) {
		dump_entry(stem,7,"izw mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-6,"ssomai") ) {
		dump_entry(stem,6,"ss mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-3,"ssw") ) {
		dump_entry(stem,3,"ss",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-4,"a/zw") ) {
		dump_entry(stem,4,"azw",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-7,"a/zomai") ) {
		dump_entry(stem,7,"azw mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-4,"ia/w") ) {
		dump_entry(stem,4,"iaw_denom",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-7,"ia/omai") ) {
		dump_entry(stem,7,"iaw_denom mp",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-3,"a/w") ) {
		dump_entry(stem,3,"aw_denom",":de:",fverbs);	
		return(1);
	}

	if( !strcmp(stem+strlen(stem)-6,"a/omai") ) {
		dump_entry(stem,6,"aw_denom mp",":de:",fverbs);	
		return(1);
	}

	return(0);
}
示例#7
0
文件: newlems2.c 项目: HCMID/morpheus
int dump_nom(char *stem,int trunc, char * tags)
{

	return(dump_entry(stem,trunc,tags,":no:",stdout));
}
示例#8
0
文件: newlems2.c 项目: HCMID/morpheus
int dump_adj(char *stem,int trunc, char * tags)
{

	return(dump_entry(stem,trunc,tags,":aj:",stdout));
}