summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h65
1 files changed, 62 insertions, 3 deletions
diff --git a/src/common.h b/src/common.h
index e2c398c..9a68531 100644
--- a/src/common.h
+++ b/src/common.h
@@ -23,6 +23,23 @@
#ifndef _COMMON_H
#define _COMMON_H
+#include <sys/types.h>
+
+#include <limits.h>
+#include <stdint.h>
+
+#ifndef OFF_MAX
+ #define OFF_MAX (off_t)((1ULL << (sizeof(off_t) * CHAR_BIT - 1)) - 1)
+#endif
+
+extern int interactive;
+extern int write_immed;
+extern int atari_format; /* Use Atari variation of MS-DOS FS format */
+
+/* program_name used for printing messages; no name will be printed when it is
+ * left as NULL */
+extern const char *program_name;
+
void die(const char *msg, ...)
__attribute((noreturn, format(printf, 1, 2)));
@@ -50,9 +67,51 @@ int min(int a, int b);
/* Returns the smaller integer value of a and b. */
-char get_key(const char *valid, const char *prompt);
+int xasprintf(char **strp, const char *fmt, ...)
+ __attribute((format(printf, 2, 3)));
+
+/* Runs asprintf() and terminates the program if it fails. */
+
+int get_choice(int noninteractive_result, const char *noninteractive_msg,
+ int choices, ...);
+
+/*
+ * Display a numbered list of choices and accept user input to select one. If
+ * interactive is false, it will instead print noninteractive_msg and return
+ * noninteractive_result. The number of options must be given in choices and
+ * must be more than one and less then ten.
+ *
+ * The variable arguments are choices times <int val, const char *desc>, where
+ * val is the value that is returned when the user selects this option and desc
+ * is the string describing this option.
+ */
+
+char *get_line(const char *prompt, char *dest, size_t length);
+
+/*
+ * Display prompt and read a line, placing it in dest with at most length-1
+ * characters plus a null byte. This behaves like printing a prompt and fgets()
+ * afterwards with the addition of temporarily enabling canonical input mode
+ * with echo if needed.
+ */
+
+void check_atari(void);
+
+/*
+ * ++roman: On m68k Linux, check if this is an Atari; if yes, turn on Atari
+ * variant of MS-DOS filesystem by default.
+ */
+
+uint32_t generate_volume_id(void);
+
+/*
+ * Generate a 32 bit volume ID
+ */
+
+int validate_volume_label(char *doslabel);
-/* Displays PROMPT and waits for user input. Only characters in VALID are
- accepted. Terminates the program on EOF. Returns the character. */
+/*
+ * Validate volume label
+ */
#endif