Ejemplo n.º 1
0
static void build_code(char *str)
{
  char *args[] = {"as", "--32", SFILE_WRITE, "-o", BFILE_WRITE, NULL};
  Elf32_Ehdr  *aspElf_Header;
  Elf32_Shdr  *aspElf_Shdr;
  Elf32_Off   offset;
  struct stat sts;
  uint32_t    size;
  int         status;
  void        *map;
  pid_t       pid;
  int         fd;

  del_files();
  write_source_file(str);
  pid = fork();
  if (pid == 0)
    {
      execvp(args[0], args);
      exit(EXIT_SUCCESS);
    }
  waitpid(pid, &status, 0);

  if (stat(BFILE_WRITE, &sts) == -1)
    exit(EXIT_FAILURE);

  fd = xopen(BFILE_WRITE, O_RDONLY, 0644);
  map = xmmap(0, sts.st_size, PROT_READ, MAP_SHARED, fd, 0);

  aspElf_Header = map;
  aspElf_Shdr = (Elf32_Shdr *)((char *)map + aspElf_Header->e_shoff);

  offset = return_info_text(0, map, aspElf_Header, aspElf_Shdr);
  size = return_info_text(1, map, aspElf_Header, aspElf_Shdr);

  asm_mode.size = size;
  asm_mode.opcode = xmalloc((size * sizeof(char)) + 1);
  asm_mode.argument = str;
  memcpy((char *)asm_mode.opcode, (char *)map + offset, asm_mode.size);
  opcode_mode.flag = 1;
  opcode_mode.size = asm_mode.size;
  opcode_mode.opcode = asm_mode.opcode;

  xclose(fd);
  del_files();
}
int main(int argn ,char *argv[])
{	
	char in[100];
	while(1)
	{
		int n = strlen(para[0]);
		printf("%s->", para[0]);
		memset(in, 0, sizeof(in));
		gets(in);
		int choice = explain(in);
		//根据命令解释器的返回结果执行相对应的命令
		switch(choice)
		{
		case -1: printf("' %s '不是内部或外部命令,也不是可运行的程序\n或批处理文件。\n", in);break;
		case 0 : show_time();break; 
		case 1 : show_version();break;
		case 2 : show_date();break;
		case 3 : clrscr(0, 0);break;
		case 4 : show_directory();break;
		case 5 : help();break;
		case 6 : show_current_tree(para[0], 0);break;
		case 7 : return 0;
		case 8 : print_text(para[0]);break;	
		case 9 : if(del_dir(para[0]) == 0)	del_files(para[0]);break;//如果para[0]是文件夹,则执行删除文件夹函数,否则执行文件删除函数
		case 10 : creat_dir(para[0]);break;
		case 11 : rename_file(para[0], para[1]);break;
		case 12 : change_path(in);break;
		}//{"time", "version", "date", "cls", "dir", "help", "tree", "print", "del", "mkdir", "ren"};
		if(choice != 12)//如果没有改变路径,则每次都把当前工作目录下的以外的其它字符清除
		{
			memset(para[0] + n, 0, (100 - n) * sizeof(char));
			memset(para[1] + n, 0, (100 - n) * sizeof(char));
		}
	}
	return 0;
}
Ejemplo n.º 3
0
void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
{
	del_files(sdata);
	debugfs_remove(sdata->debugfsdir);
	sdata->debugfsdir = NULL;
}
Ejemplo n.º 4
0
void ieee80211_debugfs_change_if_type(struct ieee80211_sub_if_data *sdata,
				      int oldtype)
{
	del_files(sdata, oldtype);
	add_files(sdata);
}