1999-03-16 22:35:19 +03:00
|
|
|
/*
|
|
|
|
* gen_uuid.c --- generate a DCE-compatible uuid
|
|
|
|
*
|
1999-07-03 10:16:06 +04:00
|
|
|
* Copyright (C) 1999, Andreas Dilger and Theodore Ts'o
|
1999-03-16 22:35:19 +03:00
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
|
|
|
*/
|
|
|
|
|
2011-09-19 01:34:37 +04:00
|
|
|
#include "config.h"
|
1999-03-16 22:35:19 +03:00
|
|
|
#include <stdio.h>
|
2001-02-08 05:38:07 +03:00
|
|
|
#ifdef HAVE_STDLIB_H
|
ChangeLog, e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c:
e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c: Fix
gcc -Wall complaints, including one bug in tune2fs caused by a block
automatic shadowing version of the variable we really wanted to use,
which broke the logic testing to see if the filesystem was mounted.
ChangeLog, MCONFIG.in:
(gcc-wall-new): Added new target which forgoes the make clean so we
only check the newly modified .c files.
2001-01-11 19:08:23 +03:00
|
|
|
#include <stdlib.h>
|
2001-02-08 05:38:07 +03:00
|
|
|
#endif
|
1999-07-03 10:16:06 +04:00
|
|
|
#ifdef HAVE_GETOPT_H
|
|
|
|
#include <getopt.h>
|
Many files:
badblocks.c, dumpe2fs.c, e2label.c, mke2fs.c, tune2fs.c, uuidgen.c:
For platforms that don't define optarg.h, manually define optarg and
optind.
ChangeLog, main.c:
main.c: For platforms that don't define optarg.h, manually define
optarg and optind.
ChangeLog, unix.c:
unix.c: For platforms that don't define optarg.h, manually define
optarg and optind.
2000-04-03 20:22:35 +04:00
|
|
|
#else
|
2006-05-30 18:27:45 +04:00
|
|
|
extern int getopt(int argc, char * const argv[], const char *optstring);
|
Many files:
badblocks.c, dumpe2fs.c, e2label.c, mke2fs.c, tune2fs.c, uuidgen.c:
For platforms that don't define optarg.h, manually define optarg and
optind.
ChangeLog, main.c:
main.c: For platforms that don't define optarg.h, manually define
optarg and optind.
ChangeLog, unix.c:
unix.c: For platforms that don't define optarg.h, manually define
optarg and optind.
2000-04-03 20:22:35 +04:00
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
1999-07-03 10:16:06 +04:00
|
|
|
#endif
|
1999-03-16 22:35:19 +03:00
|
|
|
#include "uuid/uuid.h"
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
#include "nls-enable.h"
|
1999-03-16 22:35:19 +03:00
|
|
|
|
1999-07-03 10:16:06 +04:00
|
|
|
#define DO_TYPE_TIME 1
|
|
|
|
#define DO_TYPE_RANDOM 2
|
|
|
|
|
ChangeLog, e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c:
e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c: Fix
gcc -Wall complaints, including one bug in tune2fs caused by a block
automatic shadowing version of the variable we really wanted to use,
which broke the logic testing to see if the filesystem was mounted.
ChangeLog, MCONFIG.in:
(gcc-wall-new): Added new target which forgoes the make clean so we
only check the newly modified .c files.
2001-01-11 19:08:23 +03:00
|
|
|
static void usage(const char *progname)
|
1999-07-03 10:16:06 +04:00
|
|
|
{
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
fprintf(stderr, _("Usage: %s [-r] [-t]\n"), progname);
|
1999-07-03 10:16:06 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1999-03-16 22:35:19 +03:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
1999-07-03 10:16:06 +04:00
|
|
|
int c;
|
|
|
|
int do_type = 0;
|
|
|
|
char str[37];
|
|
|
|
uuid_t uu;
|
1999-03-16 22:35:19 +03:00
|
|
|
|
2003-05-04 02:45:55 +04:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
setlocale(LC_MESSAGES, "");
|
|
|
|
setlocale(LC_CTYPE, "");
|
|
|
|
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
|
|
textdomain(NLS_CAT_NAME);
|
|
|
|
#endif
|
|
|
|
|
1999-07-03 10:16:06 +04:00
|
|
|
while ((c = getopt (argc, argv, "tr")) != EOF)
|
|
|
|
switch (c) {
|
|
|
|
case 't':
|
|
|
|
do_type = DO_TYPE_TIME;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
do_type = DO_TYPE_RANDOM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage(argv[0]);
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1999-07-03 10:16:06 +04:00
|
|
|
switch (do_type) {
|
|
|
|
case DO_TYPE_TIME:
|
|
|
|
uuid_generate_time(uu);
|
|
|
|
break;
|
|
|
|
case DO_TYPE_RANDOM:
|
|
|
|
uuid_generate_random(uu);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
uuid_generate(uu);
|
|
|
|
break;
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1999-07-03 10:16:06 +04:00
|
|
|
uuid_unparse(uu, str);
|
1999-03-16 22:35:19 +03:00
|
|
|
|
1999-07-03 10:16:06 +04:00
|
|
|
printf("%s\n", str);
|
1999-03-16 22:35:19 +03:00
|
|
|
|
1999-07-03 10:16:06 +04:00
|
|
|
return 0;
|
1999-03-16 22:35:19 +03:00
|
|
|
}
|