ping_main.c 2.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * ping stub
 * Copyright (C) 2010 Trey Hunner
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

20 21 22
#include "config.h"
#include "wine/port.h"

Borut Razem's avatar
Borut Razem committed
23
#include <stdio.h>
24 25 26 27 28
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

29 30 31 32 33 34 35 36
#include <windows.h>

#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(ping);

static void usage(void)
{
Borut Razem's avatar
Borut Razem committed
37 38 39 40
    printf("Usage: ping [-n count] [-w timeout] target_name\n\n"
           "Options:\n"
           "    -n  Number of echo requests to send.\n"
           "    -w  Timeout in milliseconds to wait for each reply.\n");
41 42 43 44
}

int main(int argc, char** argv)
{
Borut Razem's avatar
Borut Razem committed
45
    unsigned int n = 0;
46 47 48 49 50 51 52 53 54
    int optc;

    WINE_FIXME( "this command currently just sleeps based on -n parameter\n" );

    while ((optc = getopt( argc, argv, "n:w:tal:fi:v:r:s:j:k:" )) != -1)
    {
        switch(optc)
        {
            case 'n':
Borut Razem's avatar
Borut Razem committed
55 56 57 58 59 60
                n = atoi(optarg);
                if (n == 0)
                {
                  printf("Bad value for option -n, valid range is from 1 to 4294967295.\n");
                  exit(1);
                }
61 62 63 64 65 66 67 68 69 70 71
                break;
            case '?':
                usage();
                exit(1);
            default:
                usage();
                WINE_FIXME( "this command currently only supports the -n parameter\n" );
                exit(1);
        }
    }

Borut Razem's avatar
Borut Razem committed
72 73 74
    if (n != 0)
      Sleep((n - 1) * 1000);

75 76
    return 0;
}