~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to db/db.dropdb/main.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/****************************************************************************
 
3
 *
 
4
 * MODULE:       db.dropdb
 
5
 * AUTHOR(S):    Radim Blazek <radim.blazek gmail.com> (original contributor)
 
6
 *               Glynn Clements <glynn gclements.plus.com>, Markus Neteler <neteler itc.it>, Stephan Holl
 
7
 * PURPOSE:      removes an existing database
 
8
 * COPYRIGHT:    (C) 2002-2006 by the GRASS Development Team
 
9
 *
 
10
 *               This program is free software under the GNU General Public
 
11
 *               License (>=v2). Read the file COPYING that comes with GRASS
 
12
 *               for details.
 
13
 *
 
14
 *****************************************************************************/
 
15
 
 
16
#include <stdlib.h>
 
17
#include <grass/dbmi.h>
 
18
#include <grass/gis.h>
 
19
#include <grass/glocale.h>
 
20
 
 
21
 
 
22
struct
 
23
{
 
24
    char *driver, *database;
 
25
} parms;
 
26
 
 
27
 
 
28
/* function prototypes */
 
29
static void parse_command_line(int, char **);
 
30
 
 
31
 
 
32
int main(int argc, char **argv)
 
33
{
 
34
    dbDriver *driver;
 
35
    dbHandle handle;
 
36
    int stat;
 
37
 
 
38
    parse_command_line(argc, argv);
 
39
 
 
40
    driver = db_start_driver(parms.driver);
 
41
    if (driver == NULL)
 
42
        G_fatal_error(_("Unable to start driver <%s>"), parms.driver);
 
43
 
 
44
    db_init_handle(&handle);
 
45
    db_set_handle(&handle, parms.database, NULL);
 
46
    stat = db_delete_database(driver, &handle);
 
47
    db_shutdown_driver(driver);
 
48
 
 
49
    exit(stat == DB_OK ? EXIT_SUCCESS : EXIT_FAILURE);
 
50
}
 
51
 
 
52
 
 
53
static void parse_command_line(int argc, char **argv)
 
54
{
 
55
    struct Option *driver, *database;
 
56
    struct GModule *module;
 
57
 
 
58
    /* Initialize the GIS calls */
 
59
    G_gisinit(argv[0]);
 
60
 
 
61
    driver = G_define_standard_option(G_OPT_DB_DRIVER);
 
62
    driver->options = db_list_drivers();
 
63
    driver->required = YES;
 
64
    driver->answer = (char *) db_get_default_driver_name();
 
65
 
 
66
    database = G_define_standard_option(G_OPT_DB_DATABASE);
 
67
    database->required = YES;
 
68
 
 
69
    /* Set description */
 
70
    module = G_define_module();
 
71
    G_add_keyword(_("database"));
 
72
    G_add_keyword(_("attribute table"));
 
73
    G_add_keyword(_("SQL"));
 
74
    module->description = _("Removes an existing database.");
 
75
 
 
76
    if (G_parser(argc, argv))
 
77
        exit(EXIT_FAILURE);
 
78
 
 
79
    parms.driver = driver->answer;
 
80
    parms.database = database->answer;
 
81
}