summaryrefslogtreecommitdiff
path: root/fluid/file.h
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-01-26 15:23:43 +0100
committerGitHub <noreply@github.com>2023-01-26 15:23:43 +0100
commit179771acd25ee5ff8e36a5fd192682d4d55c52af (patch)
treef7d32685bccef27e64a6f706e7c0e0c9d099c372 /fluid/file.h
parentf314ca75feab8c472a9b136fd25636d2d2da68a7 (diff)
Fixing FLUID file corruption from issue #653 (#662)
Removing all globals in file writer (#653 ) Fix some static analyser complaints Valgrind: handle width==0 in GfxDrivers on Wayland and X11 Don't use `Fl_Input_::static_value`, it accesses previous buffer that may be deleted Project file write encapsulated, removing globals Encapsulating project file reader, removing states in glbals Project i/o increased source code readability
Diffstat (limited to 'fluid/file.h')
-rw-r--r--fluid/file.h61
1 files changed, 48 insertions, 13 deletions
diff --git a/fluid/file.h b/fluid/file.h
index 5470d1b26..457d14e49 100644
--- a/fluid/file.h
+++ b/fluid/file.h
@@ -1,7 +1,7 @@
//
// Fluid file routines for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2021 by Bill Spitzak and others.
+// Copyright 1998-2023 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -21,22 +21,57 @@
#include <FL/fl_attr.h>
-extern double read_version;
+class Fl_Type;
+
extern int fdesign_flip;
-extern int fdesign_magic;
-void write_word(const char *);
-void write_string(const char *,...) __fl_attr((__format__ (__printf__, 1, 2)));
-void write_indent(int n);
-void write_open(int);
-void write_close(int n);
+int read_file(const char *, int merge, Strategy strategy=kAddAsLastChild);
+int write_file(const char *, int selected_only = 0);
-void read_error(const char *format, ...);
-const char *read_word(int wantbrace = 0);
+class Fd_Project_Reader
+{
+protected:
+ FILE *fin;
+ int lineno;
+ const char *fname;
+ char *buffer;
+ int buflen;
+ void expand_buffer(int length);
-int write_file(const char *, int selected_only = 0);
+public:
+ double read_version;
-int read_file(const char *, int merge, Strategy strategy=kAddAsLastChild);
-void read_fdesign();
+public:
+ Fd_Project_Reader();
+ ~Fd_Project_Reader();
+ int open_read(const char *s);
+ int close_read();
+ int read_quoted();
+ void read_children(Fl_Type *p, int paste, Strategy strategy, char skip_options=0);
+ int read_project(const char *, int merge, Strategy strategy=kAddAsLastChild);
+ void read_error(const char *format, ...);
+ const char *read_word(int wantbrace = 0);
+ int read_fdesign_line(const char*& name, const char*& value);
+ void read_fdesign();
+};
+
+class Fd_Project_Writer
+{
+protected:
+ FILE *fout;
+ int needspace;
+
+public:
+ Fd_Project_Writer();
+ ~Fd_Project_Writer();
+ int open_write(const char *s);
+ int close_write();
+ int write_project(const char *filename, int selected_only);
+ void write_word(const char *);
+ void write_string(const char *,...) __fl_attr((__format__ (__printf__, 2, 3)));
+ void write_indent(int n);
+ void write_open(int);
+ void write_close(int n);
+};
#endif // _FLUID_FILE_H