82f50c159cd813bf03b4ab2abfaeb5d50b728c59
[oweals/busybox.git] / coreutils / length.c
1 /* vi: set sw=4 ts=4: */
2 #include "internal.h"
3 #include <stdlib.h>
4 #include <string.h>
5 #include <stdio.h>
6
7 const char length_usage[] =
8         "length STRING\n"
9 #ifndef BB_FEATURE_TRIVIAL_HELP
10         "\nPrints out the length of the specified STRING.\n"
11 #endif
12         ;
13
14 extern int length_main(int argc, char **argv)
15 {
16         if (argc != 2 || **(argv + 1) == '-')
17                 usage(length_usage);
18         printf("%lu\n", (long)strlen(argv[1]));
19         return (TRUE);
20 }