📄 osutils.cxx
字号:
* Revision 1.117 1999/02/23 07:11:27 robertj
* Improved trace facility adding trace levels and #define to remove all trace code.
*
* Revision 1.116 1998/11/30 12:45:54 robertj
* Fissioned into pchannel.cxx and pconfig.cxx
*
* Revision 1.115 1998/11/24 01:17:33 robertj
* Type discrepency between declaration and definition for PFile::SetPosition
*
* Revision 1.114 1998/11/06 02:37:53 robertj
* Fixed the fix for semaphore timeout race condition.
*
* Revision 1.113 1998/11/03 10:52:19 robertj
* Fixed bug in semaphores with timeout saying timed out when really signalled.
*
* Revision 1.112 1998/11/03 03:44:05 robertj
* Fixed missng strings on multiple parameters of same letter.
*
* Revision 1.111 1998/11/02 10:13:01 robertj
* Removed GNU warning.
*
* Revision 1.110 1998/11/01 04:56:53 robertj
* Added BOOl return value to Parse() to indicate there are parameters available.
*
* Revision 1.109 1998/10/31 14:02:20 robertj
* Removed StartImmediate capability as causes race condition in preemptive version.
*
* Revision 1.108 1998/10/31 12:47:10 robertj
* Added conditional mutex and read/write mutex thread synchronisation objects.
*
* Revision 1.107 1998/10/30 12:24:15 robertj
* Added ability to get all key values as a dictionary.
* Fixed warnings in GNU C.
*
* Revision 1.106 1998/10/30 11:22:15 robertj
* Added constructors that take strings as well as const char *'s.
*
* Revision 1.105 1998/10/30 05:25:09 robertj
* Allow user to shift past some arguments before parsing for the first time.
*
* Revision 1.104 1998/10/29 05:35:17 robertj
* Fixed porblem with GetCount() == 0 if do not call Parse() function.
*
* Revision 1.103 1998/10/28 03:26:43 robertj
* Added multi character arguments (-abc style) and options precede parameters mode.
*
* Revision 1.102 1998/10/28 00:59:49 robertj
* New improved argument parsing.
*
* Revision 1.101 1998/10/19 00:19:59 robertj
* Moved error and trace stream functions to common code.
*
* Revision 1.100 1998/10/18 14:28:45 robertj
* Renamed argv/argc to eliminate accidental usage.
*
* Revision 1.99 1998/10/13 14:06:28 robertj
* Complete rewrite of memory leak detection code.
*
* Revision 1.98 1998/09/24 07:23:54 robertj
* Moved structured fiel into separate module so don't need silly implementation file for GNU C.
*
* Revision 1.97 1998/09/23 06:22:24 robertj
* Added open source copyright license.
*
* Revision 1.96 1998/06/13 15:11:56 robertj
* Added stack check in Yield().
* Added immediate schedule of semaphore timeout thread.
*
* Revision 1.95 1998/05/30 13:28:18 robertj
* Changed memory check code so global statics are not included in leak check.
* Fixed deadlock in cooperative threading.
* Added PSyncPointAck class.
*
* Revision 1.94 1998/05/25 09:05:56 robertj
* Fixed close of channels on destruction.
*
* Revision 1.93 1998/04/07 13:33:33 robertj
* Changed startup code to support PApplication class.
*
* Revision 1.92 1998/03/29 06:16:45 robertj
* Rearranged initialisation sequence so PProcess descendent constructors can do "things".
*
* Revision 1.91 1998/03/20 03:18:17 robertj
* Added special classes for specific sepahores, PMutex and PSyncPoint.
*
* Revision 1.90 1998/02/05 13:33:12 robertj
* Fixed close of non-autodelete PIndirectChannels
*
* Revision 1.89 1998/02/03 06:19:55 robertj
* Added new function to read a block with minimum number of bytes.
*
* Revision 1.88 1998/01/26 00:47:13 robertj
* Added functions to get/set 64bit integers from a PConfig.
*
* Revision 1.87 1998/01/04 07:22:16 robertj
* Fixed bug in thread deletion not removing it from active thread list.
*
* Revision 1.86 1997/10/10 10:41:22 robertj
* Fixed problem with cooperative threading and Sleep() function returning immediately.
*
* Revision 1.85 1997/08/28 12:49:00 robertj
* Fixed possible assert on exit of application.
*
* Revision 1.84 1997/07/08 13:08:12 robertj
* DLL support.
*
* Revision 1.83 1997/04/27 05:50:15 robertj
* DLL support.
*
* Revision 1.82 1997/02/09 04:05:56 robertj
* Changed PProcess::Current() from pointer to reference.
*
* Revision 1.81 1997/02/05 11:51:42 robertj
* Changed current process function to return reference and validate objects descendancy.
*
* Revision 1.80 1996/12/21 05:54:38 robertj
* Fixed possible deadlock in timers.
*
* Revision 1.79 1996/12/05 11:44:22 craigs
* Made indirect close from different thread less likely to have
* race condition
*
* Revision 1.78 1996/11/30 12:08:42 robertj
* Removed extraneous compiler warning.
*
* Revision 1.77 1996/11/10 21:05:43 robertj
* Fixed bug of missing flush in close of indirect channel.
*
* Revision 1.76 1996/10/08 13:07:07 robertj
* Fixed bug in indirect channel being reopened double deleting subchannel.
*
* Revision 1.75 1996/09/14 13:09:37 robertj
* Major upgrade:
* rearranged sockets to help support IPX.
* added indirect channel class and moved all protocols to descend from it,
* separating the protocol from the low level byte transport.
*
* Revision 1.74 1996/08/11 06:53:04 robertj
* Fixed bug in Sleep() function (nonpreemptive version).
*
* Revision 1.73 1996/07/27 04:12:09 robertj
* Fixed bug in timer thread going into busy loop instead of blocking.
*
* Revision 1.72 1996/07/15 10:36:12 robertj
* Fixed bug in timer on startup, getting LARGE times timing out prematurely.
*
* Revision 1.71 1996/06/28 13:22:43 robertj
* Rewrite of timers to make OnTimeout more thread safe.
*
* Revision 1.70 1996/06/13 13:31:05 robertj
* Rewrite of auto-delete threads, fixes Windows95 total crash.
*
* Revision 1.69 1996/06/03 10:01:31 robertj
* Fixed GNU support bug fix for the fix.
*
* Revision 1.68 1996/06/01 05:03:37 robertj
* Fixed GNU compiler having difficulty with PTimeInterval *this.
*
* Revision 1.67 1996/05/26 03:46:56 robertj
* Compatibility to GNU 2.7.x
*
* Revision 1.66 1996/05/23 23:05:07 robertj
* Fixed process filename on MSOS platforms.
*
* Revision 1.65 1996/05/23 09:56:57 robertj
* Added mutex to timer list.
*
* Revision 1.64 1996/05/18 09:18:33 robertj
* Added mutex to timer list.
*
* Revision 1.63 1996/05/09 12:19:00 robertj
* Resolved C++ problems with 64 bit PTimeInterval for Mac platform.
*
* Revision 1.62 1996/04/14 02:53:34 robertj
* Split serial and pipe channel into separate compilation units for Linux executable size reduction.
*
* Revision 1.61 1996/04/10 12:51:29 robertj
* Fixed startup race condtion in timer thread.
*
* Revision 1.60 1996/04/09 03:32:58 robertj
* Fixed bug in config GetTime() cannot use PTime(0) in western hemisphere.
*
* Revision 1.59 1996/04/02 11:29:19 robertj
* Eliminated printing of patch level in version when there isn't one.
*
* Revision 1.58 1996/03/31 09:06:14 robertj
* Fixed WriteString() so works with sockets.
* Changed PPipeSokcet argument string list to array.
*
* Revision 1.57 1996/03/16 04:51:50 robertj
* Fixed yet another bug in the scheduler.
*
* Revision 1.56 1996/03/12 11:30:50 robertj
* Moved PProcess destructor to platform dependent code.
*
* Revision 1.55 1996/03/05 14:05:51 robertj
* Fixed some more bugs in scheduling.
*
* Revision 1.54 1996/03/04 12:22:46 robertj
* Fixed threading for unix stack check and loop list start point.
*
* Revision 1.53 1996/03/03 07:39:51 robertj
* Fixed bug in thread scheduler for correct termination of "current" thread.
*
* Revision 1.52 1996/03/02 03:24:48 robertj
* Changed timer thread to update timers periodically, this allows timers to be
* views dynamically by other threads.
* Added automatic deletion of thread object instances on thread completion.
*
* Revision 1.51 1996/02/25 11:15:27 robertj
* Added platform dependent Construct function to PProcess.
*
* Revision 1.50 1996/02/25 03:09:46 robertj
* Added consts to all GetXxxx functions in PConfig.
*
* Revision 1.49 1996/02/15 14:44:09 robertj
* Used string constructor for PTime, more "efficient".
*
* Revision 1.48 1996/02/13 12:59:30 robertj
* Changed GetTimeZone() so can specify standard/daylight time.
* Split PTime into separate module after major change to ReadFrom().
*
* Revision 1.47 1996/02/08 12:26:55 robertj
* Changed time for full support of time zones.
*
* Revision 1.46 1996/02/03 11:06:49 robertj
* Added string constructor for times, parses date/time from string.
*
* Revision 1.45 1996/01/28 14:09:39 robertj
* Fixed bug in time reading function for dates before 1980.
* Fixed bug in time reading, was out by one month.
* Added time functions to PConfig.
*
* Revision 1.44 1996/01/28 02:52:04 robertj
* Added assert into all Compare functions to assure comparison between compatible objects.
*
* Revision 1.43 1996/01/23 13:16:30 robertj
* Mac Metrowerks compiler support.
* Fixed timers so background thread not created if a windows app.
*
* Revision 1.42 1996/01/03 23:15:39 robertj
* Fixed some PTime bugs.
*
* Revision 1.41 1996/01/03 11:09:35 robertj
* Added Universal Time and Time Zones to PTime class.
*
* Revision 1.39 1995/12/23 03:40:40 robertj
* Changed version number system
*
* Revision 1.38 1995/12/10 11:41:12 robertj
* Added extra user information to processes and applications.
* Implemented timer support in text only applications with platform threads.
* Fixed bug in non-platform threads and semaphore timeouts.
*
* Revision 1.37 1995/11/21 11:50:57 robertj
* Added timeout on semaphore wait.
*
* Revision 1.36 1995/11/09 12:22:58 robertj
* Fixed bug in stream when reading an FF (get EOF).
*
* Revision 1.35 1995/07/31 12:09:25 robertj
* Added semaphore class.
* Removed PContainer from PChannel ancestor.
*
* Revision 1.34 1995/06/04 12:41:08 robertj
* Fixed bug in accessing argument strings with no argument.
*
* Revision 1.33 1995/04/25 11:30:06 robertj
* Fixed Borland compiler warnings.
*
* Revision 1.32 1995/04/22 00:51:00 robertj
* Changed file path strings to use PFilePath object.
* Changed semantics of Rename().
*
* Revision 1.31 1995/04/02 09:27:31 robertj
* Added "balloon" help.
*
* Revision 1.30 1995/04/01 08:30:58 robertj
* Fixed bug in timeout code of timers.
*
* Revision 1.29 1995/01/27 11:15:17 robertj
* Removed enum to int warning from GCC.
*
* Revision 1.28 1995/01/18 09:02:43 robertj
* Added notifier to timer.
*
* Revision 1.27 1995/01/15 04:57:15 robertj
* Implemented PTime::ReadFrom.
* Fixed flush of iostream at end of file.
*
* Revision 1.26 1995/01/11 09:45:14 robertj
* Documentation and normalisation.
*
* Revision 1.25 1995/01/10 11:44:15 robertj
* Removed PString parameter in stdarg function for GNU C++ compatibility.
*
* Revision 1.24 1995/01/09 12:31:51 robertj
* Removed unnecesary return value from I/O functions.
*
* Revision 1.23 1994/12/12 10:09:24 robertj
* Fixed flotain point configuration variable format.
*
* Revision 1.22 1994/11/28 12:38:23 robertj
* Async write functions should have const pointer.
*
* Revision 1.21 1994/10/30 11:36:58 robertj
* Fixed missing space in tine format string.
*
* Revision 1.20 1994/10/23 03:46:41 robertj
* Shortened OS error assert.
*
* Revision 1.19 1994/09/25 10:51:04 robertj
* Fixed error conversion code to use common function.
* Added pipe channel.
*
* Revision 1.18 1994/08/21 23:43:02 robertj
* Moved meta-string transmitter from PModem to PChannel.
* Added SuspendBlock state to cooperative multi-threading to fix logic fault.
* Added "force" option to Remove/Rename etc to override write protection.
* Added common entry point to convert OS error to PChannel error.
*
* Revision 1.17 1994/08/04 12:57:10 robertj
* Changed CheckBlock() to better name.
* Moved timer porcessing so is done at every Yield().
*
* Revision 1.16 1994/08/01 03:39:42 robertj
* Fixed temporary variable problem with GNU C++
*
* Revision 1.15 1994/07/27 05:58:07 robertj
* Synchronisation.
*
* Revision 1.14 1994/07/25 03:39:22 robertj
* Fixed problems with C++ temporary variables.
*
* Revision 1.13 1994/07/21 12:33:49 robertj
* Moved cooperative threads to common.
*
* Revision 1.12 1994/07/17 10:46:06 robertj
* Fixed timer bug.
* Moved handle from file to channel.
* Changed args to use container classes.
*
* Revision 1.11 1994/07/02 03:03:49 robertj
* Time interval and timer redesign.
*
* Revision 1.10 1994/06/25 11:55:15 robertj
* Unix version synchronisation.
*
* Revision 1.9 1994/04/20 12:17:44 robertj
* assert changes
*
* Revision 1.8 1994/04/01 14:05:06 robertj
* Text file streams
*
* Revision 1.7 1994/03/07 07:47:00 robertj
* Major upgrade
*
* Revision 1.6 1994/01/03 04:42:23 robertj
* Mass changes to common container classes and interactors etc etc etc.
*
* Revision 1.5 1993/12/31 06:53:02 robertj
* Made inlines optional for debugging purposes.
*
* Revision 1.4 1993/12/29 04:41:26 robertj
* Mac port.
*
* Revision 1.3 1993/11/20 17:26:28 robertj
* Removed separate osutil.h
*
* Revision 1.2 1993/08/31 03:38:02 robertj
* G++ needs explicit casts for char * / void * interchange.
*
* Revision 1.1 1993/08/27 18:17:47 robertj
* Initial revision
*
*/
#include <ptlib.h>
#include <vector>
#include <ctype.h>
#ifdef __MACOSX__
namespace PWLibStupidOSXHacks {
extern int loadShmVideoStuff;
extern int loadCoreAudioStuff;
extern int loadFakeVideoStuff;
};
#endif
class PSimpleThread : public PThread
{
PCLASSINFO(PSimpleThread, PThread);
public:
PSimpleThread(
const PNotifier & notifier,
INT parameter,
AutoDeleteFlag deletion,
Priority priorityLevel,
const PString & threadName,
PINDEX stackSize
);
void Main();
protected:
PNotifier callback;
INT parameter;
};
static PMutex * PTraceMutex = NULL;
#ifndef __NUCLEUS_PLUS__
static ostream * PErrorStream = &cerr;
#else
static ostream * PErrorStream = NULL;
#endif
ostream & PGetErrorStream()
{
return *PErrorStream;
}
void PSetErrorStream(ostream * s)
{
#ifndef __NUCLEUS_PLUS__
PErrorStream = s != NULL ? s : &cerr;
#else
PErrorStream = s;
#endif
}
//////////////////////////////////////////////////////////////////////////////
#if !defined(__NUCLEUS_PLUS__)
static ostream * PTraceStream = &cerr;
#else
#ifdef __NUCLEUS_PLUS__
static ostream * PTraceStream = 0L;
#endif
#endif
static unsigned PTraceOptions = PTrace::FileAndLine;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -