⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
     void (*fun) PARAMS ((char *, int));     char *doc;{  add_cmd (name, no_class, fun, doc, &infolist);}/* Add an alias to the list of info subcommands.  */voidadd_info_alias (name, oldname, abbrev_flag)     char *name;     char *oldname;     int abbrev_flag;{  add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist);}/* The "info" command is defined as a prefix, with allow_unknown = 0.   Therefore, its own definition is called only for "info" with no args.  *//* ARGSUSED */static voidinfo_command (arg, from_tty)     char *arg;     int from_tty;{  printf ("\"info\" must be followed by the name of an info command.\n");  help_list (infolist, "info ", -1, stdout);}/* The "show" command with no arguments shows all the settings.  *//* ARGSUSED */static voidshow_command (arg, from_tty)     char *arg;     int from_tty;{  cmd_show_list (showlist, from_tty, "");}/* Add an element to the list of commands.  */voidadd_com (name, class, fun, doc)     char *name;     enum command_class class;     void (*fun) PARAMS ((char *, int));     char *doc;{  add_cmd (name, class, fun, doc, &cmdlist);}/* Add an alias or abbreviation command to the list of commands.  */voidadd_com_alias (name, oldname, class, abbrev_flag)     char *name;     char *oldname;     enum command_class class;     int abbrev_flag;{  add_alias_cmd (name, oldname, class, abbrev_flag, &cmdlist);}voiderror_no_arg (why)     char *why;{  error ("Argument required (%s).", why);}/* ARGSUSED */static voidhelp_command (command, from_tty)     char *command;     int from_tty; /* Ignored */{  help_cmd (command, stdout);}static voidvalidate_comname (comname)     char *comname;{  register char *p;  if (comname == 0)    error_no_arg ("name of command to define");  p = comname;  while (*p)    {      if (!isalnum(*p) && *p != '-')	error ("Junk in argument list: \"%s\"", p);      p++;    }}/* This is just a placeholder in the command data structures.  */static voiduser_defined_command (ignore, from_tty)     char *ignore;     int from_tty;{}static voiddefine_command (comname, from_tty)     char *comname;     int from_tty;{  register struct command_line *cmds;  register struct cmd_list_element *c, *newc, *hookc = 0;  char *tem = comname;#define	HOOK_STRING	"hook-"#define	HOOK_LEN 5  validate_comname (comname);  /* Look it up, and verify that we got an exact match.  */  c = lookup_cmd (&tem, cmdlist, "", -1, 1);  if (c && 0 != strcmp (comname, c->name))    c = 0;      if (c)    {      if (c->class == class_user || c->class == class_alias)	tem = "Redefine command \"%s\"? ";      else	tem = "Really redefine built-in command \"%s\"? ";      if (!query (tem, c->name))	error ("Command \"%s\" not redefined.", c->name);    }  /* If this new command is a hook, then mark the command which it     is hooking.  Note that we allow hooking `help' commands, so that     we can hook the `stop' pseudo-command.  */  if (!strncmp (comname, HOOK_STRING, HOOK_LEN))    {      /* Look up cmd it hooks, and verify that we got an exact match.  */      tem = comname+HOOK_LEN;      hookc = lookup_cmd (&tem, cmdlist, "", -1, 0);      if (hookc && 0 != strcmp (comname+HOOK_LEN, hookc->name))	hookc = 0;      if (!hookc)	{	  warning ("Your new `%s' command does not hook any existing command.",		   comname);	  if (!query ("Proceed? ", (char *)0))	    error ("Not confirmed.");	}    }  comname = savestring (comname, strlen (comname));  /* If the rest of the commands will be case insensitive, this one      should behave in the same manner. */  for (tem = comname; *tem; tem++)    if (isupper(*tem)) *tem = tolower(*tem);  if (from_tty)    {      printf ("Type commands for definition of \"%s\".\n\End with a line saying just \"end\".\n", comname);      fflush (stdout);    }  cmds = read_command_lines (from_tty);  if (c && c->class == class_user)    free_command_lines (c->user_commands);  newc = add_cmd (comname, class_user, user_defined_command,	   (c && c->class == class_user)	   ? c->doc : savestring ("User-defined.", 13), &cmdlist);  newc->user_commands = cmds;  /* If this new command is a hook, then mark both commands as being     tied.  */  if (hookc)    {      hookc->hook = newc;	/* Target gets hooked.  */      newc->hookee = hookc;	/* We are marked as hooking target cmd.  */    }}static voiddocument_command (comname, from_tty)     char *comname;     int from_tty;{  struct command_line *doclines;  register struct cmd_list_element *c;  char *tem = comname;  validate_comname (comname);  c = lookup_cmd (&tem, cmdlist, "", 0, 1);  if (c->class != class_user)    error ("Command \"%s\" is built-in.", comname);  if (from_tty)    printf ("Type documentation for \"%s\".\n\End with a line saying just \"end\".\n", comname);  doclines = read_command_lines (from_tty);  if (c->doc) free (c->doc);  {    register struct command_line *cl1;    register int len = 0;    for (cl1 = doclines; cl1; cl1 = cl1->next)      len += strlen (cl1->line) + 1;    c->doc = (char *) xmalloc (len + 1);    *c->doc = 0;    for (cl1 = doclines; cl1; cl1 = cl1->next)      {	strcat (c->doc, cl1->line);	if (cl1->next)	  strcat (c->doc, "\n");      }  }  free_command_lines (doclines);}static voidprint_gnu_advertisement(){    printf ("\GDB is free software and you are welcome to distribute copies of it\n\ under certain conditions; type \"show copying\" to see the conditions.\n\There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\");}static voidprint_gdb_version (){  printf_filtered ("\GDB %s, Copyright 1992 Free Software Foundation, Inc.",	  version);}/* ARGSUSED */static voidshow_version (args, from_tty)     char *args;     int from_tty;{  immediate_quit++;  print_gnu_advertisement ();  print_gdb_version ();  printf_filtered ("\n");  immediate_quit--;}/* xgdb calls this to reprint the usual GDB prompt.  */voidprint_prompt (){  printf ("%s", masterprompt);  fflush (stdout);}#ifdef HAVE_TERMIO#include <termio.h>static struct termio norm_tty;init_term(tty){	ioctl(tty, TCGETA, &norm_tty);}static voidsuspend_sig(){	int tty = fileno(stdin);	struct termio cur_tty;	ioctl(tty, TCGETA, &cur_tty);	ioctl(tty, TCSETAW, &norm_tty);	(void) sigsetmask(0);	signal(SIGTSTP, SIG_DFL);	kill(0, SIGTSTP);	/*	 * we've just been resumed -- current tty params become new	 * 'normal' params (in case tset/stty was done while we were	 * suspended).  Merge values that readline might have changed	 * into new params, then restore term mode.	 */	ioctl(tty, TCGETA, &norm_tty);	cur_tty.c_lflag = (cur_tty.c_lflag & (ICANON|ECHO|ISIG)) |			  (norm_tty.c_lflag &~ (ICANON|ECHO|ISIG));	cur_tty.c_iflag = (cur_tty.c_iflag & (IXON|ISTRIP|INPCK)) |			  (norm_tty.c_iflag &~ (IXON|ISTRIP|INPCK));	ioctl(tty, TCSETAW, &cur_tty);	signal(SIGTSTP, suspend_sig);	print_prompt();	/*	 * Forget about any previous command -- null line now will do	 * nothing.	 */	dont_repeat();}#else#include <fcntl.h>#include <sgtty.h>#include <sys/ioctl.h> /* XXX BSD: must follow sgtty.h for compat to kick in */static struct sgttyb norm_tty;static struct tchars norm_tchars;static struct ltchars norm_ltchars;static int norm_lflags;#ifdef PASS8#define RL_TFLAGS (RAW|CRMOD|ECHO|CBREAK|PASS8)#else#define RL_TFLAGS (RAW|CRMOD|ECHO|CBREAK)#endifinit_term(tty)	int tty;{  ioctl(tty, TIOCGETP, &norm_tty);  ioctl(tty, TIOCLGET, &norm_lflags);  ioctl(tty, TIOCGETC, &norm_tchars);  ioctl(tty, TIOCGLTC, &norm_ltchars);}static voidsuspend_sig(){	int tty = fileno(stdin);	struct sgttyb cur_tty;	struct tchars cur_tchars;	struct ltchars cur_ltchars;	int cur_lflags;	int cur_flags;	ioctl(tty, TIOCGETP, &cur_tty);	ioctl(tty, TIOCGETC, &cur_tchars);	ioctl(tty, TIOCLGET, &cur_lflags);	ioctl(tty, TIOCGLTC, &cur_ltchars);	ioctl(tty, TIOCSETP, &norm_tty);	ioctl(tty, TIOCSETC, &norm_tchars);	ioctl(tty, TIOCLSET, &norm_lflags);	ioctl(tty, TIOCSLTC, &norm_ltchars);	(void) sigsetmask(0);	signal(SIGTSTP, SIG_DFL);	kill(0, SIGTSTP);	/*	 * we've just been resumed -- current tty params become new	 * 'normal' params (in case tset/stty was done while we were	 * suspended).  Merge values that readline might have changed	 * into new params, then restore term mode.	 */	ioctl(tty, TIOCGETP, &norm_tty);	cur_flags = cur_tty.sg_flags;	cur_tty = norm_tty;	cur_tty.sg_flags = (cur_tty.sg_flags &~ RL_TFLAGS)			   | (cur_flags & RL_TFLAGS);	ioctl(tty, TIOCLGET, &norm_lflags);#ifdef LPASS8	cur_lflags = (cur_lflags &~ LPASS8) | (cur_flags & LPASS8);#endif	ioctl(tty, TIOCGETC, &norm_tchars);	ioctl(tty, TIOCGLTC, &norm_ltchars);	ioctl(tty, TIOCSETP, &cur_tty);	ioctl(tty, TIOCSETC, &cur_tchars);	ioctl(tty, TIOCLSET, &cur_lflags);	ioctl(tty, TIOCSLTC, &cur_ltchars);	signal(SIGTSTP, suspend_sig);	print_prompt();	/*	 * Forget about any previous command -- null line now will do	 * nothing.	 */	dont_repeat();}#endif /* HAVE_TERMIO */static voidquit_command (args, from_tty)     char *args;     int from_tty;{  /*   * Don't bother checking if the inferior_pid is 0 because the remote   * module doesn't muck with it (for pid 0, target_kill should be a nop    * in the ptrace case anyway -- moreover, inferior_pid should be private   * to infptrace.c)   */  if (target_has_execution)    {      if (inhibit_confirm || query ("The program is running.  Quit anyway? "))	{	  if (attach_flag)	    target_detach (args, from_tty);	  else	    target_kill ();	}      else	error ("Not confirmed.");    }  /* Save the history information if it is appropriate to do so.  */  if (write_history_p && history_filename)    write_history (history_filename);  exit (0);}/* Returns whether GDB is running on a terminal and whether the user   desires that questions be asked of them on that terminal.  */intinput_from_terminal_p (){  return gdb_has_a_terminal && (instream == stdin) & caution;}/* ARGSUSED */static voidpwd_command (args, from_tty)     char *args;     int from_tty;{  if (args) error ("The \"pwd\" command does not take an argument: %s", args);  getcwd (dirbuf, sizeof (dirbuf));  if (strcmp (dirbuf, current_directory))    printf ("Working directory %s\n (canonically %s).\n",	    current_directory, dirbuf);  else    printf ("Working directory %s.\n", current_directory);}static voidcd_command (dir, from_tty)     char *dir;     int from_tty;{  int len;  int change;  /* If the new directory is absolute, repeat is a no-op; if relative,     repeat might be useful but is more likely to be a mistake.  */  dont_repeat ();  if (dir == 0)    error_no_arg ("new working directory");  dir = tilde_expand (dir);  make_cleanup (free, dir);  if (chdir (dir) < 0)    perror_with_name (dir);  len = strlen (dir);  dir = savestring (dir, len - (len > 1 && dir[len-1] == '/'));  if (dir[0] == '/')    current_directory = dir;  else    {      current_directory = concat (current_directory, "/", dir, NULL);      free (dir);    }  /* Now simplify any occurrences of `.' and `..' in the pathname.  */  change = 1;  while (change)    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -