summaryrefslogtreecommitdiff
path: root/tools/d2c/manual.h
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-01-28 23:32:25 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-01-28 23:32:25 (GMT)
commit16e0fd9d89ef433848678dfc8dd20426844a2868 (patch)
tree79075ae02c133cea21ffb555b1086aae833b3aac /tools/d2c/manual.h
parent66c99d59d6a6d533de0bb65488de8243213bcdea (diff)
Cleaned, rewritten and improved the whole code of the compiler.
Diffstat (limited to 'tools/d2c/manual.h')
-rw-r--r--tools/d2c/manual.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/tools/d2c/manual.h b/tools/d2c/manual.h
new file mode 100644
index 0000000..1402ca5
--- /dev/null
+++ b/tools/d2c/manual.h
@@ -0,0 +1,65 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * manual.h - définitions de macros pour la lecture manuelle de lexèmes
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _TOOLS_D2C_MANUAL_H
+#define _TOOLS_D2C_MANUAL_H
+
+
+#define read_block(tmp) \
+ ({ \
+ unsigned int __depth; \
+ bool __is_string; \
+ char *__iter; \
+ \
+ __depth = 1; \
+ __is_string = false; \
+ \
+ for (__iter = temp; __depth > 0; __iter += (__depth > 0 ? 1 : 0)) \
+ { \
+ *__iter = input(); \
+ \
+ switch (*__iter) \
+ { \
+ case '"': \
+ __is_string = !__is_string; \
+ break; \
+ \
+ case '{': \
+ if (!__is_string) __depth++; \
+ break; \
+ \
+ case '}': \
+ if (!__is_string) __depth--; \
+ break; \
+ \
+ } \
+ \
+ } \
+ \
+ *__iter = '\0'; \
+ \
+ printf("\n\nBLOCK\n''''\n%s\n''''\n\n", temp); \
+ })
+
+
+#endif /* _TOOLS_D2C_MANUAL_H */