appwiz.cpl: Add Wine Mono to addons.
[wine] / programs / ping / ping_main.c
1 /*
2  * ping stub
3  * Copyright (C) 2010 Trey Hunner
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include "config.h"
21 #include "wine/port.h"
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #ifdef HAVE_UNISTD_H
26 #include <unistd.h>
27 #endif
28
29 #include <windows.h>
30
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(ping);
34
35 static void usage(void)
36 {
37     printf("Usage: ping [-n count] [-w timeout] target_name\n\n"
38            "Options:\n"
39            "    -n  Number of echo requests to send.\n"
40            "    -w  Timeout in milliseconds to wait for each reply.\n");
41 }
42
43 int main(int argc, char** argv)
44 {
45     unsigned int n = 0;
46     int optc;
47
48     WINE_FIXME( "this command currently just sleeps based on -n parameter\n" );
49
50     while ((optc = getopt( argc, argv, "n:w:tal:fi:v:r:s:j:k:" )) != -1)
51     {
52         switch(optc)
53         {
54             case 'n':
55                 n = atoi(optarg);
56                 if (n == 0)
57                 {
58                   printf("Bad value for option -n, valid range is from 1 to 4294967295.\n");
59                   exit(1);
60                 }
61                 break;
62             case '?':
63                 usage();
64                 exit(1);
65             default:
66                 usage();
67                 WINE_FIXME( "this command currently only supports the -n parameter\n" );
68                 exit(1);
69         }
70     }
71
72     if (n != 0)
73       Sleep((n - 1) * 1000);
74
75     return 0;
76 }