00001 /**** 00002 * \file miodefns.h <mi32/miodefns.h> 00003 * \brief Header file for Mio...() functions 00004 * 00005 * NOTE: For compatibility, this file MUST be usable in C code. Any 00006 * C++ specific features must be inside #ifdef __cplusplus/#endif 00007 * blocks. This includes default parameters. 00008 * Many of our 3rd party libraries are modified to use Mio functions 00009 * for file IO and must be able to include this file and some of them 00010 * can't be compiled for C++ 00011 * 00012 * \if NODOC 00013 * $Id: miodefns.h_v 1.177 2004/07/15 14:24:36 dwilliss Exp $ 00014 * 00015 * $Log: miodefns.h_v $ 00016 * Revision 1.177 2004/07/15 14:24:36 dwilliss 00017 * Moved a prototype to allow compalation under non-C++ conditions 00018 * 00019 * Revision 1.176 2004/03/04 18:07:10 mju 00020 * Change MmFree from macro to inline template function. 00021 * 00022 * Revision 1.175 2004/02/27 20:02:34 scowan 00023 * DO not let the include file echo the deprecated items. 00024 * 00025 * Revision 1.174 2004/02/27 19:49:37 scowan 00026 * Added more windows depreacted functions (Old Mio calls). 00027 * 00028 * Revision 1.173 2003/11/28 15:51:55 scowan 00029 * Removed unused functions. 00030 * 00031 * Revision 1.172 2003/11/27 00:29:33 scowan 00032 * mio unlink is now retired. 00033 * 00034 * Revision 1.171 2003/11/12 20:50:49 mju 00035 * Add GetLastErrCode. 00036 * 00037 * Revision 1.170 2003/10/08 17:32:40 mju 00038 * Don't include mtimer header as confuses compiler. 00039 * 00040 * Revision 1.169 2003/10/08 16:41:02 mju 00041 * Move timer stuff to own header, include that header unless no_deprecated. 00042 * Deprecate MioUnlink. 00043 * 00044 * Revision 1.168 2003/10/06 16:19:24 scowan 00045 * Removed more unused flags. 00046 * 00047 * Revision 1.167 2003/10/06 16:00:31 scowan 00048 * Made mode functions deprecated. 00049 * 00050 * Revision 1.166 2003/10/06 14:36:06 mju 00051 * Remove obsolete prototypes. 00052 * 00053 * Revision 1.165 2003/09/22 15:09:34 mju 00054 * Move most deprecated methods to 'removed' sections. 00055 * 00056 * Revision 1.164 2003/09/15 13:49:56 fileserver!dwilliss 00057 * Doxygen 00058 * 00059 * Revision 1.162 2003/07/09 14:36:48 mju 00060 * Use std name for classlibexport. 00061 * 00062 * Revision 1.161 2003/07/09 14:02:58 dwilliss 00063 * Don't leave CLASSLIBEXPORT defined 00064 * 00065 * Revision 1.160 2003/07/09 14:00:30 dwilliss 00066 * Eliminate obsolete Mac OS 9 stuff 00067 * 00068 * Revision 1.159 2003/07/03 20:37:08 scowan 00069 * Deprecated or removed functions. 00070 * 00071 * Revision 1.158 2003/07/03 16:48:29 mju 00072 * Delete many obsolete prototypes. 00073 * 00074 * Revision 1.157 2003/07/03 15:22:45 mju 00075 * Remove prototypes from fdspace module. 00076 * 00077 * Revision 1.156 2003/05/28 16:40:36 mju 00078 * Move filelistuc stuff to 'removed' section. 00079 * 00080 * Revision 1.155 2003/05/23 17:26:59 mju 00081 * Deprecate/remove more stuff. 00082 * 00083 * Revision 1.154 2003/05/22 16:42:25 mju 00084 * Deprecate GetRefFile, Rename(). 00085 * 00086 * Revision 1.153 2003/05/21 22:13:54 mju 00087 * Move more stuff to 'removed' section. 00088 * 00089 * Revision 1.152 2003/05/20 18:00:45 mju 00090 * Deprecate more stuff moved to MISYSTEM. 00091 * 00092 * Revision 1.151 2003/05/16 15:27:37 mju 00093 * Move some deprecated stuff to 'removed' section so still export from DLL but can't use in new builds. 00094 * 00095 * Revision 1.150 2003/05/16 13:47:40 mju 00096 * Restore MioGetExeFile when building DLL as twmi18n uses. 00097 * 00098 * Revision 1.149 2003/05/15 14:50:20 mju 00099 * Remove MioGetExeFile. 00100 * 00101 * Revision 1.148 2003/05/12 16:34:47 scowan 00102 * Updated deprecated stuff. 00103 * 00104 * Revision 1.147 2003/05/09 17:05:10 scowan 00105 * More deprecated stuff. 00106 * 00107 * Revision 1.146 2003/05/09 15:43:50 scowan 00108 * Removed all retired functions, deprecated search list functions and structures. 00109 * 00110 * Revision 1.145 2003/05/09 14:24:59 scowan 00111 * Removed split path code. 00112 * 00113 * Revision 1.144 2002/09/18 17:11:06 dwilliss 00114 * Never mind... I was going to add a SETERRPOSNDISABLE class, but somebody 00115 * already created the same thing and called it ERRORPOSNDISABLE 00116 * 00117 * Revision 1.143 2002/09/09 16:35:21 mju 00118 * Remove builderrstr fns. 00119 * 00120 * Revision 1.142 2002/09/09 14:38:23 mju 00121 * Retire previously deprecated stuff. 00122 * Remove getdrivelist fn. 00123 * 00124 * Revision 1.141 2002/09/05 14:13:03 scowan 00125 * define deprecated or miodll. 00126 * 00127 * Revision 1.140 2002/07/05 14:33:02 dwilliss 00128 * Don't leave USEEXPORTPRAGMA defined after end of include 00129 * 00130 * Revision 1.139 2002/04/26 15:00:45 mju 00131 * Still need builderrstr/uc prototypes when compiling RVCSYS. 00132 * 00133 * Revision 1.138 2002/04/25 22:08:19 mju 00134 * Remove comment re deprecate_varargs from log. 00135 * 00136 * Revision 1.137 2002/04/25 21:48:26 mju 00137 * Retire builderrstr. 00138 * 00139 * Revision 1.136 2002/04/05 15:09:32 mju 00140 * Retire BuildErrstrUCV except when compiling MISYSTEM or RVCSYS DLLs. 00141 * 00142 * Revision 1.131 2002/03/27 16:36:34 mju 00143 * Deprecate varargs in ErrStr stuff. 00144 * Add GetErrString(). 00145 * 00146 * Revision 1.130 2002/03/01 20:15:20 dwilliss 00147 * MioGetMacFileType prototype should be defined for MacOS X too 00148 * 00149 * Revision 1.129 2002/01/14 17:30:04 mju 00150 * Remove Get/SetModuleFilename functions. 00151 * 00152 * Revision 1.127 2001/12/11 00:13:52 scowan 00153 * Deprecated more mio functions that deal with file paths. 00154 * 00155 * Revision 1.126 2001/12/06 20:46:19 scowan 00156 * Moved long list of functions to DEPRECATED status and one function to RETIRED status. 00157 * Removed pseudo RETIRED status functions (FILESIZE64) outright. 00158 * 00159 * Revision 1.125 2001/11/26 22:01:16 dwilliss 00160 * heapsort fix for Mac OS X 00161 * 00162 * Revision 1.124 2001/10/03 20:07:58 dwilliss 00163 * Damn it! Don't add default parameters to a funcion without also adding 00164 * an #ifdef __cplusplus and a prototype without the defaults if it's not 00165 * C++. We DO still have non-C++ code! 00166 * 00167 * Revision 1.123 2001/10/02 16:09:06 mju 00168 * Add defaults for filter func/data for MioCopyFile. 00169 * 00170 * Revision 1.121 2001/09/12 19:15:44 scowan 00171 * Added is running win 2000. 00172 * 00173 * Revision 1.120 2001/06/22 20:37:58 mju 00174 * Use const in MioMakeDir and MioMakePathDirs. 00175 * 00176 * Revision 1.119 2001/05/23 22:43:24 scowan 00177 * Added class to disable and re-enable error position reporting. 00178 * 00179 * Revision 1.118 2001/05/16 17:49:07 dwilliss 00180 * Put major warning at the top of the file. 00181 * 00182 * Revision 1.117 2001/05/14 17:26:07 dwilliss 00183 * Default paramerters MUST be included ONLY if __cplusplus is defined 00184 * XmHTML includes this and can't be compiled for C++ 00185 * 00186 * Revision 1.116 2001/05/14 14:03:00 mju 00187 * Add defaults and comments for Mio Seek64. 00188 * 00189 * Revision 1.115 2001/05/04 19:58:55 scowan 00190 * Added more const and new platform. 00191 * 00192 * Revision 1.114 2001/03/01 16:37:48 scowan 00193 * Change list name to alist for std namespace. 00194 * 00195 * Revision 1.1 1994/08/03 22:39:33 scowan 00196 * Initial revision 00197 * \endif 00198 ****/ 00199 00200 #ifndef INC_MI32_MIODEFNS_H 00201 #define INC_MI32_MIODEFNS_H 00202 00203 #ifndef INC_STDARG_H 00204 #include <stdarg.h> 00205 #define INC_STDARG_H 00206 #endif 00207 00208 #ifndef INC_STDIO_H 00209 #include <stdio.h> 00210 #define INC_STDIO_H 00211 #endif 00212 00213 #ifndef INC_STDLIB_H 00214 #include <stdlib.h> //! for void free(void*) 00215 #define INC_STDLIB_H 00216 #endif 00217 00218 #ifndef INC_MI32_STDDEFNS_H 00219 #include <mi32/stddefns.h> 00220 #endif 00221 00222 #ifdef MISYSTEMDLL 00223 #define LIBEXPORT MI_DLLEXPORT 00224 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT 00225 #else 00226 #define LIBEXPORT MI_DLLIMPORT 00227 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT 00228 #endif 00229 00230 00231 #ifdef WIN32 00232 #pragma warning (disable:4996) 00233 #endif 00234 00235 #ifdef __cplusplus 00236 class MISTRING; 00237 #endif 00238 00239 #define MioFLAG_OBCFileName 0x00000080 //!< Was OneByteChar flag, now removed 00240 00241 #if defined(__cplusplus) 00242 extern "C" { 00243 #endif 00244 00245 00246 //!:Associate with "Error Reporting Functions" 00247 //!\addtogroup ErrorPosn Error Reporting Functions 00248 //!@{ 00249 00250 //! Clear the last reported error and the error stack. 00251 LIBEXPORT void ClearLastErr (void); 00252 00253 //! Get the details string set by SetErrDetails(). 00254 //! Do not free the returned string. 00255 LIBEXPORT const UNICODE* GetErrDetails (); 00256 00257 #if defined(__cplusplus) 00258 00259 //! Get MISTRING reference to current error message. 00260 //! This allows subsequent use of the << operator on the string to substitute 00261 //! or append additional error values for %-format or $-position codes. 00262 LIBEXPORT MISTRING& GetErrString ( 00263 ); 00264 00265 //! Get the last error message (Unicode). 00266 //! Do not free the returned string. 00267 LIBEXPORT const UNICODE* GetErrStrUC ( 00268 ERRVALUE errcode, //!< Error code to retrieve string for 00269 int *errlevel = 0 //!< Error level returned (NULL if don't care) 00270 ); 00271 00272 00273 //! Get the first line of the last error message (Unicode). 00274 //! Do not free the returned string. 00275 LIBEXPORT const UNICODE* GetErrStrLine1UC ( 00276 ERRVALUE errcode, //!< Error code to retrieve string for 00277 int *errlevel = 0 //!< Error level returned (NULL if don't care) 00278 ); 00279 00280 //! Determine if error position recording is disabled. 00281 //! @return true if disabled, false if not. 00282 LIBEXPORT bool IsErrPosnDisabled (); 00283 00284 #else 00285 #ifndef GENERATING_DOXYGEN_OUTPUT 00286 //! Version of above without default parameter for 3rd party libs 00287 //! that don't compile with C++ but that we still have to patch 00288 //! to use Mio 00289 00290 LIBEXPORT const UNICODE* GetErrStrUC ( 00291 ERRVALUE errcode, //!< Error code to retrieve string for 00292 int *errlevel //!< Error level returned (NULL if don't care) 00293 ); 00294 00295 LIBEXPORT const UNICODE* GetErrStrLine1UC ( 00296 ERRVALUE errcode, //!< Error code to retrieve string for 00297 int *errlevel //!< Error level returned (NULL if don't care) 00298 ); 00299 00300 #endif // GENERATING_DOXYGEN_OUTPUT 00301 #endif 00302 00303 //! Get last error code. 00304 LIBEXPORT ERRVALUE GetLastErrCode (); 00305 00306 //! Set the details string for an error. 00307 //! This can be used to report any extra details about an error. 00308 //! If set, the standard error dialog will have a "detial..." button 00309 //! which will let the user see the details. 00310 LIBEXPORT void SetErrDetails ( 00311 const UNICODE* 00312 ); 00313 00314 #ifndef GENERATING_DOXYGEN_OUTPUT 00315 LIBEXPORT int _SetErrPosn (int, const char*, int); 00316 LIBEXPORT int _SetErrPosnC (int, const char*, int); 00317 #endif // GENERATING_DOXYGEN_OUTPUT 00318 00319 //! Record an error code and it's position. 00320 //! 00321 //! Note, this is really a macro which calls an internal function 00322 //! and also passes it RCSID and __LINE__ 00323 //! For this to work, the following line must exist near the top 00324 //! of the module (just below the main comment block) 00325 //! @code 00326 //! #define RCSID "@(#)$Id: miodefns.h_v 1.177 2004/07/15 14:24:36 dwilliss Exp $" 00327 //! @endcode 00328 //! 00329 //! Note: The example above shows what the RCSID for this include file looks 00330 //! like. If you're using RCS, it will fill in everything between the <tt>Id:</tt> and the <tt>$</tt>. If you're not using RCS, change miodefns.h to the name 00331 //! of the source module. The number after that is the revision number which 00332 //! TNT will show in the error message. The rest of the RCSID is ignored. 00333 #define SetErrPosn(e) _SetErrPosn(e,RCSID,__LINE__) 00334 00335 //! Clear current error stack and set error position. 00336 //! 00337 //! Same as SetErrPosn(), but clears the error stack first. 00338 //! 00339 //! @see SetErrPosn() 00340 #define SetErrPosnC(e) _SetErrPosnC(e,RCSID,__LINE__) 00341 00342 00343 //! Set the current error position and goto Error label. 00344 //! 00345 //! Note, This is really a #define macro. 00346 //! 00347 //! It does the same thing as SetErrPosn(), then does a 00348 //! <tt>goto Error;</tt> 00349 #define SetErrPosnGoto(e) { err=SetErrPosn(e); goto Error; } 00350 00351 //! Clear the error stack, set the current error position and goto Error label. 00352 //! 00353 //! Note, This is really a #define macro. 00354 //! It does the same thing as SetErrPosnC(), then does a 00355 //! <tt>goto Error;</tt> 00356 #define SetErrPosnGotoC(e) { err=SetErrPosnC(e); goto Error; } 00357 00358 00359 //! Disable error position reporting. 00360 //! 00361 //! This is important when cleaning up after an error. It often happens that 00362 //! if you get an error, you need to cleanup (close files, etc) before returning. 00363 //! If something in your cleanup code also causes an error, it will wipe out 00364 //! the error trace that you're trying to report. Therefore, always bracket 00365 //! cleanup code with SetErrPosnDiaable()/SetErrPosnEnable(). 00366 LIBEXPORT void SetErrPosnDisable (void); 00367 00368 //! Reenable error position reporting. 00369 //! 00370 //! @see SetErrPosnDisable() 00371 LIBEXPORT void SetErrPosnEnable (void); 00372 00373 //!@} 00374 00375 #if defined(__cplusplus) 00376 //! Disable and enable error positioning using this class and scoping 00377 00378 class ERRORPOSNDISABLE { 00379 public: 00380 ERRORPOSNDISABLE ( 00381 ) { SetErrPosnDisable(); } 00382 00383 ~ERRORPOSNDISABLE ( 00384 ) { SetErrPosnEnable(); } 00385 }; 00386 00387 #endif 00388 00389 00390 #ifdef MAC_OSX 00391 //! Mac OSX standard library defines their own heapsort which takes a 00392 //! different compare function. This makes sure we link to ours, not 00393 //! theirs. 00394 #define heapsort heapsort_MicroImages 00395 #endif 00396 00397 //!:Associate with "Sorting Functions" 00398 //!\addtogroup sort Sorting Functions 00399 //!@{ 00400 00401 //! Memory based heapsort. 00402 //! 00403 //! Sorts an array in memory. Assumes it can use memcpy() to swap items. 00404 LIBEXPORT void heapsort ( 00405 void* array, //!< Array to sort 00406 INT32 n, //!< Number of elements in array 00407 INT32 size, //!< sizeof() each element 00408 int (*compare)(void*a, void*b, void*hookdata), //! Compare function. Return 1 if *a <= *b. 00409 void* hookdata //!< Passed as 3rd parameter to compare function 00410 ); 00411 00412 //! Generic Heapsort. 00413 LIBEXPORT int HeapSortGen ( 00414 INT32 n, //!< Number of items to sort 00415 int (*compare)(INT32 a, INT32 b, void* hookdata), //! Return 1 if item a <= item b 00416 int (*swap)(INT32 a, INT32 b, void* hookdata), //! Swap two items 00417 void* hookdata //!< Passed as 3rd parameter to compare and swap functions 00418 ); 00419 //!@} 00420 00421 00422 //!:Associate with "Math Functions" 00423 //!\addtogroup math Math Functions 00424 //!@{ 00425 00426 //! Returns the IEEE representation of Not A Number. 00427 LIBEXPORT double IEEE_NaN (void); 00428 00429 //! Returns the IEEE representation of Infinity. 00430 LIBEXPORT double IEEE_Infinity (void); 00431 00432 //!@} 00433 00434 //!:Associate with "Mm Functions (Memory Allocation)" 00435 //!\addtogroup Mm Memory Allocation Functions (Mm) 00436 //!@{ 00437 00438 /* 00439 * The following macro changed 19-Nov-96 DCW. The do -- while (0) looks silly but the body will be executed exactly 00440 * once. The compiler will optimize out the fact that it looks like a loop. The advantage is that you can always put 00441 * a ';' after it, even if the next thing after it is an "else". 00442 * 00443 */ 00444 //! Free a pointer and set it's value to NULL. 00445 #if defined(__cplusplus) 00446 } 00447 template <class _CT> inline void MmFree(_CT *& p) { if (p != 0) { free(p); p = NULL; } } 00448 extern "C" { 00449 #else 00450 #define MmFree(p) do {if ((p) != NULL) {free((p));(p) = NULL;}} while (0) 00451 #endif 00452 00453 //! Allocate memory - Return error on failure. 00454 //! 00455 //! Returns error code if allocation fails. 00456 //! Example: 00457 //! @code 00458 //! UINT8* buf; 00459 //! err = MmAlloc((void**)&buf, size); 00460 //! if (err < 0) return(SetErrPosn(err)); 00461 LIBEXPORT ERRVALUE MmAlloc ( 00462 void** ptr, //!< Pointer to memory allocated and returned 00463 int size //!< Size to allocate in bytes 00464 ); 00465 00466 //! Allocate and clear memory - Return error on failure. 00467 //! 00468 //! @see MmAlloc() 00469 LIBEXPORT ERRVALUE MmAllocC ( 00470 void** ptr, //!< Pointer to memory allocated and returned 00471 int size //!< Size to allocate in bytes 00472 ); 00473 00474 //! Allocate and clear memory - Throw exception of failure. 00475 //! 00476 //! @see MmAlloc() 00477 LIBEXPORT void MmAllocCExc ( 00478 void** ptr, //!< Pointer to memory allocated and returned 00479 int size //!< Size to allocate in bytes 00480 ); 00481 00482 //! Allocate memory - Throw exception of failure. 00483 //! 00484 //! @see MmAlloc() 00485 LIBEXPORT void MmAllocExc ( 00486 void** ptr, //!< Pointer to memory allocated and returned 00487 int size //!< Size to allocate in bytes 00488 ); 00489 00490 //! Resize memory buffer, retaining existing contents - Return error on failure. 00491 //! 00492 //! @see MmAlloc() 00493 LIBEXPORT ERRVALUE MmRealloc ( 00494 void** ptr, //!< Pointer to memory to reallocate and returned 00495 int newsize //!< New size in bytes 00496 ); 00497 00498 #if defined(__cplusplus) 00499 //! Resize memory buffer and clear new part - Return error on failure. 00500 //! 00501 //! @see MmAlloc() 00502 LIBEXPORT ERRVALUE MmReallocC ( 00503 void** ptr, //!< Pointer to memory to reallocate and returned 00504 int newsize, //!< New size in bytes 00505 int oldsize = 0 //!< Size of portion to not clear in bytes 00506 ); 00507 #else //!< normal "C" 00508 LIBEXPORT ERRVALUE MmReallocC ( 00509 void** ptr, //!< Pointer to memory to reallocate and returned 00510 int newsize, //!< New size in bytes 00511 int oldsize //!< Size of portion to not clear in bytes 00512 ); 00513 #endif 00514 00515 #if defined(__cplusplus) 00516 //! Resize memory buffer and clear new part - Throw exception on failure. 00517 //! 00518 //! @see MmAlloc() 00519 LIBEXPORT void MmReallocCExc ( 00520 void** ptr, //!< Pointer to memory to reallocate and returned 00521 int newsize, //!< New size in bytes 00522 int oldsize = 0 //!< Size of portion to not clear in bytes 00523 ); 00524 #endif 00525 00526 #if defined(__cplusplus) 00527 //! Resize memory buffer, discarding existing contents - Return error on failure. 00528 //! 00529 //! @see MmAlloc() 00530 inline ERRVALUE MmReallocD ( 00531 void** ptr, //!< Pointer to memory to reallocate and returned 00532 int newsize //!< New size in bytes 00533 ) { 00534 if (*ptr != 0) { 00535 free(*ptr); 00536 } 00537 return (MmAlloc(ptr,newsize)); 00538 } 00539 #endif 00540 00541 #if defined(__cplusplus) 00542 //! Resize memory buffer, discarding existing contents - Throw exception on failure. 00543 //! 00544 //! @see MmAlloc() 00545 inline void MmReallocDExc ( 00546 void** ptr, //!< Pointer to memory to reallocate and returned 00547 int newsize //!< New size in bytes 00548 ) { 00549 if (*ptr != 0) { 00550 free(*ptr); 00551 } 00552 MmAllocExc(ptr,newsize); 00553 return; 00554 } 00555 #endif 00556 00557 #if defined(__cplusplus) 00558 //! Resize memory buffer, retaining existing contents - Throw exception on failure. 00559 //! 00560 //! @see MmAlloc() 00561 LIBEXPORT void MmReallocExc ( 00562 void** ptr, //!< Pointer to memory to reallocate and returned 00563 int newsize //!< New size in bytes 00564 ); 00565 #endif 00566 00567 //!@} 00568 00569 //!:Associate with "Mio (File I/O and system) functions" 00570 //!\addtogroup Mio File I/O and system functions (Mio) 00571 //!@{ 00572 00573 //! Close a file. 00574 //! \deprecated Replaced by FILE_RAW::Close(); 00575 DEPRECATED LIBEXPORT int MioClose ( 00576 int handle //!< Handle to open file 00577 ); 00578 00579 //! Get size of an open file. 00580 //! \deprecated Replaced by FILE_RAW::GetSize(); 00581 //! 00582 //! @return Size of open file. 00583 //! 00584 //! Made long instead of INT32 intentionally. 00585 //! This function is needed because the Mac does not have a fstat(). 00586 DEPRECATED LIBEXPORT long MioGetOpenFileSize ( 00587 int handle //!< Open file descriptor 00588 ); 00589 00590 //! Get size of an open file. 00591 //! \deprecated Replaced by FILE_RAW::GetSize(); 00592 //! 00593 //! @return Size of open file. 00594 DEPRECATED LIBEXPORT INT64 MioGetOpenFileSize64 ( 00595 int handle 00596 ); 00597 00598 //! Get size of an open file pointer (FILE *). 00599 //! 00600 //! @return Size of open file. 00601 //! 00602 //! Made long instead of INT32 intentionally. 00603 //! This function is needed because the Mac does not have a fstat(). 00604 LIBEXPORT long MioGetOpenFPSize ( 00605 FILE *fp //!< Open FILE pointer 00606 ); 00607 00608 //! Read a string from a file created on ANY platform. 00609 //! 00610 //! @return Length read, error code or -1 if EOF. 00611 //! 00612 //! This function reads a line of text file up to the 'newline' character 00613 //! or (len - 1), whichever is first. The 'newline' character is handled 00614 //! irregardless of the platform run on and the platform that created the 00615 //! text file. The 'newline' charact is NOT appended onto the string. 00616 //! If this function gets to the 'end of file', -1 is returned. The 00617 //! length of the string should be 'len + 1' for reading in the string 00618 //! and a place for the string terminator. This behavior is the same as fgets(). 00619 LIBEXPORT INT32 MioGetStr ( 00620 char *str, //!< String to read into 00621 INT32 len, //!< Maximum length to read - 1 00622 FILE *f //!< File handle 00623 ); 00624 00625 00626 #ifdef __cplusplus 00627 00628 //! Open an existing file. 00629 //! 00630 //! Return value depends on whether 'fp' is NULL. If it is, this function 00631 //! uses open() to open the file and determines open mode based on the mode 00632 //! string. The handle is in the return value. Acceptable modes are shown below: 00633 //! 00634 //! Modes and equivalent: 00635 //! "r" Read-only 00636 //! "r+" Read-write 00637 //! "w" New file (no CR/LF translation) 00638 //! "wt" New file (with CR/LF translation) 00639 //! 00640 //! If 'fp' is not NULL, fopen() is used to open the file and the return value 00641 //! is 0 if fopen was sucessful, otherwise an error is returned. 00642 //! The flag is called MioFLAG_NoBuildErrStr. MioOpen will not build 00643 //! an error string if this flag is specified. Used in FindErrStr() in geterrst.c. 00644 LIBEXPORT int MioOpen ( 00645 const UNICODE *filename, //!< File to open 00646 const char *mode, //!< fopen() type mode string 00647 FILE **fp = 0, //!< File pointer RETURNED, can be NULL 00648 UINT32 flag = 0 //!< Flag 00649 ); 00650 00651 #else 00652 00653 //! Open an existing file. 00654 //! 00655 //! Return value depends on whether 'fp' is NULL. If it is, this function 00656 //! uses open() to open the file and determines open mode based on the mode 00657 //! string. The handle is in the return value. Acceptable modes are shown below: 00658 //! 00659 //! Modes and equivalent: 00660 //! "r" Read-only 00661 //! "r+" Read-write 00662 //! "w" New file (no CR/LF translation) 00663 //! "wt" New file (with CR/LF translation) 00664 //! 00665 //! If 'fp' is not NULL, fopen() is used to open the file and the return value 00666 //! is 0 if fopen was sucessful, otherwise an error is returned. 00667 //! The flag is called MioFLAG_NoBuildErrStr. MioOpen will not build 00668 //! an error string if this flag is specified. Used in FindErrStr() in geterrst.c. 00669 LIBEXPORT int MioOpen ( 00670 const UNICODE *filename, //!< File to open 00671 const char *mode, //!< fopen() type mode string 00672 FILE **fp, //!< File pointer RETURNED, can be NULL 00673 UINT32 flag //!< Flag 00674 ); 00675 00676 #endif 00677 00678 //! Read from an open file. 00679 //! \deprecated Replaced by FILE_RAW::Read(); 00680 //! 00681 //! @return "Size" or error code. 00682 //! 00683 //! If less than number of requested bytes are read, EDiskReadErr will be returned. 00684 DEPRECATED LIBEXPORT INT32 MioRead ( 00685 int handle, //!< Handle from MioOpen() 00686 void *data, //!< Buffer to contain data read 00687 INT32 size //!< Number of bytes to read 00688 ); 00689 00690 //! Seek to a position within an open file. 00691 //! \deprecated Replaced by FILE_RAW::Seek(); 00692 //! 00693 //! @return New position in the file. 00694 DEPRECATED LIBEXPORT INT32 MioSeek ( 00695 int handle, //!< Open file handle from MioOpen(). 00696 INT32 offset, //!< Where to seek to 00697 int type //!< SEEK_CUR, SEEK_SET, SEEK_END 00698 ); 00699 00700 //! Seek to a spot and read the data. 00701 //! \deprecated Replaced by FILE_RAW::SeekAndRead(); 00702 //! 00703 //! @return NOTE: This function returns an error if < size is read in. 00704 DEPRECATED LIBEXPORT INT32 MioSeekAndRead ( 00705 int handle, //!< Open file handle from MioOpen(). 00706 long offset, //!< Where to seek to (SEEK_SET) 00707 void *data, //!< Buffer to read into 00708 INT32 size //!< Amount to read in bytes 00709 ); 00710 00711 //! Seek to a spot and write the data. 00712 //! \deprecated Replaced by FILE_RAW::SeekAndWrite(); 00713 //! 00714 //! @return Amount read or error code if < 0. 00715 //! 00716 //! NOTE: This function returns an error if < size is written out. 00717 DEPRECATED LIBEXPORT INT32 MioSeekAndWrite ( 00718 int handle, //!< Open file handle from MioOpen(). 00719 long offset, //!< Where to seek to (SEEK_SET) 00720 const void*const data, //!< The data to write from 00721 INT32 size //!< Amount to read in bytes 00722 ); 00723 00724 #if defined(__cplusplus) 00725 //! Current position in the file (macro). 00726 //! @return Position in the file or error. 00727 inline INT32 MioTell ( 00728 int handle //!< Open file handle from MioOpen(). 00729 ) { return (MioSeek(handle, 0, SEEK_CUR)); } 00730 #else 00731 #define MioTell(h) MioSeek((h), 0, SEEK_CUR) 00732 #endif 00733 00734 //! Write to an open file. 00735 //! \deprecated Replaced by FILE_RAW::Write(); 00736 //! 00737 //! @return "Size" or error code. 00738 //! 00739 //! If the OPSYS write() call writes less than requested, EDiskWriteErr will 00740 //! be returned. 00741 DEPRECATED LIBEXPORT INT32 MioWrite ( 00742 int handle, //!< Handle from MioOpen() 00743 const void*const data, //!< The data to write from 00744 INT32 size //!< The amount to write 00745 ); 00746 00747 //===================================================================================================================== 00748 // DEPRECATED - Begin 00749 00750 #if !defined(NO_DEPRECATED) || defined(MISYSTEMDLL) 00751 00752 #endif // Deprecated items 00753 00754 //!@} 00755 00756 // DEPRECATED - End 00757 //===================================================================================================================== 00758 // RETIRED - Begin 00759 00760 #if defined(ALLOW_RETIRED) || defined(MISYSTEMDLL) 00761 00762 //! Search for a specific reference file. 00763 //! \deprecated Replaced by FILEFIND::LocateReferenceFile() 00764 //! 00765 //! @return Complete path to the file or NULL if not found. 00766 //! 00767 //! Flag values: 00768 //! MioFLAG_OBCFileName Use one-byte-character (ASCII) filename for searching 00769 //! MioFLAG_UseHomePath Prefix users home directory if it exists to the search path 00770 //! MioFLAG_UseLocale Add TNTmips locale directories to the search 00771 LIBEXPORT UNICODE *MioGetRefFile ( 00772 const void *vname, //!< File or path/file to search for, default is UNICODE string 00773 UINT32 flags //!< Flags 00774 ); 00775 00776 #endif // Retired items 00777 00778 // RETIRED - End 00779 //===================================================================================================================== 00780 // REMOVED - Begin 00781 00782 #ifndef GENERATING_DOXYGEN_OUTPUT 00783 //! Removed items, still exported from DLL until sure all dependent EXEs rebuilt. 00784 00785 #endif // GENERATING_DOXYGEN_OUTPUT 00786 00787 // REMOVED - End 00788 //===================================================================================================================== 00789 00790 00791 #if defined(__cplusplus) 00792 } 00793 #endif 00794 00795 #ifdef WIN32 00796 #pragma warning (default:4996) 00797 #endif 00798 00799 #undef LIBEXPORT 00800 #undef CLASSLIBEXPORT 00801 00802 #endif //!< INC_MI32_MIODEFNS_H
1.3.8-20040913