e6db318b2456bd18dab47017d9ef28ff261b7136
[awesomized/libmemcached] / src / utilities.c
1 #include <ctype.h>
2 #include <strings.h>
3 #include "utilities.h"
4
5 long int timedif(struct timeval a, struct timeval b)
6 {
7 register int us, s;
8
9 us = a.tv_usec - b.tv_usec;
10 us /= 1000;
11 s = a.tv_sec - b.tv_sec;
12 s *= 1000;
13 return s + us;
14 }
15
16 void version_command(char *command_name)
17 {
18 printf("%s v%u.%u\n", command_name, 1, 0);
19 exit(0);
20 }
21
22 void help_command(char *command_name, char *description,
23 const struct option *long_options,
24 memcached_programs_help_st *options)
25 {
26 unsigned int x;
27
28 printf("%s v%u.%u\n\n", command_name, 1, 0);
29 printf("\t%s\n\n", description);
30 printf("Current options. A '=' means the option takes a value.\n\n");
31
32 for (x= 0; long_options[x].name; x++)
33 printf("\t --%s%c\n", long_options[x].name,
34 long_options[x].has_arg ? '=' : ' ');
35
36 printf("\n");
37 exit(0);
38 }