mdbtools/src/util/mdb-ver.c

84 lines
1.9 KiB
C
Raw Normal View History

2002-03-21 12:27:37 +08:00
/* MDB Tools - A library for reading MS Access database file
* Copyright (C) 2000-2004 Brian Bruns
2002-03-21 12:27:37 +08:00
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "mdbtools.h"
#include "mdbver.h"
#include "mdbprivate.h"
#include <locale.h>
#ifdef DMALLOC
#include "dmalloc.h"
#endif
2002-03-21 12:27:37 +08:00
int
2002-03-21 12:27:37 +08:00
main(int argc, char **argv)
{
MdbHandle *mdb;
int print_mdbver = 0;
int opt;
2002-03-21 12:27:37 +08:00
/* setlocale (LC_ALL, ""); */
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
while ((opt=getopt(argc, argv, "M"))!=-1) {
switch (opt) {
case 'M':
print_mdbver = 1;
break;
default:
break;
}
}
if (print_mdbver) {
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
if (argc-optind < 1) exit(0);
}
2002-03-21 12:27:37 +08:00
/*
** optind is now the position of the first non-option arg,
** see getopt(3)
*/
if (argc-optind < 1) {
fprintf(stderr,_("Usage: %s [-M] <file>\n"),argv[0]);
2002-03-21 12:27:37 +08:00
exit(1);
}
mdb_init();
2004-04-14 04:06:04 +08:00
if (!(mdb = mdb_open(argv[optind], MDB_NOFLAGS))) {
fprintf(stderr,_("Error: unable to open file %s\n"),argv[optind]);
2005-03-14 05:29:17 +08:00
mdb_exit();
2002-03-21 12:27:37 +08:00
exit(1);
}
2003-01-02 06:29:39 +08:00
if (IS_JET3(mdb)) {
printf("JET3\n");
} else if (IS_JET4(mdb)) {
printf("JET4\n");
} else {
printf(_("unknown database version\n"));
2002-03-21 12:27:37 +08:00
}
mdb_close(mdb);
2002-03-21 12:27:37 +08:00
mdb_exit();
exit(0);
2002-03-21 12:27:37 +08:00
}