// C Header File // Created 9/28/2002; 3:02:48 PM HANDLE CreateFile (const char *FileName) // Returns a handle, H_NULL in case of error { HANDLE h; SYM_ENTRY *sym_entry; char str[30], *sptr = str; *sptr = 0; while ((*++sptr = *FileName++)); if (!(h = HeapAlloc (HeapMax ()))) return H_NULL; if (!(sym_entry = DerefSym (SymAdd (sptr)))) { HeapFree (h); return H_NULL; } *(long *) HeapDeref (sym_entry->handle = h) = 0x00010000; return h; } void AppendCharToFile (HANDLE h, unsigned char c) { char *base = HeapDeref (h); unsigned short len = *(unsigned short *) base; if (len > HeapSize (h) - 10) return; *(unsigned short *) base = len + 1; base[len + 2] = c; } void AppendBlockToFile (HANDLE h, void *addr, unsigned short len) { unsigned short i; for (i = len; i; i--) AppendCharToFile (h, *((unsigned char *) addr)++); } void CloseFile (HANDLE h) { AppendCharToFile (h, 0); AppendCharToFile (h, 'o'); AppendCharToFile (h, 'l'); AppendCharToFile (h, 'e'); AppendCharToFile (h, 'v'); AppendCharToFile (h, 0); AppendCharToFile (h, OTH_TAG); HeapUnlock (h); HeapRealloc (h, *(unsigned short *) HeapDeref (h) + 3); } void CloseFolderFile (HANDLE h) { AppendCharToFile (h, 0); AppendCharToFile (h, 'o'); AppendCharToFile (h, 'f'); AppendCharToFile (h, 0); AppendCharToFile (h, OTH_TAG); HeapUnlock (h); HeapRealloc (h, *(unsigned short *) HeapDeref (h) + 3); }