| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/lib/linux/oelnx_os.h $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003/08/26 03:58:13 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * |
| 26 | * $Log: oelnx_os.h,v $ |
| 27 | * Revision 1.1.1.1 2003/08/26 03:58:13 kevinb |
| 28 | * initial 1.5 import |
| 29 | * |
| 30 | * |
| 31 | * 1 1/07/99 11:14p Jeff |
| 32 | * |
| 33 | * 3 5/15/97 1:48 AM Jeremy |
| 34 | * added define of ASSERT macro to call debugger function, implemented |
| 35 | * more parts of osMacDatabase in header, redefined max-filename, |
| 36 | * directory-name lengths to be correct size |
| 37 | * |
| 38 | * 2 5/9/97 7:15 PM Jeremy |
| 39 | * redefinition of object database class and #defines of some constants |
| 40 | * from the dos world |
| 41 | * |
| 42 | * 1 2/26/97 6:57 PM Jeremy |
| 43 | * Mac OS Specific header/initialization/debug/database stuff |
| 44 | * |
| 45 | * $NoKeywords: $ |
| 46 | */ |
| 47 | |
| 48 | #ifndef OEMAC_OS_H |
| 49 | #define OEMAC_OS_H |
| 50 | |
| 51 | #define ASSERT(x) \ |
| 52 | do { \ |
| 53 | if (!(x)) \ |
| 54 | debug_break(); \ |
| 55 | } while (0) |
| 56 | |
| 57 | // ANSI Headers |
| 58 | #include <string.h> |
| 59 | |
| 60 | // Macintosh Headers |
| 61 | #include <Files.h> |
| 62 | |
| 63 | class osMacObject : public osObject { |
| 64 | protected: |
| 65 | virtual void os_init(void); // mac os specific initialization |
| 66 | |
| 67 | public: |
| 68 | osMacObject(void); |
| 69 | virtual ~osMacObject(void); // mac os specific shutdown |
| 70 | |
| 71 | // parent_os is the osObject that is the parent of this new object. |
| 72 | // info is a device dependent structure passed in using device independent parms. |
| 73 | virtual void init(osObject *parent_os, void *info); |
| 74 | virtual bool create(osObject *parent_os, void *info); |
| 75 | |
| 76 | // returns a packet with a code telling us either to quit or that we are in some |
| 77 | // sort of idle state, which means we perform tasks like a game. |
| 78 | virtual gameos_packet *defer(void); // defers game operation to OS. |
| 79 | |
| 80 | virtual void get_info(void *info, int size_str); |
| 81 | }; |
| 82 | |
| 83 | /* osDatabase |
| 84 | to get info about the application from an OS managed database (or a custom info file) |
| 85 | */ |
| 86 | |
| 87 | class osMacDatabase : public osDatabase { |
| 88 | public: |
| 89 | osMacDatabase(); |
| 90 | virtual ~osMacDatabase(); |
| 91 | |
| 92 | virtual bool init(); |
| 93 | |
| 94 | // creates an empty classification or structure where you can store information |
| 95 | virtual bool create_record(const char *pathname); |
| 96 | |
| 97 | // set current database focus to a particular record |
| 98 | virtual bool lookup_record(const char *pathname); |
| 99 | |
| 100 | // read either an integer or string from the current record |
| 101 | virtual bool read(const char *label, char *entry, int *entrylen); |
| 102 | virtual bool read(const char *label, int *entry); |
| 103 | |
| 104 | // write either an integer or string to a record. |
| 105 | virtual bool write(const char *label, char *entry, int entrylen); |
| 106 | virtual bool write(const char *label, int *entry); |
| 107 | |
| 108 | // get the current user's name from the os |
| 109 | virtual void get_user_name(char *buffer, size_t *size); |
| 110 | |
| 111 | protected: |
| 112 | // Additional Macintosh Functions, return true if successful |
| 113 | virtual bool FillOutPrefsInfo(void); |
| 114 | virtual bool InitPrefsFile(void); |
| 115 | |
| 116 | enum { kMacDatabaseResourceType = 'DatB' }; |
| 117 | virtual bool WriteDataToResourceFork(const char *label, void *entry, int entrylen); |
| 118 | virtual bool ReadDataFromResourceFork(const char *label, void *entry, int *entrylen); |
| 119 | |
| 120 | protected: |
| 121 | bool mInitted; |
| 122 | |
| 123 | OSType mAppSignature; |
| 124 | |
| 125 | // Prefs information |
| 126 | Str255 mPrefsFileName; |
| 127 | Str255 mPrefsFolderName; |
| 128 | OSType mPrefsFileType; |
| 129 | FSSpec mPrefsFileSpec; |
| 130 | int16_t mPrefsFileRefNum; |
| 131 | }; |
| 132 | |
| 133 | /******************************************* |
| 134 | Utility functions specific to the Mac OS |
| 135 | *******************************************/ |
| 136 | |
| 137 | int stricmp(const char *s1, const char *s2); |
| 138 | int strnicmp(const char *s1, const char *s2, int n); |
| 139 | |
| 140 | /******************************************* |
| 141 | Constants/#defines functions specific to the Mac OS |
| 142 | *******************************************/ |
| 143 | #define _MAX_DIR 32 |
| 144 | #define _MAX_FNAME 32 |
| 145 | |
| 146 | // fakeouts from windows/intel |
| 147 | #define _MAX_EXT 4 |
| 148 | #define _MAX_DRIVE 4 |
| 149 | |
| 150 | // Boolean values |
| 151 | #ifndef true |
| 152 | #define true 1 |
| 153 | #endif |
| 154 | #ifndef false |
| 155 | #define false 0 |
| 156 | #endif |
| 157 | |
| 158 | #endif |