Useful CLI tools (bash) for Arch Linux administration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
341 B

  1. #include <stdio.h>
  2. #include <stddef.h>
  3. #include <netdb.h>
  4. int main(int argc, char *argv[])
  5. {
  6. struct servent *se;
  7. if (argc != 3) {
  8. printf("%s usage: <protocol> [tcp|udp]\n", argv[0]);
  9. return 1;
  10. }
  11. if ((se = getservbyname(argv[1], argv[2])) == NULL) {
  12. return 1;
  13. } else {
  14. printf("%d\n", ntohs(se->s_port));
  15. }
  16. return 0;
  17. }