diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/glamac_errors.h | 41 | ||||
-rw-r--r-- | include/glass_data.h | 6 |
2 files changed, 47 insertions, 0 deletions
diff --git a/include/glamac_errors.h b/include/glamac_errors.h new file mode 100644 index 0000000..4e7b9d0 --- /dev/null +++ b/include/glamac_errors.h @@ -0,0 +1,41 @@ +/**
+ * glamac_errors.h - Unified error handling for GlaMaC
+ *
+ * Copyright (C) 2025 https://optics-design.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * See the COPYING file for the full license text.
+ */
+#ifndef GLAMAC_ERRORS_H
+#define GLAMAC_ERRORS_H
+
+#include "glamacdef.h"
+
+// Error codes for GlaMaC operations
+typedef enum {
+ GLAMAC_SUCCESS = 0,
+ GLAMAC_ERROR_MEMORY = -1,
+ GLAMAC_ERROR_FILE_NOT_FOUND = -2,
+ GLAMAC_ERROR_FILE_TOO_LARGE = -3,
+ GLAMAC_ERROR_INVALID_JSON = -4,
+ GLAMAC_ERROR_INVALID_PATH = -5,
+ GLAMAC_ERROR_BUFFER_OVERFLOW = -6,
+ GLAMAC_ERROR_MANUFACTURER_NOT_FOUND = -7,
+ GLAMAC_ERROR_NO_GLASSES_FOUND = -8,
+ GLAMAC_ERROR_INVALID_ARGUMENT = -9
+} GlamacResult;
+
+// Convert error code to human-readable string
+const char* glamac_error_string(GlamacResult error);
+
+// Security limits
+#define MAX_JSON_FILE_SIZE (10 * 1024 * 1024) // 10MB limit
+#define MAX_JSON_STRING_LEN 1024 // Max string field length
+#define MAX_PATH_LEN 4096 // Max file path length
+#define MAX_MANUFACTURER_NAME_LEN 64 // Max manufacturer name length
+
+#endif /* GLAMAC_ERRORS_H */
\ No newline at end of file diff --git a/include/glass_data.h b/include/glass_data.h index 277adfa..75aedde 100644 --- a/include/glass_data.h +++ b/include/glass_data.h @@ -14,12 +14,15 @@ #define GLASS_DATA_H
#include "glamacdef.h" // For type definitions
+#include "glamac_errors.h" // For error handling
// Structure to represent an optical glass
typedef struct {
byte name[50];
f32 abbeNumber; // X-axis (vd)
f32 refractiveIndex; // Y-axis (nd)
+ byte glass_code[20]; // Glass code from manufacturer
+ byte manufacturer[20]; // Manufacturer name
} Glass;
// Get number of glasses in the catalog
@@ -40,4 +43,7 @@ void initialize_glass_data(void); // Load glasses from JSON file
b32 load_glasses_from_json(const byte* json_path, const byte* manufacturer_filter);
+// Cleanup glass data resources
+void cleanup_glass_data(void);
+
#endif /* GLASS_DATA_H */
|