From: H. Peter Anvin Date: Fri, 29 May 2009 22:10:37 +0000 (-0700) Subject: Run Nindent on utils/gethostip.c X-Git-Tag: syslinux-3.83-pre2~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf1f066e3efd2f9ec8235ff9df94635a60b8d4f9;p=platform%2Fupstream%2Fsyslinux.git Run Nindent on utils/gethostip.c Automatically reformat utils/gethostip.c using Nindent. Do this for all files except HDT, gPXE and externally maintained libraries (zlib, tinyjpeg, libpng). Signed-off-by: H. Peter Anvin --- diff --git a/utils/gethostip.c b/utils/gethostip.c index 2a1e6e6..f3f8757 100644 --- a/utils/gethostip.c +++ b/utils/gethostip.c @@ -26,106 +26,106 @@ #define _GNU_SOURCE /* For getopt_long */ #include -const struct option options[] = -{ - { "hexadecimal", 0, NULL, 'x' }, - { "decimal", 0, NULL, 'd' }, - { "dotted-quad", 0, NULL, 'd' }, - { "full-output", 0, NULL, 'f' }, - { "name", 0, NULL, 'n' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 } +const struct option options[] = { + {"hexadecimal", 0, NULL, 'x'}, + {"decimal", 0, NULL, 'd'}, + {"dotted-quad", 0, NULL, 'd'}, + {"full-output", 0, NULL, 'f'}, + {"name", 0, NULL, 'n'}, + {"help", 0, NULL, 'h'}, + {NULL, 0, NULL, 0} }; const char *program; void usage(int exit_code) { - fprintf(stderr, "Usage: %s [-dxnf] hostname/ip...\n", program); - exit(exit_code); + fprintf(stderr, "Usage: %s [-dxnf] hostname/ip...\n", program); + exit(exit_code); } int main(int argc, char *argv[]) { - int opt; - int output = 0; - int i; - char *sep; - int err = 0; - - struct hostent *host; - - program = argv[0]; - - while ( (opt = getopt_long(argc, argv, "dxfnh", options, NULL)) != -1 ) { - switch ( opt ) { - case 'd': - output |= 2; /* Decimal output */ - break; - case 'x': - output |= 4; /* Hexadecimal output */ - break; - case 'n': - output |= 1; /* Canonical name output */ - break; - case 'f': - output = 7; /* Full output */ - break; - case 'h': - usage(0); - break; - default: - usage(EX_USAGE); - break; - } - } - - if ( optind == argc ) - usage(EX_USAGE); - - if ( output == 0 ) - output = 7; /* Default output */ - - for ( i = optind ; i < argc ; i++ ) { - sep = ""; - host = gethostbyname(argv[i]); - if ( !host ) { - herror(argv[i]); - err = 1; - continue; - } - - if ( host->h_addrtype != AF_INET || host->h_length != 4 ) { - fprintf(stderr, "%s: No IPv4 address associated with name\n", argv[i]); - err = 1; - continue; - } - - if ( output & 1 ) { - printf("%s%s", sep, host->h_name); - sep = " "; + int opt; + int output = 0; + int i; + char *sep; + int err = 0; + + struct hostent *host; + + program = argv[0]; + + while ((opt = getopt_long(argc, argv, "dxfnh", options, NULL)) != -1) { + switch (opt) { + case 'd': + output |= 2; /* Decimal output */ + break; + case 'x': + output |= 4; /* Hexadecimal output */ + break; + case 'n': + output |= 1; /* Canonical name output */ + break; + case 'f': + output = 7; /* Full output */ + break; + case 'h': + usage(0); + break; + default: + usage(EX_USAGE); + break; + } } - if ( output & 2 ) { - printf("%s%u.%u.%u.%u", sep, - ((unsigned char *)host->h_addr)[0], - ((unsigned char *)host->h_addr)[1], - ((unsigned char *)host->h_addr)[2], - ((unsigned char *)host->h_addr)[3]); - sep = " "; + if (optind == argc) + usage(EX_USAGE); + + if (output == 0) + output = 7; /* Default output */ + + for (i = optind; i < argc; i++) { + sep = ""; + host = gethostbyname(argv[i]); + if (!host) { + herror(argv[i]); + err = 1; + continue; + } + + if (host->h_addrtype != AF_INET || host->h_length != 4) { + fprintf(stderr, "%s: No IPv4 address associated with name\n", + argv[i]); + err = 1; + continue; + } + + if (output & 1) { + printf("%s%s", sep, host->h_name); + sep = " "; + } + + if (output & 2) { + printf("%s%u.%u.%u.%u", sep, + ((unsigned char *)host->h_addr)[0], + ((unsigned char *)host->h_addr)[1], + ((unsigned char *)host->h_addr)[2], + ((unsigned char *)host->h_addr)[3]); + sep = " "; + } + + if (output & 4) { + printf("%s%02X%02X%02X%02X", sep, + ((unsigned char *)host->h_addr)[0], + ((unsigned char *)host->h_addr)[1], + ((unsigned char *)host->h_addr)[2], + ((unsigned char *)host->h_addr)[3]); + sep = " "; + } + + putchar('\n'); } - if ( output & 4 ) { - printf("%s%02X%02X%02X%02X", sep, - ((unsigned char *)host->h_addr)[0], - ((unsigned char *)host->h_addr)[1], - ((unsigned char *)host->h_addr)[2], - ((unsigned char *)host->h_addr)[3]); - sep = " "; - } - - putchar('\n'); - } - - return err; + return err; }