summaryrefslogtreecommitdiff
path: root/detect/env.c
diff options
context:
space:
mode:
authorAndrea Possemato2016-04-05 11:18:59 +0200
committerjvoisin2016-04-05 11:18:59 +0200
commitd82685c027edef9f7ca73a98413d7ec562391dbd (patch)
tree602c7f479b9f36bcd6d65e9f933d52e19d20c34c /detect/env.c
parent8356443afb0c80d49246ff41b7942bba7c76a7c6 (diff)
Gdb envHEADmaster
Add gdb detection via environment variables
Diffstat (limited to 'detect/env.c')
-rw-r--r--detect/env.c37
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
10int gdb_columns() {
11 return (getenv("COLUMNS") != NULL);
12}
13
14int gdb_lines() {
15 return (getenv("LINES") != NULL);
16}
17
18int 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