summaryrefslogtreecommitdiffhomepage
path: root/public/tools/ping/src/CommandLine.cc
blob: a9ba177aab8eab5d6d50add908c49a631f8978c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <libSystem/SystemKit/System.h>

SInt32 _NeMain(SInt32 argc, Char* argv[]) {
  LIBSYS_UNUSED(argc);

  if (argc < 2) {
    PrintOut(nullptr, "HELP: ping <hostname>\n");
    return EXIT_FAILURE;
  }

  PrintOut(nullptr, "Pinging %s...\n", argv[1]);

  for (SizeT i = 0U; i < 4; ++i) {
    SInt32 result = 0;

    if (result != 0) {
      PrintOut(nullptr, "Request timed out.\n");
      return EXIT_FAILURE;
    }

    SInt32 bytes = 64;              // Simulated response size
    SInt32 time  = 100 + (i * 10);  // Simulated response time
    SInt32 ttl   = 64;

    PrintOut(nullptr, "Reply from %s: bytes=%i time=%ims TTL=%i\n", argv[1], bytes, time, ttl);
  }

  return EXIT_SUCCESS;
}