diff options
Diffstat (limited to 'detect/env.c')
| -rw-r--r-- | detect/env.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/detect/env.c b/detect/env.c new file mode 100644 index 0000000..6782f8d --- /dev/null +++ b/detect/env.c | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * Detect GDB using env | ||
| 3 | * | ||
| 4 | */ | ||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include <string.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | |||
| 10 | int gdb_columns() { | ||
| 11 | return (getenv("COLUMNS") != NULL); | ||
| 12 | } | ||
| 13 | |||
| 14 | int gdb_lines() { | ||
| 15 | return (getenv("LINES") != NULL); | ||
| 16 | } | ||
| 17 | |||
| 18 | int gdb_path() { | ||
| 19 | char *gdb_path = getenv("_"); | ||
| 20 | if (gdb_path == NULL) { | ||
| 21 | return 0; | ||
| 22 | } | ||
| 23 | char *block_path = strtok(gdb_path, "/"); | ||
| 24 | char *str = NULL; | ||
| 25 | while (block_path != NULL) { | ||
| 26 | str = block_path; | ||
| 27 | block_path = strtok(NULL, "/"); | ||
| 28 | } | ||
| 29 | if (str == NULL) { | ||
| 30 | return 0; | ||
| 31 | } | ||
| 32 | else { | ||
| 33 | return !strcmp(str,"gdb"); | ||
| 34 | } | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
