]>
Commit | Line | Data |
---|---|---|
4684b66f | 1 | /** @file\r |
2 | Translate the service name into a port number\r | |
3 | \r | |
9f7f5161 | 4 | Copyright (c) 2011-2012, Intel Corporation\r |
4684b66f | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include <errno.h>\r | |
16 | #include <netdb.h>\r | |
17 | #include <string.h>\r | |
18 | #include <Uefi.h>\r | |
19 | #include <unistd.h>\r | |
20 | \r | |
21 | #include <Library/DebugLib.h>\r | |
22 | #include <Library/UefiLib.h>\r | |
23 | \r | |
24 | #include <sys/socket.h>\r | |
25 | \r | |
59bc0593 | 26 | char mBuffer[65536];\r |
4684b66f | 27 | \r |
28 | \r | |
29 | /**\r | |
30 | Translate the service name into a port number\r | |
31 | \r | |
32 | @param [in] Argc The number of arguments\r | |
33 | @param [in] Argv The argument value array\r | |
34 | \r | |
35 | @retval 0 The application exited normally.\r | |
36 | @retval Other An error occurred.\r | |
37 | **/\r | |
38 | int\r | |
39 | main (\r | |
40 | IN int Argc,\r | |
41 | IN char **Argv\r | |
42 | )\r | |
43 | {\r | |
44 | int AppStatus;\r | |
45 | int PortNumber;\r | |
46 | struct servent * pService;\r | |
47 | \r | |
48 | //\r | |
49 | // Determine if the service name is specified\r | |
50 | //\r | |
51 | AppStatus = 0;\r | |
52 | if ( 1 == Argc ) {\r | |
53 | Print ( L"%a <service name>\r\n", Argv[0]);\r | |
54 | }\r | |
55 | else {\r | |
56 | //\r | |
57 | // Translate the service name\r | |
58 | //\r | |
59 | pService = getservbyname ( Argv[1], NULL );\r | |
60 | if ( NULL == pService ) {\r | |
61 | Print ( L"ERROR - service not found, errno: %d\r\n", errno );\r | |
62 | }\r | |
63 | else {\r | |
64 | PortNumber = htons ( pService->s_port );\r | |
65 | Print ( L"%a: %d, %a\r\n",\r | |
66 | pService->s_name,\r | |
67 | PortNumber,\r | |
68 | pService->s_proto );\r | |
69 | }\r | |
70 | }\r | |
71 | \r | |
72 | //\r | |
73 | // All done\r | |
74 | //\r | |
75 | return errno;\r | |
76 | }\r |