aboutsummaryrefslogtreecommitdiffstats
path: root/7_2/main.c
diff options
context:
space:
mode:
authorjustanothercatgirl <sotov2070@gmail.com>2024-10-17 17:38:07 +0300
committerjustanothercatgirl <sotov2070@gmail.com>2024-10-17 17:38:07 +0300
commit82ec99f51b2b3b7a7b36b43b22df07ec503158b8 (patch)
tree4b308e68145ff124c50c7a5d4ebec8f0060d35e6 /7_2/main.c
parent5d294755542190ac5135af8e120e313b55828625 (diff)
task7 initial commit
Diffstat (limited to '7_2/main.c')
-rw-r--r--7_2/main.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/7_2/main.c b/7_2/main.c
new file mode 100644
index 0000000..5411ecf
--- /dev/null
+++ b/7_2/main.c
@@ -0,0 +1,44 @@
+#include <X11/X.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "input.h"
+#include "drawable.h"
+#include "figure.h"
+
+long fatness = 1; // пока никак не используется
+
+int sx = 100, sy = 100;
+
+int main(int argc, char *argv[]) {
+ char file[256] = {};
+ if (argc >= 2) {
+ size_t len = strlen(argv[1]);
+ memcpy(file, argv[1], len > 255 ? 255 : len);
+ } else {
+ printf("введите файл: ");
+ scanf("%255s", file);
+ }
+ char x11 = 0;
+ for (int i = 0; i < argc; ++i) {
+ if (!strcmp("-X", argv[i])) x11 = 1;
+ }
+ struct figure *fs = read_file(file);
+ struct drawable d = x11 ? drawable_X11(sx, sy) : drawable_plaintxt(sx, sy);
+ if (!fs) {
+ fprintf(stderr, "ERROR: errno %i: %s\n", errno, strerror(errno));
+ return 1;
+ }
+ for (struct figure *i = fs; i->type != F_NONE; ++i)
+ i->draw(i, &d);
+
+ d.show(&d);
+ free(fs);
+ drawable_destroy(&d);
+ return 0;
+}
+