您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

nslookup_cmd.c 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2012 Patrick Plenefisch <phplenefisch@wpi.edu>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. FILE_LICENCE ( GPL2_OR_LATER );
  20. #include <stdio.h>
  21. #include <getopt.h>
  22. #include <ipxe/command.h>
  23. #include <ipxe/parseopt.h>
  24. #include <usr/nslookup.h>
  25. /** @file
  26. *
  27. * nslookup command
  28. *
  29. */
  30. /** "nslookup" options */
  31. struct nslookup_options {};
  32. /** "nslookup" option list */
  33. static struct option_descriptor nslookup_opts[] = {};
  34. /** "nslookup" command descriptor */
  35. static struct command_descriptor nslookup_cmd =
  36. COMMAND_DESC ( struct nslookup_options, nslookup_opts, 2, 2,
  37. "<setting> <name>" );
  38. /**
  39. * The "nslookup" command
  40. *
  41. * @v argc Argument count
  42. * @v argv Argument list
  43. * @ret rc Return status code
  44. */
  45. static int nslookup_exec ( int argc, char **argv ) {
  46. struct nslookup_options opts;
  47. const char *name;
  48. const char *setting_name;
  49. int rc;
  50. /* Parse options */
  51. if ( ( rc = parse_options ( argc, argv, &nslookup_cmd, &opts ) ) != 0 )
  52. return rc;
  53. /* Parse setting name */
  54. setting_name = argv[optind];
  55. /* Parse name to be resolved */
  56. name = argv[ optind + 1 ];
  57. /* Look up name */
  58. if ( ( rc = nslookup ( name, setting_name ) ) != 0 )
  59. return rc;
  60. return 0;
  61. }
  62. /** The "nslookup" command */
  63. struct command nslookup_command __command = {
  64. .name = "nslookup",
  65. .exec = nslookup_exec,
  66. };