| 1 |
#include <unistd.h> |
| 2 |
#include "global.h" |
| 3 |
|
| 4 |
static int which_env = -1; |
| 5 |
|
| 6 |
int select_current_env(void) |
| 7 |
{ |
| 8 |
if (which_env < 0) { |
| 9 |
G_create_alt_env(); |
| 10 |
which_env = 0; |
| 11 |
} |
| 12 |
if (which_env != 0) { |
| 13 |
G_switch_env(); |
| 14 |
which_env = 0; |
| 15 |
} |
| 16 |
|
| 17 |
return 0; |
| 18 |
} |
| 19 |
|
| 20 |
int select_target_env(void) |
| 21 |
{ |
| 22 |
if (which_env < 0) { |
| 23 |
G_create_alt_env(); |
| 24 |
which_env = 1; |
| 25 |
} |
| 26 |
if (which_env != 1) { |
| 27 |
G_switch_env(); |
| 28 |
which_env = 1; |
| 29 |
} |
| 30 |
|
| 31 |
return 0; |
| 32 |
} |
| 33 |
|
| 34 |
int show_env(void) |
| 35 |
{ |
| 36 |
fprintf(stderr, "env(%d) switch to LOCATION %s, MAPSET %s\n", which_env, |
| 37 |
G_getenv_nofatal("LOCATION_NAME") == NULL |
| 38 |
? "?" |
| 39 |
: G_getenv_nofatal("LOCATION_NAME"), |
| 40 |
G_getenv_nofatal("MAPSET") == NULL ? "?" |
| 41 |
: G_getenv_nofatal("MAPSET")); |
| 42 |
G_sleep(2); |
| 43 |
|
| 44 |
return 0; |
| 45 |
} |