├── Include
├── EasyTypes.h
├── EasyPusherAPI.h
└── EasyRTSPClientAPI.h
├── Lib
├── libEasyPusher.dll
├── libEasyPusher.lib
├── libEasyRTSPClient.dll
└── libEasyRTSPClient.lib
├── PrefsSourceLib
├── nilib2.c
├── PrefsSource.h
├── NetInfoPrefsSource.h
├── FilePrefsSource.h
├── NetInfoPrefsSource.cpp
└── XMLParser.h
├── Server.tproj
├── QTSServer.cpp
├── RunServer.cpp
├── QTSSExpirationDate.h
├── QTSSExpirationDate.cpp
├── nbproject
│ ├── Makefile-variables.mk
│ └── project.xml
├── QTSSErrorLogModule.h
├── GenerateXMLPrefs.h
├── QTSSSocket.cpp
├── QTSSSocket.h
├── QTSSFile.h
├── QTSSMessages.h
├── RunServer.h
├── QTSSDataConverter.h
├── QTSSStream.h
└── Makefile
├── CommonUtilitiesLib
├── MakeDir.c
├── .dep.inc
├── nbproject
│ ├── project.xml
│ ├── Makefile-variables.mk
│ ├── Package-Debug.bash
│ └── Package-Release.bash
├── Trim.c
├── Trim.h
├── GetWord.h
├── PathDelimiter.h
├── MyAssert.cpp
├── tempcalls.h
├── ConfParser.h
├── MakeDir.h
├── FastCopyMacros.h
├── mymutex.h
├── atomic.cpp
├── mycondition.h
├── Makefile.POSIX
├── OSCodeFragment.h
├── ResizeableStringFormatter.cpp
├── StopWatch.h
├── OSBufferPool.cpp
├── UDPDemuxer.cpp
├── OSBufferPool.h
├── OSArrayObjectDeleter.h
├── ResizeableStringFormatter.h
├── ev.h
├── md5.h
├── md5digest.h
├── UDPSocket.h
├── QueryParamList.h
├── StringTranslator.h
├── daemon.h
├── UserAgentParser.h
├── atomic.h
├── TCPListenerSocket.h
├── GetWord.c
├── daemon.c
├── OSCond.cpp
├── DssStopwatch.h
├── SafeStdLib.h
├── IdleTask.h
├── OSHeap.h
├── OSCond.h
├── TCPSocket.h
├── DateTranslator.h
├── TCPSocket.cpp
├── Makefile
├── TimeoutTask.h
├── OSMutex.h
├── MyAssert.h
└── IdleTask.cpp
├── .dep.inc
├── Buildit
├── SafeStdLib
├── SafeInternalStdLib.dsw
└── SafeDynamicModuleStdLib.dsw
├── .gitignore
├── HTTPUtilitiesLib
└── Makefile.POSIX
├── APIStubLib
├── makefile.apistublib.POSIX
└── BuildAPIStubLib
├── nbproject
├── project.xml
├── Makefile-variables.mk
├── Package-ARM.bash
├── Package-Debug.bash
└── Package-Release.bash
├── WinNTSupport
├── easynvr.xml
├── Win32header.h
└── EasyNVR.sln
├── revision.h
├── APICommonCode
└── QTSSMemoryDeleter.h
├── libClientCommondef.h
├── defaultPaths.h
└── Makefile
/Include/EasyTypes.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Include/EasyTypes.h
--------------------------------------------------------------------------------
/Lib/libEasyPusher.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Lib/libEasyPusher.dll
--------------------------------------------------------------------------------
/Lib/libEasyPusher.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Lib/libEasyPusher.lib
--------------------------------------------------------------------------------
/Include/EasyPusherAPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Include/EasyPusherAPI.h
--------------------------------------------------------------------------------
/PrefsSourceLib/nilib2.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/PrefsSourceLib/nilib2.c
--------------------------------------------------------------------------------
/Lib/libEasyRTSPClient.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Lib/libEasyRTSPClient.dll
--------------------------------------------------------------------------------
/Lib/libEasyRTSPClient.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Lib/libEasyRTSPClient.lib
--------------------------------------------------------------------------------
/Server.tproj/QTSServer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Server.tproj/QTSServer.cpp
--------------------------------------------------------------------------------
/Server.tproj/RunServer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Server.tproj/RunServer.cpp
--------------------------------------------------------------------------------
/CommonUtilitiesLib/MakeDir.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/CommonUtilitiesLib/MakeDir.c
--------------------------------------------------------------------------------
/Include/EasyRTSPClientAPI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Include/EasyRTSPClientAPI.h
--------------------------------------------------------------------------------
/Server.tproj/QTSSExpirationDate.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Server.tproj/QTSSExpirationDate.h
--------------------------------------------------------------------------------
/Server.tproj/QTSSExpirationDate.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/EasyNVR/master/Server.tproj/QTSSExpirationDate.cpp
--------------------------------------------------------------------------------
/.dep.inc:
--------------------------------------------------------------------------------
1 | # This code depends on make tool being used
2 | DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
3 | ifneq (${DEPFILES},)
4 | include ${DEPFILES}
5 | endif
6 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/.dep.inc:
--------------------------------------------------------------------------------
1 | # This code depends on make tool being used
2 | DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
3 | ifneq (${DEPFILES},)
4 | include ${DEPFILES}
5 | endif
6 |
--------------------------------------------------------------------------------
/Buildit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ "$*" = "clean" ] ; then
4 | make -f nbproject/Makefile-ARM.mk QMAKE= SUBPROJECTS= .clean-conf
5 | else
6 | make -f nbproject/Makefile-ARM.mk QMAKE= SUBPROJECTS= .build-conf
7 | fi
8 |
9 |
--------------------------------------------------------------------------------
/SafeStdLib/SafeInternalStdLib.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "SafeInternalStdLib"=".\SafeInternalStdLib.dsp" - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | }}}
15 |
16 | ###############################################################################
17 |
18 | Global:
19 |
20 | Package=<5>
21 | {{{
22 | }}}
23 |
24 | Package=<3>
25 | {{{
26 | }}}
27 |
28 | ###############################################################################
29 |
30 |
--------------------------------------------------------------------------------
/SafeStdLib/SafeDynamicModuleStdLib.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "SafeDynamicModuleStdLib"=".\SafeDynamicModuleStdLib.dsp" - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | }}}
15 |
16 | ###############################################################################
17 |
18 | Global:
19 |
20 | Package=<5>
21 | {{{
22 | }}}
23 |
24 | Package=<3>
25 | {{{
26 | }}}
27 |
28 | ###############################################################################
29 |
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | #ignore thumbnails created by windows
3 | Thumbs.db
4 | #Ignore files build by Visual Studio
5 | *.obj
6 | *.exe
7 | *.pdb
8 | *.aps
9 | *.pch
10 | *.vspscc
11 | *_i.c
12 | *_p.c
13 | *.ncb
14 | *.suo
15 | *.tlb
16 | *.tlh
17 | *.bak
18 | *.cache
19 | *.ilk
20 | *.log
21 | [Dd]ebug*/
22 | *.lib
23 | *.sbr
24 | obj/
25 | /EasyCMS/libEasyCMS/
26 | [Rr]elease*/
27 | _ReSharper*/
28 | [Tt]est[Rr]esult*
29 | *.sdf
30 | *.sdp
31 | *.o
32 | *.exp
33 | /CMS/build/
34 | /CMS/dist/
35 | [Ll]ogs*/
36 | [Pp]rivate*/
37 | *.user
38 | *.264
39 | *.ts
40 | *libEasyHLS/
41 | *.m3u8
42 | /EasyDarwin/build/
43 | /EasyDarwin/dist/
44 | /CommonUtilitiesLib/build/
45 | Movies*/
46 | /CMS/EasyProtocol/EasyProtocol/build/
47 | /CMS/EasyProtocol/EasyProtocol/ProtocolTest/build/
48 | /EasyCMS/EasyProtocol/EasyProtocol/build/
49 | /EasyCMS/EasyProtocol/jsoncpp/build/
50 | /EasyCMS/build/
51 | /EasyProtocol/jsoncpp/build/
52 | /EasyProtocol/EasyProtocol/build/
--------------------------------------------------------------------------------
/HTTPUtilitiesLib/Makefile.POSIX:
--------------------------------------------------------------------------------
1 | C++ = $(CPLUS)
2 | CC = $(CCOMP)
3 | LINK = $(LINKER)
4 | CCFLAGS += $(MACHDEFINES) -include ../PlatformHeader.h -g -Wall $(CFLAGSX)
5 |
6 | OPTIM = -O2
7 |
8 | # EACH DIRECTORY WITH HEADERS MUST BE APPENDED IN THIS MANNER TO THE CCFLAGS
9 |
10 | CCFLAGS += -I.
11 | CCFLAGS += -I..
12 | CCFLAGS += -I../CommonUtilitiesLib
13 | CCFLAGS += -I../APIStubLib
14 |
15 | C++FLAGS = $(CCFLAGS)
16 |
17 | CFILES =
18 |
19 | CPPFILES = HTTPProtocol.cpp\
20 | HTTPRequest.cpp
21 |
22 | all: libHTTPUtilitiesLib.a
23 |
24 | libHTTPUtilitiesLib.a: $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
25 | ar -r libHTTPUtilitiesLib.a $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
26 | ranlib libHTTPUtilitiesLib.a
27 |
28 | install: libHTTPUtilitiesLib.a
29 |
30 | clean:
31 | rm -f libHTTPUtilitiesLib.a $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
32 |
33 | .SUFFIXES: .cpp .c .o
34 |
35 | .cpp.o:
36 | $(C++) -c -o $*.o $(DEFINES) $(C++FLAGS) $*.cpp
37 |
38 | .c.o:
39 | $(CC) -c -o $*.o $(DEFINES) $(CCFLAGS) $*.c
40 |
41 |
--------------------------------------------------------------------------------
/APIStubLib/makefile.apistublib.POSIX:
--------------------------------------------------------------------------------
1 | # Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
2 | #
3 |
4 | NAME = libAPIStubLib.a
5 | C++ = $(CPLUS)
6 | CC = $(CCOMP)
7 | LINK = $(LINKER)
8 | CCFLAGS += $(MACHDEFINES) -include ../PlatformHeader.h -g -Wall $(CFLAGSX)
9 | LIBS =
10 |
11 | OPTIM = -O0
12 |
13 | # EACH DIRECTORY WITH HEADERS MUST BE APPENDED IN THIS MANNER TO THE CCFLAGS
14 |
15 | CCFLAGS += -I.
16 | CCFLAGS += -I../CommonUtilitiesLib
17 |
18 | C++FLAGS = $(CCFLAGS)
19 |
20 | #
21 | #
22 | #
23 | #
24 | CFILES =
25 |
26 | #
27 | #
28 | #
29 | #
30 | CPPFILES = ./QTSS_Private.cpp
31 |
32 | #
33 | #
34 |
35 | all: libAPIStubLib.a
36 |
37 |
38 | libAPIStubLib.a : $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
39 | $(LIB) $@ $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
40 |
41 | clean:
42 | rm -f $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
43 |
44 | .SUFFIXES: .cpp .c .o
45 |
46 | .cpp.o:
47 | $(C++) -c -o $*.o $(DEFINES) $(C++FLAGS) $*.cpp
48 |
49 | .c.o:
50 | $(CC) -c -o $*.o $(DEFINES) $(CCFLAGS) $*.c
51 |
52 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.cnd.makeproject
4 |
5 |
6 | CommonUtilitiesLib
7 | c
8 | cpp
9 | h
10 | UTF-8
11 |
12 |
13 | .
14 |
15 |
16 |
17 | Debug
18 | 3
19 |
20 |
21 | Release
22 | 3
23 |
24 |
25 |
26 | false
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/Trim.c:
--------------------------------------------------------------------------------
1 | #include "Trim.h"
2 |
3 | /*
4 | *
5 | * @APPLE_LICENSE_HEADER_START@
6 | *
7 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
8 | *
9 | * This file contains Original Code and/or Modifications of Original Code
10 | * as defined in and that are subject to the Apple Public Source License
11 | * Version 2.0 (the 'License'). You may not use this file except in
12 | * compliance with the License. Please obtain a copy of the License at
13 | * http://www.opensource.apple.com/apsl/ and read it before using this
14 | * file.
15 | *
16 | * The Original Code and all software distributed under the License are
17 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
18 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
19 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
21 | * Please see the License for the specific language governing rights and
22 | * limitations under the License.
23 | *
24 | * @APPLE_LICENSE_HEADER_END@
25 | *
26 | */
27 |
28 | char* TrimLeft(char* fromStrPtr )
29 | {
30 | char* tmp = &fromStrPtr[0];
31 | // trim any leading white space
32 | while ( (*tmp <= ' ') && (*tmp != 0) )
33 | tmp++;
34 | return tmp;
35 | }
36 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.cnd.makeproject
4 |
5 |
6 | easycamera
7 |
8 | cpp
9 | h
10 | GB2312
11 |
12 |
13 | .
14 |
15 |
16 |
17 | Debug
18 | 1
19 |
20 |
21 | Release
22 | 1
23 |
24 |
25 | ARM
26 | 1
27 |
28 |
29 |
30 | false
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/Trim.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __trim__
3 | #define __trim__
4 |
5 | /*
6 | *
7 | * @APPLE_LICENSE_HEADER_START@
8 | *
9 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
10 | *
11 | * This file contains Original Code and/or Modifications of Original Code
12 | * as defined in and that are subject to the Apple Public Source License
13 | * Version 2.0 (the 'License'). You may not use this file except in
14 | * compliance with the License. Please obtain a copy of the License at
15 | * http://www.opensource.apple.com/apsl/ and read it before using this
16 | * file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_LICENSE_HEADER_END@
27 | *
28 | */
29 |
30 |
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 |
37 | char* TrimLeft( char* fromStrPtr );
38 |
39 | #ifdef __cplusplus
40 | }
41 | #endif
42 |
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/Server.tproj/nbproject/Makefile-variables.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Generated - do not edit!
3 | #
4 | # NOCDDL
5 | #
6 | CND_BASEDIR=`pwd`
7 | CND_BUILDDIR=build
8 | CND_DISTDIR=dist
9 | # Debug configuration
10 | CND_PLATFORM_Debug=GNU-Linux-x86
11 | CND_ARTIFACT_DIR_Debug=../Debug
12 | CND_ARTIFACT_NAME_Debug=EasyDarwin
13 | CND_ARTIFACT_PATH_Debug=../Debug/EasyDarwin
14 | CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux-x86/package
15 | CND_PACKAGE_NAME_Debug=server.tproj.tar
16 | CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux-x86/package/server.tproj.tar
17 | # Release configuration
18 | CND_PLATFORM_Release=GNU-Linux-x86
19 | CND_ARTIFACT_DIR_Release=../Release
20 | CND_ARTIFACT_NAME_Release=EasyDarwin
21 | CND_ARTIFACT_PATH_Release=../Release/EasyDarwin
22 | CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux-x86/package
23 | CND_PACKAGE_NAME_Release=server.tproj.tar
24 | CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux-x86/package/server.tproj.tar
25 | #
26 | # include compiler specific variables
27 | #
28 | # dmake command
29 | ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
30 | (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
31 | #
32 | # gmake command
33 | .PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
34 | #
35 | include nbproject/private/Makefile-variables.mk
36 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/nbproject/Makefile-variables.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Generated - do not edit!
3 | #
4 | # NOCDDL
5 | #
6 | CND_BASEDIR=`pwd`
7 | CND_BUILDDIR=build
8 | CND_DISTDIR=dist
9 | # Debug configuration
10 | CND_PLATFORM_Debug=GNU-Linux-x86
11 | CND_ARTIFACT_DIR_Debug=../Debug
12 | CND_ARTIFACT_NAME_Debug=libCommonUtilitiesLib.a
13 | CND_ARTIFACT_PATH_Debug=../Debug/libCommonUtilitiesLib.a
14 | CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux-x86/package
15 | CND_PACKAGE_NAME_Debug=CommonUtilitiesLib.tar
16 | CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux-x86/package/CommonUtilitiesLib.tar
17 | # Release configuration
18 | CND_PLATFORM_Release=GM8126-Linux-x86
19 | CND_ARTIFACT_DIR_Release=../Release
20 | CND_ARTIFACT_NAME_Release=libCommonUtilitiesLib.a
21 | CND_ARTIFACT_PATH_Release=../Release/libCommonUtilitiesLib.a
22 | CND_PACKAGE_DIR_Release=dist/Release/GM8126-Linux-x86/package
23 | CND_PACKAGE_NAME_Release=CommonUtilitiesLib.tar
24 | CND_PACKAGE_PATH_Release=dist/Release/GM8126-Linux-x86/package/CommonUtilitiesLib.tar
25 | #
26 | # include compiler specific variables
27 | #
28 | # dmake command
29 | ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
30 | (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
31 | #
32 | # gmake command
33 | .PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
34 | #
35 | include nbproject/private/Makefile-variables.mk
36 |
--------------------------------------------------------------------------------
/WinNTSupport/easynvr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0
4 | www.easydarwin.org
5 | 10000
6 | 192.168.66.189
7 | 80
8 | 000000000000
9 | 0
10 | 115.29.139.20
11 | 554
12 | Error
13 | ./Logs/
14 | 7
15 | 256000
16 | 2
17 | true
18 | true
19 | admin
20 | admin
21 | 0
22 | EasyCamera.pid
23 | false
24 | 1
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/GetWord.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #ifndef __getword__
27 | #define __getword__
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "OSHeaders.h"
34 |
35 | char* GetWord( char* toWordPtr, char* fromStrPtr, SInt32 limit );
36 | char* GetQuotedWord( char* toWordPtr, char* fromStrPtr, SInt32 limit );
37 |
38 | #ifdef __cplusplus
39 | }
40 | #endif
41 |
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/Server.tproj/QTSSErrorLogModule.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QTSSErrorLogModule.h
27 |
28 | Contains: A module that uses QTSSRollingLog to write error messages to a file
29 |
30 |
31 |
32 | */
33 |
34 | #ifndef __QTSS_ERROR_LOG_MODULE_H__
35 | #define __QTSS_ERROR_LOG_MODULE_H__
36 |
37 | #include "QTSS.h"
38 |
39 | QTSS_Error QTSSErrorLogModule_Main(void* inPrivateArgs);
40 |
41 | #endif // __QTSS_ERROR_LOG_MODULE_H__
42 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/PathDelimiter.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #ifndef __pathdelimiter__
27 | #define __pathdelimiter__
28 |
29 |
30 | #if __MACOS__
31 | #define kPathDelimiterString ":"
32 | #define kPathDelimiterChar ':'
33 | #define kPartialPathBeginsWithDelimiter 1
34 | #else
35 | #define kPathDelimiterString "/"
36 | #define kPathDelimiterChar '/'
37 | #define kPartialPathBeginsWithDelimiter 0
38 | #endif
39 |
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/Server.tproj/GenerateXMLPrefs.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: GenerateXMLPrefs.h
27 |
28 | Contains: Routine that updates a QTSS 1.x 2.x PrefsSource to the new XMLPrefsSource.
29 |
30 | */
31 |
32 | #include "PrefsSource.h"
33 | #include "FilePrefsSource.h"
34 | #include "XMLPrefsParser.h"
35 |
36 | int GenerateStandardXMLPrefs(PrefsSource* inPrefsSource, XMLPrefsParser* inXMLPrefs);
37 | int GenerateAllXMLPrefs(FilePrefsSource* inPrefsSource, XMLPrefsParser* inXMLPrefs);
38 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/MyAssert.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #include "MyAssert.h"
27 | #include "OSHeaders.h"
28 | #include "SafeStdLib.h"
29 |
30 | static AssertLogger* sLogger = NULL;
31 |
32 | void SetAssertLogger(AssertLogger* theLogger)
33 | {
34 | sLogger = theLogger;
35 | }
36 |
37 | void MyAssert(char *inMessage)
38 | {
39 | if (sLogger != NULL)
40 | sLogger->LogAssert(inMessage);
41 | else
42 | {
43 | qtss_printf("%s\n", inMessage);
44 | #if __Win32__
45 | DebugBreak();
46 | #else
47 | (*(SInt32*)0) = 0;
48 | #endif
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/nbproject/Makefile-variables.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Generated - do not edit!
3 | #
4 | # NOCDDL
5 | #
6 | CND_BASEDIR=`pwd`
7 | CND_BUILDDIR=build
8 | CND_DISTDIR=dist
9 | # Debug configuration
10 | CND_PLATFORM_Debug=GNU-Linux-x86
11 | CND_ARTIFACT_DIR_Debug=Bin
12 | CND_ARTIFACT_NAME_Debug=easycamera
13 | CND_ARTIFACT_PATH_Debug=Bin/easycamera
14 | CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux-x86/package
15 | CND_PACKAGE_NAME_Debug=src.tar
16 | CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux-x86/package/src.tar
17 | # Release configuration
18 | CND_PLATFORM_Release=GNU-Linux-x86
19 | CND_ARTIFACT_DIR_Release=Bin
20 | CND_ARTIFACT_NAME_Release=easycamera
21 | CND_ARTIFACT_PATH_Release=Bin/easycamera
22 | CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux-x86/package
23 | CND_PACKAGE_NAME_Release=src.tar
24 | CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux-x86/package/src.tar
25 | # ARM configuration
26 | CND_PLATFORM_ARM=GM8126-Linux-x86
27 | CND_ARTIFACT_DIR_ARM=Bin
28 | CND_ARTIFACT_NAME_ARM=easycamera
29 | CND_ARTIFACT_PATH_ARM=Bin/easycamera
30 | CND_PACKAGE_DIR_ARM=dist/ARM/GM8126-Linux-x86/package
31 | CND_PACKAGE_NAME_ARM=src.tar
32 | CND_PACKAGE_PATH_ARM=dist/ARM/GM8126-Linux-x86/package/src.tar
33 | #
34 | # include compiler specific variables
35 | #
36 | # dmake command
37 | ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
38 | (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
39 | #
40 | # gmake command
41 | .PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
42 | #
43 | include nbproject/private/Makefile-variables.mk
44 |
--------------------------------------------------------------------------------
/revision.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /* revision.h -- define the version number
26 |
27 | */
28 |
29 | // Use no http/rtsp tspecial chars in kVersionString and kBuildString defines
30 | // tspecials = ()<>@,;:\/"[]?=
31 |
32 | #define kVersionString "7.0.0"
33 | #define kBuildString "15.0310"
34 |
35 | // Use kCommentString for seed or other release info
36 | // Do not use '(' or ')' in the kCommentString
37 | // form = token1/info; token2/info;
38 | // example "Release/public seed 1; Event/Big Event; state/half-baked"
39 |
40 | #define kCommentString "Release/EasyDarwin; State/Development; "
41 |
42 |
--------------------------------------------------------------------------------
/Server.tproj/QTSSSocket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QTSSSocket.cpp
27 |
28 | Contains: A QTSS Stream object for a generic socket
29 |
30 | Written By: Denis Serenyi
31 |
32 |
33 |
34 | */
35 |
36 | #include "QTSSSocket.h"
37 |
38 | QTSS_Error QTSSSocket::RequestEvent(QTSS_EventType inEventMask)
39 | {
40 | int theMask = 0;
41 |
42 | if (inEventMask & QTSS_ReadableEvent)
43 | theMask |= EV_RE;
44 | if (inEventMask & QTSS_WriteableEvent)
45 | theMask |= EV_WR;
46 |
47 | fEventContext.SetTask(this->GetTask());
48 | fEventContext.RequestEvent(theMask);
49 | return QTSS_NoErr;
50 | }
51 |
--------------------------------------------------------------------------------
/nbproject/Package-ARM.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | #
4 | # Generated - do not edit!
5 | #
6 |
7 | # Macros
8 | TOP=`pwd`
9 | CND_PLATFORM=GM8126-Linux-x86
10 | CND_CONF=ARM
11 | CND_DISTDIR=dist
12 | CND_BUILDDIR=build
13 | CND_DLIB_EXT=so
14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
15 | TMPDIRNAME=tmp-packaging
16 | OUTPUT_PATH=Bin/easycamera
17 | OUTPUT_BASENAME=easycamera
18 | PACKAGE_TOP_DIR=src/
19 |
20 | # Functions
21 | function checkReturnCode
22 | {
23 | rc=$?
24 | if [ $rc != 0 ]
25 | then
26 | exit $rc
27 | fi
28 | }
29 | function makeDirectory
30 | # $1 directory path
31 | # $2 permission (optional)
32 | {
33 | mkdir -p "$1"
34 | checkReturnCode
35 | if [ "$2" != "" ]
36 | then
37 | chmod $2 "$1"
38 | checkReturnCode
39 | fi
40 | }
41 | function copyFileToTmpDir
42 | # $1 from-file path
43 | # $2 to-file path
44 | # $3 permission
45 | {
46 | cp "$1" "$2"
47 | checkReturnCode
48 | if [ "$3" != "" ]
49 | then
50 | chmod $3 "$2"
51 | checkReturnCode
52 | fi
53 | }
54 |
55 | # Setup
56 | cd "${TOP}"
57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
58 | rm -rf ${NBTMPDIR}
59 | mkdir -p ${NBTMPDIR}
60 |
61 | # Copy files and create directories and links
62 | cd "${TOP}"
63 | makeDirectory "${NBTMPDIR}/src/bin"
64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
65 |
66 |
67 | # Generate tar file
68 | cd "${TOP}"
69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/src.tar
70 | cd ${NBTMPDIR}
71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/src.tar *
72 | checkReturnCode
73 |
74 | # Cleanup
75 | cd "${TOP}"
76 | rm -rf ${NBTMPDIR}
77 |
--------------------------------------------------------------------------------
/nbproject/Package-Debug.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | #
4 | # Generated - do not edit!
5 | #
6 |
7 | # Macros
8 | TOP=`pwd`
9 | CND_PLATFORM=GNU-Linux-x86
10 | CND_CONF=Debug
11 | CND_DISTDIR=dist
12 | CND_BUILDDIR=build
13 | CND_DLIB_EXT=so
14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
15 | TMPDIRNAME=tmp-packaging
16 | OUTPUT_PATH=Bin/easycamera
17 | OUTPUT_BASENAME=easycamera
18 | PACKAGE_TOP_DIR=src/
19 |
20 | # Functions
21 | function checkReturnCode
22 | {
23 | rc=$?
24 | if [ $rc != 0 ]
25 | then
26 | exit $rc
27 | fi
28 | }
29 | function makeDirectory
30 | # $1 directory path
31 | # $2 permission (optional)
32 | {
33 | mkdir -p "$1"
34 | checkReturnCode
35 | if [ "$2" != "" ]
36 | then
37 | chmod $2 "$1"
38 | checkReturnCode
39 | fi
40 | }
41 | function copyFileToTmpDir
42 | # $1 from-file path
43 | # $2 to-file path
44 | # $3 permission
45 | {
46 | cp "$1" "$2"
47 | checkReturnCode
48 | if [ "$3" != "" ]
49 | then
50 | chmod $3 "$2"
51 | checkReturnCode
52 | fi
53 | }
54 |
55 | # Setup
56 | cd "${TOP}"
57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
58 | rm -rf ${NBTMPDIR}
59 | mkdir -p ${NBTMPDIR}
60 |
61 | # Copy files and create directories and links
62 | cd "${TOP}"
63 | makeDirectory "${NBTMPDIR}/src/bin"
64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
65 |
66 |
67 | # Generate tar file
68 | cd "${TOP}"
69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/src.tar
70 | cd ${NBTMPDIR}
71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/src.tar *
72 | checkReturnCode
73 |
74 | # Cleanup
75 | cd "${TOP}"
76 | rm -rf ${NBTMPDIR}
77 |
--------------------------------------------------------------------------------
/nbproject/Package-Release.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | #
4 | # Generated - do not edit!
5 | #
6 |
7 | # Macros
8 | TOP=`pwd`
9 | CND_PLATFORM=GNU-Linux-x86
10 | CND_CONF=Release
11 | CND_DISTDIR=dist
12 | CND_BUILDDIR=build
13 | CND_DLIB_EXT=so
14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
15 | TMPDIRNAME=tmp-packaging
16 | OUTPUT_PATH=Bin/easycamera
17 | OUTPUT_BASENAME=easycamera
18 | PACKAGE_TOP_DIR=src/
19 |
20 | # Functions
21 | function checkReturnCode
22 | {
23 | rc=$?
24 | if [ $rc != 0 ]
25 | then
26 | exit $rc
27 | fi
28 | }
29 | function makeDirectory
30 | # $1 directory path
31 | # $2 permission (optional)
32 | {
33 | mkdir -p "$1"
34 | checkReturnCode
35 | if [ "$2" != "" ]
36 | then
37 | chmod $2 "$1"
38 | checkReturnCode
39 | fi
40 | }
41 | function copyFileToTmpDir
42 | # $1 from-file path
43 | # $2 to-file path
44 | # $3 permission
45 | {
46 | cp "$1" "$2"
47 | checkReturnCode
48 | if [ "$3" != "" ]
49 | then
50 | chmod $3 "$2"
51 | checkReturnCode
52 | fi
53 | }
54 |
55 | # Setup
56 | cd "${TOP}"
57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
58 | rm -rf ${NBTMPDIR}
59 | mkdir -p ${NBTMPDIR}
60 |
61 | # Copy files and create directories and links
62 | cd "${TOP}"
63 | makeDirectory "${NBTMPDIR}/src/bin"
64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
65 |
66 |
67 | # Generate tar file
68 | cd "${TOP}"
69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/src.tar
70 | cd ${NBTMPDIR}
71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/src.tar *
72 | checkReturnCode
73 |
74 | # Cleanup
75 | cd "${TOP}"
76 | rm -rf ${NBTMPDIR}
77 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/tempcalls.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 |
25 | */
26 | #ifdef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
27 | // these optimized calls are implemented in stdclib and declared in sys/ev.h on 10.5 and later for better performance.
28 |
29 | /*
30 | int watchevent(struct eventreq *u_req, int u_eventmask);
31 | int waitevent(struct eventreq *u_req, struct timeval *tv);
32 | int modwatch(struct eventreq *u_req, int u_eventmask);
33 | */
34 |
35 | #else
36 | // use syscall for the performance calls.
37 | #define watchevent(a,b) syscall(231,(a),(b))
38 | #define waitevent(a,b) syscall(232,(a),(b))
39 | #define modwatch(a,b) syscall(233,(a),(b))
40 | #endif //AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
41 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/ConfParser.h:
--------------------------------------------------------------------------------
1 | #ifndef __ConfParser__
2 | #define __ConfParser__
3 |
4 | /*
5 | *
6 | * @APPLE_LICENSE_HEADER_START@
7 | *
8 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
9 | *
10 | * This file contains Original Code and/or Modifications of Original Code
11 | * as defined in and that are subject to the Apple Public Source License
12 | * Version 2.0 (the 'License'). You may not use this file except in
13 | * compliance with the License. Please obtain a copy of the License at
14 | * http://www.opensource.apple.com/apsl/ and read it before using this
15 | * file.
16 | *
17 | * The Original Code and all software distributed under the License are
18 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
19 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
20 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
22 | * Please see the License for the specific language governing rights and
23 | * limitations under the License.
24 | *
25 | * @APPLE_LICENSE_HEADER_END@
26 | *
27 | */
28 |
29 |
30 |
31 | #include "OSHeaders.h"
32 |
33 | // the maximum size + 1 of a parameter
34 | #define kConfParserMaxParamSize 512
35 |
36 |
37 | // the maximum size + 1 of single line in the file
38 | #define kConfParserMaxLineSize 1024
39 |
40 | // the maximum number of values per config parameter
41 | #define kConfParserMaxParamValues 10
42 |
43 |
44 | void TestParseConfigFile();
45 |
46 | int ParseConfigFile( Bool16 allowNullValues, const char* fname \
47 | , Bool16 (*ConfigSetter)( const char* paramName, const char* paramValue[], void * userData ) \
48 | , void* userData );
49 | #endif
50 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/MakeDir.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #ifndef __makedir__
27 | #define __makedir__
28 |
29 | #if (! __MACOS__)
30 | #include
31 | #include
32 | #include
33 | #ifndef __solaris__ || __hpux__
34 | #include
35 | #endif
36 | #include
37 | #else
38 | #include "BogusDefs.h"
39 | #endif
40 |
41 | #ifndef S_IRWXU
42 | #define S_IRWXU 0
43 | #endif
44 |
45 |
46 | #ifdef __cplusplus
47 | extern "C" {
48 | #endif
49 |
50 |
51 | int MakeDir( const char* path, int mode );
52 | int RecursiveMakeDir( const char*inPath, int mode);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 |
59 | #endif
60 |
--------------------------------------------------------------------------------
/PrefsSourceLib/PrefsSource.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: PrefsSource.h
27 |
28 | Contains: Defines an abstract common interface for extracting prefs
29 | from some data source. Very general, low level
30 |
31 | Written by: Denis Serenyi
32 |
33 | Change History (most recent first):
34 |
35 |
36 |
37 |
38 | */
39 |
40 | #ifndef __PREFSSOURCE_H__
41 | #define __PREFSSOURCE_H__
42 |
43 | #include "OSHeaders.h"
44 |
45 | class PrefsSource
46 | {
47 | public:
48 |
49 | virtual int GetValue(const char* inKey, char* ioValue) = 0;
50 | virtual int GetValueByIndex(const char* inKey, UInt32 inIndex, char* ioValue) = 0;
51 | virtual ~PrefsSource(){};
52 | };
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/FastCopyMacros.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | #ifndef __FastCopyMacros__
26 | #define __FastCopyMacros__
27 |
28 | #define COPY_BYTE( dest, src ) ( *((char*)(dest)) = *((char*)(src)) )
29 | #define COPY_WORD( dest, src ) ( *((SInt16*)(dest)) = *((SInt16*)(src)) )
30 | #define COPY_LONG_WORD( dest, src ) ( *((SInt32*)(dest)) = *((SInt32*)(src)) )
31 | #define COPY_LONG_LONG_WORD( dest, src ) ( *((SInt64*)(dest)) = *((SInt64**)(src)) )
32 |
33 | #define MOVE_BYTE( dest, src ) ( dest = *((char*)(src)) )
34 | #define MOVE_WORD( dest, src ) ( dest = *((SInt16*)(src)) )
35 | #define MOVE_LONG_WORD( dest, src ) ( dest = *((SInt32*)(src)) )
36 | #define MOVE_LONG_LONG_WORD( dest, src ) ( dest = *((SInt64**)(src)) )
37 |
38 |
39 | #endif
40 |
41 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/nbproject/Package-Debug.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | #
4 | # Generated - do not edit!
5 | #
6 |
7 | # Macros
8 | TOP=`pwd`
9 | CND_PLATFORM=GNU-Linux-x86
10 | CND_CONF=Debug
11 | CND_DISTDIR=dist
12 | CND_BUILDDIR=build
13 | CND_DLIB_EXT=so
14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
15 | TMPDIRNAME=tmp-packaging
16 | OUTPUT_PATH=../${CND_CONF}/libCommonUtilitiesLib.a
17 | OUTPUT_BASENAME=libCommonUtilitiesLib.a
18 | PACKAGE_TOP_DIR=CommonUtilitiesLib/
19 |
20 | # Functions
21 | function checkReturnCode
22 | {
23 | rc=$?
24 | if [ $rc != 0 ]
25 | then
26 | exit $rc
27 | fi
28 | }
29 | function makeDirectory
30 | # $1 directory path
31 | # $2 permission (optional)
32 | {
33 | mkdir -p "$1"
34 | checkReturnCode
35 | if [ "$2" != "" ]
36 | then
37 | chmod $2 "$1"
38 | checkReturnCode
39 | fi
40 | }
41 | function copyFileToTmpDir
42 | # $1 from-file path
43 | # $2 to-file path
44 | # $3 permission
45 | {
46 | cp "$1" "$2"
47 | checkReturnCode
48 | if [ "$3" != "" ]
49 | then
50 | chmod $3 "$2"
51 | checkReturnCode
52 | fi
53 | }
54 |
55 | # Setup
56 | cd "${TOP}"
57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
58 | rm -rf ${NBTMPDIR}
59 | mkdir -p ${NBTMPDIR}
60 |
61 | # Copy files and create directories and links
62 | cd "${TOP}"
63 | makeDirectory "${NBTMPDIR}/CommonUtilitiesLib/lib"
64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644
65 |
66 |
67 | # Generate tar file
68 | cd "${TOP}"
69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/CommonUtilitiesLib.tar
70 | cd ${NBTMPDIR}
71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/CommonUtilitiesLib.tar *
72 | checkReturnCode
73 |
74 | # Cleanup
75 | cd "${TOP}"
76 | rm -rf ${NBTMPDIR}
77 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/nbproject/Package-Release.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | #
4 | # Generated - do not edit!
5 | #
6 |
7 | # Macros
8 | TOP=`pwd`
9 | CND_PLATFORM=GM8126-Linux-x86
10 | CND_CONF=Release
11 | CND_DISTDIR=dist
12 | CND_BUILDDIR=build
13 | CND_DLIB_EXT=so
14 | NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
15 | TMPDIRNAME=tmp-packaging
16 | OUTPUT_PATH=../${CND_CONF}/libCommonUtilitiesLib.a
17 | OUTPUT_BASENAME=libCommonUtilitiesLib.a
18 | PACKAGE_TOP_DIR=CommonUtilitiesLib/
19 |
20 | # Functions
21 | function checkReturnCode
22 | {
23 | rc=$?
24 | if [ $rc != 0 ]
25 | then
26 | exit $rc
27 | fi
28 | }
29 | function makeDirectory
30 | # $1 directory path
31 | # $2 permission (optional)
32 | {
33 | mkdir -p "$1"
34 | checkReturnCode
35 | if [ "$2" != "" ]
36 | then
37 | chmod $2 "$1"
38 | checkReturnCode
39 | fi
40 | }
41 | function copyFileToTmpDir
42 | # $1 from-file path
43 | # $2 to-file path
44 | # $3 permission
45 | {
46 | cp "$1" "$2"
47 | checkReturnCode
48 | if [ "$3" != "" ]
49 | then
50 | chmod $3 "$2"
51 | checkReturnCode
52 | fi
53 | }
54 |
55 | # Setup
56 | cd "${TOP}"
57 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
58 | rm -rf ${NBTMPDIR}
59 | mkdir -p ${NBTMPDIR}
60 |
61 | # Copy files and create directories and links
62 | cd "${TOP}"
63 | makeDirectory "${NBTMPDIR}/CommonUtilitiesLib/lib"
64 | copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644
65 |
66 |
67 | # Generate tar file
68 | cd "${TOP}"
69 | rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/CommonUtilitiesLib.tar
70 | cd ${NBTMPDIR}
71 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/CommonUtilitiesLib.tar *
72 | checkReturnCode
73 |
74 | # Cleanup
75 | cd "${TOP}"
76 | rm -rf ${NBTMPDIR}
77 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/mymutex.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
7 | *
8 | * This file contains Original Code and/or Modifications of Original Code
9 | * as defined in and that are subject to the Apple Public Source License
10 | * Version 2.0 (the 'License'). You may not use this file except in
11 | * compliance with the License. Please obtain a copy of the License at
12 | * http://www.opensource.apple.com/apsl/ and read it before using this
13 | * file.
14 | *
15 | * The Original Code and all software distributed under the License are
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 | * Please see the License for the specific language governing rights and
21 | * limitations under the License.
22 | *
23 | * @APPLE_LICENSE_HEADER_END@
24 | */
25 | /*
26 | File: mymutex.h
27 |
28 | Contains: xxx put contents here xxx
29 |
30 | Written by: Greg Vaughan
31 |
32 | Change History (most recent first):
33 |
34 | <2> 10/27/99 GBV update for beaker
35 |
36 | To Do:
37 | */
38 |
39 | #ifndef _MYMUTEX_H_
40 | #define _MYMUTEX_H_
41 |
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | #include
48 | #include
49 |
50 | typedef void* mymutex_t;
51 | mymutex_t mymutex_alloc();
52 | void mymutex_free(mymutex_t);
53 |
54 | void mymutex_lock(mymutex_t);
55 | int mymutex_try_lock(mymutex_t);
56 | void mymutex_unlock(mymutex_t);
57 |
58 | #ifdef __cplusplus
59 | }
60 | #endif
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/Server.tproj/QTSSSocket.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QTSSSocket.h
27 |
28 | Contains: A QTSS Stream object for a generic socket
29 |
30 | Written By: Denis Serenyi
31 |
32 |
33 |
34 |
35 | */
36 |
37 | #ifndef __QTSS_SOCKET_H__
38 | #define __QTSS_SOCKET_H__
39 |
40 | #include "QTSS.h"
41 | #include "EventContext.h"
42 | #include "QTSSStream.h"
43 | #include "Socket.h"
44 |
45 | class QTSSSocket : public QTSSStream
46 | {
47 | public:
48 |
49 | QTSSSocket(int inFileDesc) : fEventContext(inFileDesc, Socket::GetEventThread()) {}
50 | virtual ~QTSSSocket() {}
51 |
52 | //
53 | // The only operation this stream supports is the requesting of events.
54 | virtual QTSS_Error RequestEvent(QTSS_EventType inEventMask);
55 |
56 | private:
57 |
58 | EventContext fEventContext;
59 | };
60 |
61 | #endif //__QTSS_SOCKET_H__
62 |
63 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/atomic.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #include "atomic.h"
27 | #include "OSMutex.h"
28 |
29 | static OSMutex sAtomicMutex;
30 |
31 |
32 | unsigned int atomic_add(unsigned int *area, int val)
33 | {
34 | OSMutexLocker locker(&sAtomicMutex);
35 | *area += val;
36 | return *area;
37 | }
38 |
39 | unsigned int atomic_sub(unsigned int *area,int val)
40 | {
41 | return atomic_add(area,-val);
42 | }
43 |
44 | unsigned int atomic_or(unsigned int *area, unsigned int val)
45 | {
46 | unsigned int oldval;
47 |
48 | OSMutexLocker locker(&sAtomicMutex);
49 | oldval=*area;
50 | *area = oldval | val;
51 | return oldval;
52 | }
53 |
54 | unsigned int compare_and_store(unsigned int oval, unsigned int nval, unsigned int *area)
55 | {
56 | int rv;
57 | OSMutexLocker locker(&sAtomicMutex);
58 | if( oval == *area )
59 | {
60 | rv=1;
61 | *area = nval;
62 | }
63 | else
64 | rv=0;
65 | return rv;
66 | }
67 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/mycondition.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
7 | *
8 | * This file contains Original Code and/or Modifications of Original Code
9 | * as defined in and that are subject to the Apple Public Source License
10 | * Version 2.0 (the 'License'). You may not use this file except in
11 | * compliance with the License. Please obtain a copy of the License at
12 | * http://www.opensource.apple.com/apsl/ and read it before using this
13 | * file.
14 | *
15 | * The Original Code and all software distributed under the License are
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 | * Please see the License for the specific language governing rights and
21 | * limitations under the License.
22 | *
23 | * @APPLE_LICENSE_HEADER_END@
24 | */
25 | /*
26 | File: mycondition.h
27 |
28 | Contains: xxx put contents here xxx
29 |
30 | Written by: Greg Vaughan
31 |
32 | Change History (most recent first):
33 |
34 | <2> 10/27/99 GBV update for beaker
35 |
36 | To Do:
37 | */
38 |
39 | #ifndef _MYCONDITION_H_
40 | #define _MYCONDITION_H_
41 |
42 |
43 | #include
44 | #include
45 |
46 | #include "mymutex.h"
47 |
48 | #ifdef __cplusplus
49 | extern "C" {
50 | #endif
51 |
52 | typedef void* mycondition_t;
53 | mycondition_t mycondition_alloc();
54 | void mycondition_free(mycondition_t);
55 |
56 | void mycondition_broadcast(mycondition_t);
57 | void mycondition_signal(mycondition_t);
58 | void mycondition_wait(mycondition_t, mymutex_t, int); //timeout as a msec offset from now (0 means no timeout)
59 |
60 | #ifdef __cplusplus
61 | }
62 | #endif
63 |
64 | #endif
--------------------------------------------------------------------------------
/PrefsSourceLib/NetInfoPrefsSource.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: NetInfoPrefsSource.h
27 |
28 | Contains: Implements the PrefsSource interface wrt NetInfo database
29 |
30 | Written by: Denis Serenyi
31 |
32 | Change History (most recent first):
33 |
34 |
35 |
36 | */
37 |
38 | #ifndef __NETINFOPREFSSOURCE_H__
39 | #define __NETINFOPREFSSOURCE_H__
40 |
41 | #include "PrefsSource.h"
42 | #include "OSHeaders.h"
43 |
44 | class NetInfoPrefsSource : public PrefsSource
45 | {
46 | public:
47 |
48 | NetInfoPrefsSource();
49 | virtual ~NetInfoPrefsSource() {}
50 |
51 | virtual int GetValue(const char* inKey, char* ioValue);
52 | virtual int GetValueByIndex(const char* inKey, UInt32 inIndex, char* ioValue);
53 |
54 |
55 | void SetValue(char* inKey, char* inValue);
56 | void SetValueByIndex(char* inKey, char* inValue, UInt32 inIndex);
57 | };
58 |
59 | #endif //__NETINFOPREFSSOURCE_H__
60 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/Makefile.POSIX:
--------------------------------------------------------------------------------
1 | C++ = $(CPLUS)
2 | # Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | #
4 |
5 | NAME = CommonUtilitiesLib
6 | C++ = $(CPLUS)
7 | CC = $(CCOMP)
8 | LINK = $(LINKER)
9 | CCFLAGS += $(COMPILER_FLAGS) $(INCLUDE_FLAG) ../PlatformHeader.h -g -Wall
10 |
11 | # OPTIMIZATION
12 | CCFLAGS += -O2
13 |
14 | # EACH DIRECTORY WITH HEADERS MUST BE APPENDED IN THIS MANNER TO THE CCFLAGS
15 |
16 | CCFLAGS += -I.
17 | CCFLAGS += -I..
18 | CCFLAGS += -I../APIStubLib
19 | CCFLAGS += -I../RTPMetaInfoLib
20 | CCFLAGS += -I../APICommonCode
21 |
22 | C++FLAGS = $(CCFLAGS)
23 |
24 | CFILES = base64.c GetWord.c Trim.c md5.c
25 |
26 | CPPFILES = atomic.cpp\
27 | ConfParser.cpp\
28 | DateTranslator.cpp\
29 | EventContext.cpp\
30 | IdleTask.cpp\
31 | MyAssert.cpp \
32 | OS.cpp\
33 | OSCodeFragment.cpp \
34 | OSCond.cpp\
35 | OSFileSource.cpp \
36 | OSHeap.cpp\
37 | OSBufferPool.cpp \
38 | OSMutex.cpp \
39 | OSMutexRW.cpp \
40 | OSQueue.cpp\
41 | OSRef.cpp \
42 | OSThread.cpp\
43 | Socket.cpp \
44 | SocketUtils.cpp\
45 | ResizeableStringFormatter.cpp \
46 | StringFormatter.cpp\
47 | StringParser.cpp \
48 | StringTranslator.cpp\
49 | StrPtrLen.cpp \
50 | Task.cpp\
51 | TCPListenerSocket.cpp\
52 | TCPSocket.cpp\
53 | TimeoutTask.cpp \
54 | UDPDemuxer.cpp\
55 | UDPSocket.cpp \
56 | UDPSocketPool.cpp\
57 | ev.cpp \
58 | UserAgentParser.cpp \
59 | QueryParamList.cpp \
60 | md5digest.cpp \
61 | SDPUtils.cpp
62 |
63 | all: libCommonUtilitiesLib.a
64 |
65 | libCommonUtilitiesLib.a: $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
66 | ar -r libCommonUtilitiesLib.a $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
67 | ranlib libCommonUtilitiesLib.a
68 |
69 | install: libCommonUtilitiesLib.a
70 |
71 | clean:
72 | rm -f libCommonUtilitiesLib.a $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
73 |
74 | .SUFFIXES: .cpp .c .o
75 |
76 | .cpp.o:
77 | $(C++) -c -o $*.o $(DEFINES) $(C++FLAGS) $*.cpp
78 |
79 | .c.o:
80 | $(CC) -c -o $*.o $(DEFINES) $(CCFLAGS) $*.c
81 |
82 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/OSCodeFragment.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: OSDynamicLoader.h
27 |
28 | Contains: OS abstraction for loading code fragments.
29 |
30 |
31 |
32 | */
33 |
34 | #ifndef _OS_CODEFRAGMENT_H_
35 | #define _OS_CODEFRAGMENT_H_
36 |
37 | #include
38 | #include "SafeStdLib.h"
39 | #include "OSHeaders.h"
40 |
41 | #ifdef __MacOSX__
42 | #include
43 | #endif
44 |
45 | class OSCodeFragment
46 | {
47 | public:
48 |
49 | static void Initialize();
50 |
51 | OSCodeFragment(const char* inPath);
52 | ~OSCodeFragment();
53 |
54 | Bool16 IsValid() { return (fFragmentP != NULL); }
55 | void* GetSymbol(const char* inSymbolName);
56 |
57 | private:
58 |
59 | #ifdef __Win32__
60 | HMODULE fFragmentP;
61 | #elif __MacOSX__
62 | CFBundleRef fFragmentP;
63 | #else
64 | void* fFragmentP;
65 | #endif
66 | };
67 |
68 | #endif//_OS_CODEFRAGMENT_H_
69 |
--------------------------------------------------------------------------------
/APICommonCode/QTSSMemoryDeleter.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QTSSMemoryDeleter.h
27 |
28 | Contains: Auto object for deleting memory allocated by QTSS API callbacks,
29 | such as QTSS_GetValueAsString
30 |
31 | */
32 |
33 | #ifndef __QTSS_MEMORY_DELETER_H__
34 | #define __QTSS_MEMORY_DELETER_H__
35 |
36 | #include "MyAssert.h"
37 | #include "QTSS.h"
38 |
39 | template
40 | class QTSSMemoryDeleter
41 | {
42 | public:
43 | QTSSMemoryDeleter(T* victim) : fT(victim) {}
44 | ~QTSSMemoryDeleter() { QTSS_Delete(fT); }
45 |
46 | void ClearObject() { fT = NULL; }
47 |
48 | void SetObject(T* victim)
49 | {
50 | Assert(fT == NULL);
51 | fT = victim;
52 | }
53 | T* GetObject() { return fT; }
54 |
55 | operator T*() { return fT; }
56 |
57 | private:
58 |
59 | T* fT;
60 | };
61 |
62 | typedef QTSSMemoryDeleter QTSSCharArrayDeleter;
63 |
64 | #endif //__QTSS_MEMORY_DELETER_H__
65 |
66 |
67 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/ResizeableStringFormatter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: ResizeableStringFormatter.cpp
27 |
28 | Contains: Implements object defined in ResizeableStringFormatter.h
29 |
30 |
31 | */
32 |
33 | #include "ResizeableStringFormatter.h"
34 | #include "OSMemory.h"
35 |
36 | Bool16 ResizeableStringFormatter::BufferIsFull(char* inBuffer, UInt32 inBufferLen)
37 | {
38 | //allocate a buffer twice as big as the old one, and copy over the contents
39 | UInt32 theNewBufferSize = this->GetTotalBufferSize() * 2;
40 | if (theNewBufferSize == 0)
41 | theNewBufferSize = 64;
42 |
43 | char* theNewBuffer = NEW char[theNewBufferSize];
44 | ::memcpy(theNewBuffer, inBuffer, inBufferLen);
45 |
46 | //if the old buffer was dynamically allocated also, we'd better delete it.
47 | if (inBuffer != fOriginalBuffer)
48 | delete [] inBuffer;
49 |
50 | fStartPut = theNewBuffer;
51 | fCurrentPut = theNewBuffer + inBufferLen;
52 | fEndPut = theNewBuffer + theNewBufferSize;
53 | return true;
54 | }
55 |
--------------------------------------------------------------------------------
/libClientCommondef.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013-2015 EasyDarwin.ORG. All rights reserved.
3 | Github: https://github.com/EasyDarwin
4 | WEChat: EasyDarwin
5 | Website: http://www.easydarwin.org
6 | */
7 | #ifndef _LIB_CLIENT_COMMON_DEF_H
8 | #define _LIB_CLIENT_COMMON_DEF_H
9 |
10 |
11 | ///////////////////////////////////////////////////////////////////////////
12 |
13 | namespace EasyDSS { namespace libEDClient
14 | {
15 |
16 | #define LIB_CLIENT_RETURN_ERROR_OK 0
17 |
18 | enum ClientMsgType
19 | {
20 | CLIENT_ERROR = 0,
21 | CLIENT_MSG_REGISTER_USER,
22 | CLIENT_MSG_LOGIN,
23 | CLIENT_MSG_HEARTBEAT,
24 | CLIENT_MSG_GET_DEVICE_LIST,
25 | CLIENT_MSG_GET_DEVICE_INFO,
26 | CLIENT_MSG_GET_USER_INFO,
27 | CLIENT_MSG_PUBLISH_STREAM,
28 | CLIENT_MSG_PUBLISH_STREAM_START
29 | };
30 |
31 | #define LOGIN_TYPE_USER_ACCESS "UserAccess"
32 | #define LOGIN_TYPE_PHONE_NUM "PhoneNum"
33 | #define LOGIN_TYPE_EMAIL "Email"
34 | #define LOGIN_TYPE_SERIAL "Serail"
35 |
36 | enum
37 | {
38 | Easy_NoErr = 0,
39 | Easy_RequestFailed = -1,
40 | Easy_Unimplemented = -2,
41 | Easy_RequestArrived = -3,
42 | Easy_OutOfState = -4,
43 | Easy_NotAModule = -5,
44 | Easy_WrongVersion = -6,
45 | Easy_IllegalService = -7,
46 | Easy_BadIndex = -8,
47 | Easy_ValueNotFound = -9,
48 | Easy_BadArgument = -10,
49 | Easy_ReadOnly = -11,
50 | Easy_NotPreemptiveSafe = -12,
51 | Easy_NotEnoughSpace = -13,
52 | Easy_WouldBlock = -14,
53 | Easy_NotConnected = -15,
54 | Easy_FileNotFound = -16,
55 | Easy_NoMoreData = -17,
56 | Easy_AttrDoesntExist = -18,
57 | Easy_AttrNameExists = -19,
58 | Easy_InstanceAttrsNotAllowed= -20,
59 | Easy_InvalidSocket = -21,
60 | Easy_MallocError = -22,
61 | Easy_ConnectError = -23,
62 | Easy_SendError = -24
63 | };
64 | typedef int Easy_Error;
65 |
66 | /////////////////////////////////////////////////////////////////////////////////////////////
67 | typedef void(*ClientLogCallback)(const char* msg, void* pClient);
68 |
69 | }
70 | }
71 |
72 | #endif
--------------------------------------------------------------------------------
/WinNTSupport/Win32header.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
7 | *
8 | * This file contains Original Code and/or Modifications of Original Code
9 | * as defined in and that are subject to the Apple Public Source License
10 | * Version 2.0 (the 'License'). You may not use this file except in
11 | * compliance with the License. Please obtain a copy of the License at
12 | * http://www.opensource.apple.com/apsl/ and read it before using this
13 | * file.
14 | *
15 | * The Original Code and all software distributed under the License are
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 | * Please see the License for the specific language governing rights and
21 | * limitations under the License.
22 | *
23 | * @APPLE_LICENSE_HEADER_END@
24 | */
25 | #define __Win32__ 1
26 | #define _MT 1
27 |
28 | /* Defines needed to compile windows headers */
29 |
30 | #ifndef _X86_
31 | #define _X86_ 1
32 | #endif
33 |
34 | /* Pro4 compilers should automatically define this to appropriate value */
35 | #ifndef _M_IX86
36 | #define _M_IX86 500
37 | #endif
38 |
39 | #ifndef WIN32
40 | /* same as definition in OLE2.h where 100 implies WinNT version 1.0 */
41 | #define WIN32 100
42 | #endif
43 |
44 | #ifndef _WIN32
45 | #define _WIN32 1
46 | #endif
47 |
48 | #ifndef _MSC_VER
49 | /* we implement the feature set of CL 9.0 (MSVC++ 2) */
50 | #define _MSC_VER 900
51 | #endif
52 |
53 | #ifndef _CRTAPI1
54 | #define _CRTAPI1 __cdecl
55 | #endif
56 |
57 | #ifndef _WIN32_WINNT
58 | #define _WIN32_WINNT 0x0400
59 | #endif
60 |
61 | #ifndef _WIN32_IE
62 | #define _WIN32_IE 0x0400
63 | #endif
64 |
65 | #define _CRT_SECURE_NO_WARNINGS
66 | #define _CRT_NONSTDC_NO_WARNINGS
67 |
68 | #include "PlatformHeader.h"
69 | #include "revision.h"
70 | #include
--------------------------------------------------------------------------------
/CommonUtilitiesLib/StopWatch.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 |
27 | /*
28 | File: StopWatch.h
29 |
30 | Contains: classes for stopwatch timers
31 |
32 | */
33 |
34 |
35 | #include "OS.h"
36 |
37 | class MilliSecondStopWatch {
38 |
39 | public:
40 | MilliSecondStopWatch () { fStartedAt = -1; fStoppedAt = -1; }
41 |
42 | void Start() { fStartedAt = OS::Milliseconds(); }
43 | void Stop() { fStoppedAt = OS::Milliseconds(); }
44 | SInt64 Duration() { return fStoppedAt - fStartedAt; }
45 | private:
46 | SInt64 fStartedAt;
47 | SInt64 fStoppedAt;
48 |
49 | };
50 |
51 |
52 |
53 | class MicroSecondStopWatch {
54 |
55 | public:
56 | MicroSecondStopWatch () { fStartedAt = -1; fStoppedAt = -1; }
57 |
58 | void Start() { fStartedAt = OS::Microseconds(); }
59 | void Stop() { fStoppedAt = OS::Microseconds(); }
60 | SInt64 Duration() { return fStoppedAt - fStartedAt; }
61 | private:
62 | SInt64 fStartedAt;
63 | SInt64 fStoppedAt;
64 |
65 | };
66 |
67 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/OSBufferPool.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: OSBufferPool.cpp
27 |
28 | Contains: Fast access to fixed size buffers.
29 |
30 | Written By: Denis Serenyi
31 |
32 | */
33 |
34 | #include "OSBufferPool.h"
35 | #include "OSMemory.h"
36 | #ifdef _WIN32
37 | #include
38 | #endif
39 |
40 | void* OSBufferPool::Get()
41 | {
42 | OSMutexLocker locker(&fMutex);
43 | if (fQueue.GetLength() == 0)
44 | {
45 | fTotNumBuffers++;
46 | char* theNewBuf = NEW char[fBufSize + sizeof(OSQueueElem)];
47 |
48 | //
49 | // We need to construct a Queue Element, but we don't actually need
50 | // to use it in this function, so to avoid a compiler warning just
51 | // don't assign the result to anything.
52 | (void)new (theNewBuf) OSQueueElem(theNewBuf + sizeof(OSQueueElem));
53 |
54 | return theNewBuf + sizeof(OSQueueElem);
55 | }
56 | return fQueue.DeQueue()->GetEnclosingObject();
57 | }
58 |
59 | void OSBufferPool::Put(void* inBuffer)
60 | {
61 | OSMutexLocker locker(&fMutex);
62 | fQueue.EnQueue((OSQueueElem*)((char*)inBuffer - sizeof(OSQueueElem)));
63 | }
64 |
--------------------------------------------------------------------------------
/APIStubLib/BuildAPIStubLib:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | x=`uname`
4 | y=`uname -m`
5 |
6 | PLAT=$x.$y
7 |
8 | echo $PLAT
9 |
10 | case $PLAT in
11 |
12 | Linux.ppc)
13 | echo "Configuring for a Linux PPC platform"
14 | CPLUS='egcs'
15 | CCOMP=egcs
16 | LINKER='egcs'
17 | MACHDEFINES=-D__linuxppc__
18 | LIB="ar -r "
19 | if [ -f /usr/include/socketbits.h ]; then
20 | NEED_SOCKETBITS=1
21 | export NEED_SOCKETBITS
22 | fi
23 | ;;
24 |
25 | Linux.i586 | \
26 | Linux.i686)
27 | echo "Configuring for a Linux x86 platform"
28 | CPLUS='egcs'
29 | CCOMP=egcs
30 | LINKER='egcs'
31 | MACHDEFINES=-D__linux__
32 | LIB="ar -r "
33 | if [ -f /usr/include/socketbits.h ]; then
34 | NEED_SOCKETBITS=1
35 | export NEED_SOCKETBITS
36 | fi
37 | ;;
38 |
39 | FreeBSD.i386)
40 | echo "Configuring for a FreeBSD platform"
41 | CPLUS=gcc
42 | CCOMP=gcc
43 | LINKER="gcc"
44 | MACHDEFINES="-D__FreeBSD__ -fhandle-exceptions"
45 | LIB="ar -r "
46 | ;;
47 | buildplay
48 | # SunOS.sun4m)
49 | SunOS.*)
50 | echo "Configuring for a Solaris platform"
51 | CPLUS=gcc
52 | CCOMP=gcc
53 | LINKER="gcc"
54 | MACHDEFINES="-D__solaris__"
55 | LIB="/usr/ccs/bin/ar -r "
56 | ;;
57 |
58 | IRIX*.*)
59 | # IRIX and MipsPro compiler
60 | echo "Configuring for IRIX platform"
61 | CPLUS=CC
62 | CCOMP=cc
63 | LINKER="CC"
64 | MACHDEFINES="-D__sgi__ -DirixMipsPro -D_SGI_REENTRANT_FUNCTIONS -DASSERT -D__PTHREADS__ -D__PTHREADS_MUTEXES__ -DBIGENDIAN -DUSE_THREAD -DEXPORT -D_REENTRANT"
65 | LIB="ar -r "
66 | ;;
67 |
68 | *)
69 | echo "I don't know your platform. I'll assume this is a Linux x86 platform."
70 | echo "Please edit the BuildServer script & PlatformHeader.h to add your platform."
71 | CPLUS='egcs'
72 | CCOMP=egcs
73 | LINKER='egcs'
74 | MACHDEFINES=-D__linux__
75 | LIB="ar -r "
76 | if [ -f /usr/include/socketbits.h ]; then
77 | NEED_SOCKETBITS=1
78 | export NEED_SOCKETBITS
79 | fi
80 | ;;
81 | esac
82 |
83 | echo Building for $PLAT with $CPLUS
84 |
85 | export CPLUS
86 | echo "CPLUS " $CPLUS
87 | export CCOMP
88 | echo "CCOMP " $CCOMP
89 | export LINKER
90 | echo "LINKER " $LINKER
91 | export MACHDEFINES
92 | echo "MACHDEFINES " $MACHDEFINES
93 | export LIB
94 | echo "LIB " $LIB
95 |
96 | make -f makefile.apistublib.POSIX
97 |
98 |
99 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/UDPDemuxer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: UDPDemuxer.cpp
27 |
28 | Contains: Implements objects defined in UDPDemuxer.h
29 |
30 |
31 |
32 | */
33 |
34 | #include "UDPDemuxer.h"
35 |
36 | #include
37 |
38 |
39 | OS_Error UDPDemuxer::RegisterTask(UInt32 inRemoteAddr, UInt16 inRemotePort,
40 | UDPDemuxerTask *inTaskP)
41 | {
42 | Assert(NULL != inTaskP);
43 | OSMutexLocker locker(&fMutex);
44 | if (this->GetTask(inRemoteAddr, inRemotePort) != NULL)
45 | return EPERM;
46 | inTaskP->Set(inRemoteAddr, inRemotePort);
47 | fHashTable.Add(inTaskP);
48 | return OS_NoErr;
49 | }
50 |
51 | OS_Error UDPDemuxer::UnregisterTask(UInt32 inRemoteAddr, UInt16 inRemotePort,
52 | UDPDemuxerTask *inTaskP)
53 | {
54 | OSMutexLocker locker(&fMutex);
55 | //remove by executing a lookup based on key information
56 | UDPDemuxerTask* theTask = this->GetTask(inRemoteAddr, inRemotePort);
57 |
58 | if ((NULL != theTask) && (theTask == inTaskP))
59 | {
60 | fHashTable.Remove(theTask);
61 | return OS_NoErr;
62 | }
63 | else
64 | return EPERM;
65 | }
66 |
67 | UDPDemuxerTask* UDPDemuxer::GetTask(UInt32 inRemoteAddr, UInt16 inRemotePort)
68 | {
69 | UDPDemuxerKey theKey(inRemoteAddr, inRemotePort);
70 | return fHashTable.Map(&theKey);
71 | }
72 |
--------------------------------------------------------------------------------
/Server.tproj/QTSSFile.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QTSSFile.h
27 |
28 | Contains:
29 |
30 |
31 |
32 |
33 | */
34 |
35 | #include "QTSSDictionary.h"
36 | #include "QTSSModule.h"
37 |
38 | #include "OSFileSource.h"
39 | #include "EventContext.h"
40 |
41 | class QTSSFile : public QTSSDictionary
42 | {
43 | public:
44 |
45 | QTSSFile();
46 | virtual ~QTSSFile() {}
47 |
48 | static void Initialize();
49 |
50 | //
51 | // Opening & Closing
52 | QTSS_Error Open(char* inPath, QTSS_OpenFileFlags inFlags);
53 | void Close();
54 |
55 | //
56 | // Implementation of stream functions.
57 | virtual QTSS_Error Read(void* ioBuffer, UInt32 inLen, UInt32* outLen);
58 |
59 | virtual QTSS_Error Seek(UInt64 inNewPosition);
60 |
61 | virtual QTSS_Error Advise(UInt64 inPosition, UInt32 inAdviseSize);
62 |
63 | virtual QTSS_Error RequestEvent(QTSS_EventType inEventMask);
64 |
65 | private:
66 |
67 | QTSSModule* fModule;
68 | UInt64 fPosition;
69 | QTSSFile* fThisPtr;
70 |
71 | //
72 | // File attributes
73 | UInt64 fLength;
74 | time_t fModDate;
75 |
76 | static QTSSAttrInfoDict::AttrInfo sAttributes[];
77 | };
78 |
79 |
--------------------------------------------------------------------------------
/defaultPaths.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | /*
27 | * defaultPaths.h - define the default paths to hardcode into the executables
28 | *
29 | * IMPORTANT NOTE : The trailering directory separators are required on all
30 | * DEFAULTPATHS_*_DIR* defines
31 | *
32 | * Contributed by: Peter Bray
33 | */
34 |
35 | #ifdef __Win32__
36 |
37 | # define DEFAULTPATHS_DIRECTORY_SEPARATOR "\\"
38 |
39 | # define DEFAULTPATHS_ETC_DIR "./"
40 | # define DEFAULTPATHS_ETC_DIR_OLD "./"
41 | # define DEFAULTPATHS_SSM_DIR "./QTSSModules/"
42 | # define DEFAULTPATHS_LOG_DIR "./Logs/"
43 | # define DEFAULTPATHS_PID_FILE ""
44 | # define DEFAULTPATHS_PID_DIR ""
45 | #elif __MacOSX__
46 |
47 | # define DEFAULTPATHS_DIRECTORY_SEPARATOR "/"
48 |
49 | # define DEFAULTPATHS_ETC_DIR "/Library/QuickTimeStreaming/Config/"
50 | # define DEFAULTPATHS_ETC_DIR_OLD "/etc/"
51 | # define DEFAULTPATHS_SSM_DIR "/Library/QuickTimeStreaming/Modules/"
52 | # define DEFAULTPATHS_LOG_DIR "/Library/QuickTimeStreaming/Logs/"
53 | # define DEFAULTPATHS_PID_DIR "/var/run/"
54 |
55 | #else
56 |
57 | # define DEFAULTPATHS_DIRECTORY_SEPARATOR "/"
58 |
59 | # define DEFAULTPATHS_ETC_DIR "/etc/streaming/"
60 | # define DEFAULTPATHS_ETC_DIR_OLD "/etc/"
61 | # define DEFAULTPATHS_SSM_DIR "/usr/local/sbin/StreamingServerModules/"
62 | # define DEFAULTPATHS_LOG_DIR "/var/streaming/logs/"
63 | # define DEFAULTPATHS_PID_DIR "/var/run/"
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/OSBufferPool.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: OSBufferPool.h
27 |
28 | Contains: Fast access to fixed size buffers.
29 |
30 | Written By: Denis Serenyi
31 |
32 | */
33 |
34 | #ifndef __OS_BUFFER_POOL_H__
35 | #define __OS_BUFFER_POOL_H__
36 |
37 | #include "OSQueue.h"
38 | #include "OSMutex.h"
39 |
40 | class OSBufferPool
41 | {
42 | public:
43 |
44 | OSBufferPool(UInt32 inBufferSize) : fBufSize(inBufferSize), fTotNumBuffers(0) {}
45 |
46 | //
47 | // This object currently *does not* clean up for itself when
48 | // you destruct it!
49 | ~OSBufferPool() {}
50 |
51 | //
52 | // ACCESSORS
53 | UInt32 GetTotalNumBuffers() { return fTotNumBuffers; }
54 | UInt32 GetNumAvailableBuffers() { return fQueue.GetLength(); }
55 |
56 | //
57 | // All these functions are thread-safe
58 |
59 | //
60 | // Gets a buffer out of the pool. This buffer must be replaced
61 | // by calling Put when you are done with it.
62 | void* Get();
63 |
64 | //
65 | // Returns a buffer retreived by Get back to the pool.
66 | void Put(void* inBuffer);
67 |
68 | private:
69 |
70 | OSMutex fMutex;
71 | OSQueue fQueue;
72 | UInt32 fBufSize;
73 | UInt32 fTotNumBuffers;
74 | };
75 |
76 | #endif //__OS_BUFFER_POOL_H__
77 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/OSArrayObjectDeleter.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: OSArrayObjectDeleter.h
27 |
28 | Contains: Auto object for deleting arrays.
29 |
30 |
31 |
32 | */
33 |
34 | #ifndef __OS_ARRAY_OBJECT_DELETER_H__
35 | #define __OS_ARRAY_OBJECT_DELETER_H__
36 |
37 | #include "MyAssert.h"
38 |
39 | template
40 | class OSArrayObjectDeleter
41 | {
42 | public:
43 | OSArrayObjectDeleter() : fT(NULL) {}
44 | OSArrayObjectDeleter(T* victim) : fT(victim) {}
45 | ~OSArrayObjectDeleter() { delete [] fT; }
46 |
47 | void ClearObject() { fT = NULL; }
48 |
49 | void SetObject(T* victim)
50 | {
51 | Assert(fT == NULL);
52 | fT = victim;
53 | }
54 | T* GetObject() { return fT; }
55 |
56 | operator T*() { return fT; }
57 |
58 | private:
59 |
60 | T* fT;
61 | };
62 |
63 |
64 | template
65 | class OSPtrDeleter
66 | {
67 | public:
68 | OSPtrDeleter() : fT(NULL) {}
69 | OSPtrDeleter(T* victim) : fT(victim) {}
70 | ~OSPtrDeleter() { delete fT; }
71 |
72 | void ClearObject() { fT = NULL; }
73 |
74 | void SetObject(T* victim)
75 | { Assert(fT == NULL);
76 | fT = victim;
77 | }
78 |
79 | private:
80 |
81 | T* fT;
82 | };
83 |
84 |
85 | typedef OSArrayObjectDeleter OSCharPointerArrayDeleter;
86 | typedef OSArrayObjectDeleter OSCharArrayDeleter;
87 |
88 | #endif //__OS_OBJECT_ARRAY_DELETER_H__
89 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/ResizeableStringFormatter.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: ResizeableStringFormatter.h
27 |
28 | Contains: Derived from StringFormatter, this transparently grows the
29 | output buffer if the original buffer is too small to hold all
30 | the data being placed in it
31 |
32 |
33 |
34 | */
35 |
36 | #ifndef __RESIZEABLE_STRING_FORMATTER_H__
37 | #define __RESIZEABLE_STRING_FORMATTER_H__
38 |
39 | #include "StringFormatter.h"
40 |
41 | class ResizeableStringFormatter : public StringFormatter
42 | {
43 | public:
44 | // Pass in inBuffer=NULL and inBufSize=0 to dynamically allocate the initial buffer.
45 | ResizeableStringFormatter(char* inBuffer = NULL, UInt32 inBufSize = 0)
46 | : StringFormatter(inBuffer, inBufSize), fOriginalBuffer(inBuffer) {}
47 |
48 | //If we've been forced to increase the buffer size, fStartPut WILL be a dynamically allocated
49 | //buffer, and it WON'T be equal to fOriginalBuffer (obviously).
50 | virtual ~ResizeableStringFormatter() { if (fStartPut != fOriginalBuffer) delete [] fStartPut; }
51 |
52 | private:
53 |
54 | // This function will get called by StringFormatter if the current
55 | // output buffer is full. This object allocates a buffer that's twice
56 | // as big as the old one.
57 | virtual Bool16 BufferIsFull(char* inBuffer, UInt32 inBufferLen);
58 |
59 | char* fOriginalBuffer;
60 |
61 | };
62 |
63 | #endif //__RESIZEABLE_STRING_FORMATTER_H__
64 |
--------------------------------------------------------------------------------
/Server.tproj/QTSSMessages.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QTSSMessages.h
27 |
28 | Contains: This global dictionary provides a central mapping from message
29 | names to actual text messages, stored in the provided prefs source.
30 |
31 | This allows the whole server to be easily localizeable.
32 |
33 |
34 |
35 | */
36 |
37 | #ifndef __QTSSMESSAGES_H__
38 | #define __QTSSMESSAGES_H__
39 |
40 | #include "QTSS.h"
41 | #include "QTSSDictionary.h"
42 | #include "PrefsSource.h"
43 |
44 | class QTSSMessages : public QTSSDictionary
45 | {
46 | public:
47 |
48 | // INITIALIZE
49 | //
50 | // This function sets up the dictionary map. Must be called before instantiating
51 | // the first RTSPMessages object.
52 |
53 | static void Initialize();
54 |
55 | QTSSMessages(PrefsSource* inMessages);
56 | virtual ~QTSSMessages() {
57 | for (UInt32 x = 0; x < numAttrs; x++)
58 | if (attrBuffer[x] != NULL)
59 | delete [] attrBuffer[x];
60 | delete [] attrBuffer;
61 | }
62 |
63 |
64 | //Use the standard GetAttribute method in QTSSDictionary to retrieve messages
65 |
66 | private:
67 | char** attrBuffer;
68 | UInt32 numAttrs;
69 |
70 | enum
71 | {
72 | kNumMessages = 74 // 0 based count so it is one more than last message index number
73 | };
74 |
75 | static char* sMessagesKeyStrings[];
76 | static char* sMessages[];
77 | };
78 |
79 |
80 | #endif // __QTSSMESSAGES_H__
81 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/ev.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #ifndef _DSS_SYS_EV_H_
27 | #define _DSS_SYS_EV_H_
28 |
29 |
30 |
31 | #if !defined(__Win32__) && !defined(__solaris__) && !defined(__sgi__) && !defined(__osf__) && !defined(__hpux__)
32 | #include
33 | #endif
34 |
35 | #if MACOSXEVENTQUEUE
36 | #include
37 | #else
38 |
39 |
40 | struct eventreq {
41 | int er_type;
42 | #define EV_FD 1 // file descriptor
43 | int er_handle;
44 | void *er_data;
45 | int er_rcnt;
46 | int er_wcnt;
47 | int er_ecnt;
48 | int er_eventbits;
49 | #define EV_RE 1
50 | #define EV_WR 2
51 | #define EV_EX 4
52 | #define EV_RM 8
53 | };
54 |
55 | typedef struct eventreq *er_t;
56 |
57 |
58 | #ifdef _KERNEL
59 |
60 | #define EV_RBYTES 0x1
61 | #define EV_WBYTES 0x2
62 | #define EV_RWBYTES (EV_RBYTES|EV_WBYTES)
63 | #define EV_RCLOSED 0x4
64 | #define EV_RCONN 0x8
65 | #define EV_ERRORS 0x10
66 | #define EV_WCLOSED 0x20
67 | #define EV_WCONN 0x40
68 | #define EV_OOBD 0x80
69 | #define EV_OOBM 0x100
70 |
71 | struct eventqelt {
72 | TAILQ_ENTRY(eventqelt) ee_slist;
73 | TAILQ_ENTRY(eventqelt) ee_plist;
74 | struct eventreq ee_req;
75 | struct proc * ee_proc;
76 | u_int ee_flags;
77 | #define EV_QUEUED 1
78 | u_int ee_eventmask;
79 | struct socket *ee_sp;
80 | };
81 |
82 | #endif /* _KERNEL */
83 |
84 |
85 | int select_watchevent(struct eventreq *req, int which);
86 | int select_modwatch(struct eventreq *req, int which);
87 | int select_waitevent(struct eventreq *req, void* onlyForMOSX);
88 | void select_startevents();
89 | int select_removeevent(int which);
90 |
91 | #endif /* !MACOSXEVENTQUEUE */
92 |
93 | #endif /* _DSS_SYS_EV_H_ */
94 |
--------------------------------------------------------------------------------
/PrefsSourceLib/FilePrefsSource.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: FilePrefsSource.h
27 |
28 | Contains: Implements the PrefsSource interface, getting the prefs from a file.
29 |
30 | Written by: Chris LeCroy
31 |
32 |
33 |
34 |
35 | */
36 |
37 | #ifndef __FILEPREFSSOURCE_H__
38 | #define __FILEPREFSSOURCE_H__
39 |
40 | #include "PrefsSource.h"
41 | #include "OSHeaders.h"
42 |
43 | class KeyValuePair; //only used in the implementation
44 |
45 | class FilePrefsSource : public PrefsSource
46 | {
47 | public:
48 |
49 | FilePrefsSource( Bool16 allowDuplicates = false );
50 | virtual ~FilePrefsSource();
51 |
52 | virtual int GetValue(const char* inKey, char* ioValue);
53 | virtual int GetValueByIndex(const char* inKey, UInt32 inIndex, char* ioValue);
54 |
55 | // Allows caller to iterate over all the values in the file.
56 | char* GetValueAtIndex(UInt32 inIndex);
57 | char* GetKeyAtIndex(UInt32 inIndex);
58 | UInt32 GetNumKeys() { return fNumKeys; }
59 |
60 | int InitFromConfigFile(const char* configFilePath);
61 | void WriteToConfigFile(const char* configFilePath);
62 |
63 | void SetValue(const char* inKey, const char* inValue);
64 | void DeleteValue(const char* inKey);
65 |
66 | private:
67 |
68 | static Bool16 FilePrefsConfigSetter( const char* paramName, const char* paramValue[], void* userData );
69 |
70 | KeyValuePair* FindValue(const char* inKey, char* ioValue, UInt32 index = 0);
71 | KeyValuePair* fKeyValueList;
72 | UInt32 fNumKeys;
73 | Bool16 fAllowDuplicates;
74 | };
75 |
76 | #endif //__FILEPREFSSOURCE_H__
77 |
--------------------------------------------------------------------------------
/Server.tproj/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.cnd.makeproject
4 |
5 |
6 | EasyDarwin
7 |
8 | cpp
9 | h
10 | UTF-8
11 |
12 |
13 | .
14 | ../PrefsSourceLib
15 | ../OSMemoryLib
16 | ../RTSPClientLib
17 | ../HTTPUtilitiesLib
18 | ../RTCPUtilitiesLib
19 | ../RTPMetaInfoLib
20 | ../APIStubLib
21 | ../APICommonCode
22 | ../SafeStdLib
23 | ../APIModules/QTSSAccessLogModule
24 | ../APIModules/QTSSFileModule
25 | ../APIModules/QTSSFlowControlModule
26 | ../APIModules/QTSSReflectorModule
27 | ../APIModules/QTSSWebDebugModule
28 | ../APIModules/QTSSWebStatsModule
29 | ../APIModules/QTSSPOSIXFileSysModule
30 | ../APIModules/QTSSAdminModule
31 | ../APIModules/QTSSMP3StreamingModule
32 | ../APIModules/QTSSRTPFileModule
33 | ../APIModules/QTSSAccessModule
34 | ../APIModules/QTSSHttpFileModule
35 |
36 |
37 |
38 | Debug
39 | 1
40 |
41 |
42 | Release
43 | 1
44 |
45 |
46 |
47 | false
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Server.tproj/RunServer.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: RunServer.h
27 |
28 | Contains: Routines to run the Streaming Server
29 |
30 |
31 | */
32 |
33 |
34 | #include "OSHeaders.h"
35 | #include "XMLPrefsParser.h"
36 | #include "PrefsSource.h"
37 | #include "QTSS.h"
38 | #include "QTSServer.h"
39 |
40 | enum {
41 | kRunServerDebug_Off = 0,
42 | kRunServerDebugDisplay_On = 1 << 0,
43 | kRunServerDebugLogging_On = 1 << 1 // not implemented
44 | };
45 |
46 | inline Bool16 DebugOn(QTSServer* server) { return ( server->GetDebugOptions() != kRunServerDebug_Off ) ? true : false ; }
47 | inline Bool16 DebugDisplayOn(QTSServer* server) { return (server->GetDebugOptions() & kRunServerDebugDisplay_On) ? true : false ; }
48 | inline Bool16 DebugLogOn(QTSServer* server) { return (server->GetDebugOptions() & kRunServerDebugLogging_On) ? true : false ; }
49 |
50 | //
51 | // This function starts the Streaming Server. Pass in a source
52 | // for preferences, a source for text messages, and an optional
53 | // port to override the default.
54 | //
55 | // Returns the server state upon completion of startup. If this
56 | // is qtssFatalErrorState, something went horribly wrong and caller
57 | // should just die.
58 | QTSS_ServerState StartServer( XMLPrefsParser* inPrefsSource,
59 | PrefsSource* inMessagesSource,
60 | UInt16 inPortOverride,
61 | int statsUpdateInterval,
62 | QTSS_ServerState inInitialState,
63 | Bool16 inDontFork,
64 | UInt32 debugLevel,
65 | UInt32 debugOptions );
66 |
67 | //
68 | // Call this after StartServer if it doesn't return qtssFatalError.
69 | // This will not return until the server is going away
70 | void RunServer();
71 |
72 | // write pid to file
73 | void WritePid(Bool16 forked);
74 |
75 | // clean the pid file
76 | void CleanPid(Bool16 force);
77 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/md5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
7 | *
8 | * This file contains Original Code and/or Modifications of Original Code
9 | * as defined in and that are subject to the Apple Public Source License
10 | * Version 2.0 (the 'License'). You may not use this file except in
11 | * compliance with the License. Please obtain a copy of the License at
12 | * http://www.opensource.apple.com/apsl/ and read it before using this
13 | * file.
14 | *
15 | * The Original Code and all software distributed under the License are
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 | * Please see the License for the specific language governing rights and
21 | * limitations under the License.
22 | *
23 | * @APPLE_LICENSE_HEADER_END@
24 | */
25 | /* MD5.H - header file for MD5.C
26 | */
27 |
28 | /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
29 | rights reserved.
30 |
31 | License to copy and use this software is granted provided that it
32 | is identified as the "RSA Data Security, Inc. MD5 Message-Digest
33 | Algorithm" in all material mentioning or referencing this software
34 | or this function.
35 |
36 | License is also granted to make and use derivative works provided
37 | that such works are identified as "derived from the RSA Data
38 | Security, Inc. MD5 Message-Digest Algorithm" in all material
39 | mentioning or referencing the derived work.
40 |
41 | RSA Data Security, Inc. makes no representations concerning either
42 | the merchantability of this software or the suitability of this
43 | software for any particular purpose. It is provided "as is"
44 | without express or implied warranty of any kind.
45 |
46 | These notices must be retained in any copies of any part of this
47 | documentation and/or software.
48 | */
49 |
50 | /*
51 | Note: Renamed the functions to avoid having same symbols in
52 | the linked-in frameworks.
53 | It is a hack to work around the problem.
54 | */
55 |
56 | #ifndef _MD5_H_
57 | #define _MD5_H_
58 |
59 | #include "OSHeaders.h"
60 |
61 | #ifdef __cplusplus
62 | extern "C" {
63 | #endif
64 |
65 | /* MD5 context. */
66 | typedef struct {
67 | UInt32 state[4]; /* state (ABCD) */
68 | UInt32 count[2]; /* number of bits, modulo 2^64 (lsb first) */
69 | unsigned char buffer[64]; /* input buffer */
70 | } MD5_CTX;
71 |
72 | void MD5_Init(MD5_CTX *context);
73 | void MD5_Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen);
74 | void MD5_Final(unsigned char digest[16], MD5_CTX *context);
75 |
76 | #ifdef __cplusplus
77 | }
78 | #endif
79 |
80 | #endif
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/md5digest.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: md5digest.h
27 |
28 | Contains: Provides a function to calculate the md5 digest
29 | given all the authentication parameters.
30 |
31 | */
32 |
33 | #ifndef _MD5DIGEST_H_
34 | #define _MD5DIGEST_H_
35 |
36 | #include "StrPtrLen.h"
37 |
38 | enum {
39 | kHashHexLen = 32,
40 | kHashLen = 16
41 | };
42 |
43 | // HashToString allocates memory for hashStr->Ptr
44 | void HashToString(unsigned char aHash[kHashLen], StrPtrLen* hashStr);
45 |
46 | // allocates memory for hashA1Hex16Bit->Ptr
47 | void CalcMD5HA1(StrPtrLen* userName, StrPtrLen* realm, StrPtrLen* userPassword, StrPtrLen* hashA1Hex16Bit);
48 |
49 | // allocates memory to hA1->Ptr
50 | void CalcHA1( StrPtrLen* algorithm,
51 | StrPtrLen* userName,
52 | StrPtrLen* realm,
53 | StrPtrLen* userPassword,
54 | StrPtrLen* nonce,
55 | StrPtrLen* cNonce,
56 | StrPtrLen* hA1
57 | );
58 |
59 | // allocates memory to hA1->Ptr
60 | void CalcHA1Md5Sess(StrPtrLen* hashA1Hex16Bit, StrPtrLen* nonce, StrPtrLen* cNonce, StrPtrLen* hA1);
61 |
62 | // allocates memory for requestDigest->Ptr
63 | void CalcRequestDigest( StrPtrLen* hA1,
64 | StrPtrLen* nonce,
65 | StrPtrLen* nonceCount,
66 | StrPtrLen* cNonce,
67 | StrPtrLen* qop,
68 | StrPtrLen* method,
69 | StrPtrLen* digestUri,
70 | StrPtrLen* hEntity,
71 | StrPtrLen* requestDigest
72 | );
73 |
74 |
75 | void to64(register char *s, register SInt32 v, register int n);
76 |
77 | // Doesn't allocate any memory. The size of the result buffer should be nbytes
78 | void MD5Encode( char *pw, char *salt, char *result, int nbytes);
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/WinNTSupport/EasyNVR.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APICommonCode", "..\APICommonCode\APICommonCode.vcproj", "{EEEB3A6E-B4AF-4C09-AB57-7F2576CFE38D}"
5 | EndProject
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APIStubLib", "..\APIStubLib\APIStubLib.vcproj", "{21898038-6830-4B4D-BE2C-E32641F253BC}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CommonUtilitiesLib", "..\CommonUtilitiesLib\CommonUtilitiesLib.vcproj", "{4E4F758C-7CB5-471C-BD61-FB70BF69D48B}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SafeInternalStdLib", "..\SafeStdLib\SafeInternalStdLib.vcproj", "{230D5525-AEA7-4037-95FE-3B45BEF98E55}"
11 | ProjectSection(ProjectDependencies) = postProject
12 | {4E4F758C-7CB5-471C-BD61-FB70BF69D48B} = {4E4F758C-7CB5-471C-BD61-FB70BF69D48B}
13 | EndProjectSection
14 | EndProject
15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EasyCamera", "EasyNVR.vcproj", "{A0EFC09D-B539-40ED-B7A2-06177CBA669D}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Win32 = Debug|Win32
20 | Release|Win32 = Release|Win32
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {EEEB3A6E-B4AF-4C09-AB57-7F2576CFE38D}.Debug|Win32.ActiveCfg = Debug|Win32
24 | {EEEB3A6E-B4AF-4C09-AB57-7F2576CFE38D}.Debug|Win32.Build.0 = Debug|Win32
25 | {EEEB3A6E-B4AF-4C09-AB57-7F2576CFE38D}.Release|Win32.ActiveCfg = Release|Win32
26 | {EEEB3A6E-B4AF-4C09-AB57-7F2576CFE38D}.Release|Win32.Build.0 = Release|Win32
27 | {21898038-6830-4B4D-BE2C-E32641F253BC}.Debug|Win32.ActiveCfg = Debug|Win32
28 | {21898038-6830-4B4D-BE2C-E32641F253BC}.Debug|Win32.Build.0 = Debug|Win32
29 | {21898038-6830-4B4D-BE2C-E32641F253BC}.Release|Win32.ActiveCfg = Release|Win32
30 | {21898038-6830-4B4D-BE2C-E32641F253BC}.Release|Win32.Build.0 = Release|Win32
31 | {4E4F758C-7CB5-471C-BD61-FB70BF69D48B}.Debug|Win32.ActiveCfg = Debug|Win32
32 | {4E4F758C-7CB5-471C-BD61-FB70BF69D48B}.Debug|Win32.Build.0 = Debug|Win32
33 | {4E4F758C-7CB5-471C-BD61-FB70BF69D48B}.Release|Win32.ActiveCfg = Release|Win32
34 | {4E4F758C-7CB5-471C-BD61-FB70BF69D48B}.Release|Win32.Build.0 = Release|Win32
35 | {230D5525-AEA7-4037-95FE-3B45BEF98E55}.Debug|Win32.ActiveCfg = Debug|Win32
36 | {230D5525-AEA7-4037-95FE-3B45BEF98E55}.Debug|Win32.Build.0 = Debug|Win32
37 | {230D5525-AEA7-4037-95FE-3B45BEF98E55}.Release|Win32.ActiveCfg = Release|Win32
38 | {230D5525-AEA7-4037-95FE-3B45BEF98E55}.Release|Win32.Build.0 = Release|Win32
39 | {A0EFC09D-B539-40ED-B7A2-06177CBA669D}.Debug|Win32.ActiveCfg = Debug|Win32
40 | {A0EFC09D-B539-40ED-B7A2-06177CBA669D}.Debug|Win32.Build.0 = Debug|Win32
41 | {A0EFC09D-B539-40ED-B7A2-06177CBA669D}.Release|Win32.ActiveCfg = Release|Win32
42 | {A0EFC09D-B539-40ED-B7A2-06177CBA669D}.Release|Win32.Build.0 = Release|Win32
43 | EndGlobalSection
44 | GlobalSection(SolutionProperties) = preSolution
45 | HideSolutionNode = FALSE
46 | EndGlobalSection
47 | EndGlobal
48 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/UDPSocket.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: UDPSocket.h
27 |
28 | Contains: Adds additional Socket functionality specific to UDP.
29 |
30 |
31 |
32 |
33 | */
34 |
35 |
36 | #ifndef __UDPSOCKET_H__
37 | #define __UDPSOCKET_H__
38 |
39 | #ifndef __Win32__
40 | #include
41 | #include
42 | #endif
43 |
44 | #include "Socket.h"
45 | #include "UDPDemuxer.h"
46 |
47 |
48 | class UDPSocket : public Socket
49 | {
50 | public:
51 |
52 | //Another socket type flag (in addition to the ones defined in Socket.h).
53 | //The value of this can't conflict with those!
54 | enum
55 | {
56 | kWantsDemuxer = 0x0100 //UInt32
57 | };
58 |
59 | UDPSocket(Task* inTask, UInt32 inSocketType);
60 | virtual ~UDPSocket() { if (fDemuxer != NULL) delete fDemuxer; }
61 |
62 | //Open
63 | OS_Error Open() { return Socket::Open(SOCK_DGRAM); }
64 |
65 | OS_Error JoinMulticast(UInt32 inRemoteAddr);
66 | OS_Error LeaveMulticast(UInt32 inRemoteAddr);
67 | OS_Error SetTtl(UInt16 timeToLive);
68 | OS_Error SetMulticastInterface(UInt32 inLocalAddr);
69 |
70 | //returns an ERRNO
71 | OS_Error SendTo(UInt32 inRemoteAddr, UInt16 inRemotePort,
72 | void* inBuffer, UInt32 inLength);
73 |
74 | OS_Error RecvFrom(UInt32* outRemoteAddr, UInt16* outRemotePort,
75 | void* ioBuffer, UInt32 inBufLen, UInt32* outRecvLen);
76 |
77 | //A UDP socket may or may not have a demuxer associated with it. The demuxer
78 | //is a data structure so the socket can associate incoming data with the proper
79 | //task to process that data (based on source IP addr & port)
80 | UDPDemuxer* GetDemuxer() { return fDemuxer; }
81 |
82 | private:
83 |
84 | UDPDemuxer* fDemuxer;
85 | struct sockaddr_in fMsgAddr;
86 | };
87 | #endif // __UDPSOCKET_H__
88 |
89 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/QueryParamList.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QueryParamList.cpp
27 |
28 | Contains: Implementation of QueryParamList class
29 |
30 | The QueryParamList class is used to parse and build a searchable list
31 | of name/value pairs from a RFC1808 QueryString that has been encoded
32 | using the html 'form encoding' rules.
33 |
34 | */
35 |
36 | #ifndef __query_param_list__
37 | #define __query_param_list__
38 |
39 |
40 | //#include "QueryParamList.h"
41 |
42 | #include "PLDoubleLinkedList.h"
43 | #include "StrPtrLen.h"
44 |
45 |
46 | class QueryParamListElement {
47 |
48 | public:
49 | QueryParamListElement( char* name, char* value )
50 | {
51 | mName = name;
52 | mValue = value;
53 |
54 | }
55 |
56 | virtual ~QueryParamListElement()
57 | {
58 | delete [] mName;
59 | delete [] mValue;
60 | }
61 |
62 | char *mName;
63 | char *mValue;
64 |
65 | };
66 |
67 |
68 | class QueryParamList
69 | {
70 | public:
71 | QueryParamList( char* queryString );
72 | QueryParamList( StrPtrLen* querySPL );
73 | ~QueryParamList() { delete fNameValueQueryParamlist; }
74 |
75 | void AddNameValuePairToList( char* name, char* value );
76 | const char *DoFindCGIValueForParam( char *name );
77 | void PrintAll( char *idString );
78 |
79 | protected:
80 | void BulidList( StrPtrLen* querySPL );
81 | void DecodeArg( char *ioCodedPtr );
82 | enum {
83 | // escaping states
84 | kLastWasText
85 | , kPctEscape
86 | , kRcvHexDigitOne
87 | };
88 |
89 | Bool16 IsHex( char c );
90 |
91 | PLDoubleLinkedList *fNameValueQueryParamlist;
92 |
93 |
94 | };
95 |
96 |
97 |
98 |
99 |
100 | #endif
101 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/StringTranslator.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | Contains: Static utilities for translating strings from one encoding scheme to
27 | another. For example, routines for encoding and decoding URLs
28 |
29 |
30 |
31 | */
32 |
33 | #ifndef __STRINGTRANSLATOR_H__
34 | #define __STRINGTRANSLATOR_H__
35 |
36 | #include "OSHeaders.h"
37 |
38 | #define STRINGTRANSLATORTESTING 0
39 |
40 | class StringTranslator
41 | {
42 | public:
43 |
44 | //DecodeURL:
45 | //
46 | // This function does 2 things: Decodes % encoded characters in URLs, and strips out
47 | // any ".." or "." complete filenames from the URL. Writes the result into ioDest.
48 | //
49 | //If successful, returns the length of the destination string.
50 | //If failure, returns an OS errorcode: OS_BadURLFormat, OS_NotEnoughSpace
51 |
52 | static SInt32 DecodeURL(const char* inSrc, SInt32 inSrcLen, char* ioDest, SInt32 inDestLen);
53 |
54 | //EncodeURL:
55 | //
56 | // This function takes a character string and % encodes any special URL characters.
57 | // In general, the output buffer will be longer than the input buffer, so caller should
58 | // be aware of that.
59 | //
60 | //If successful, returns the length of the destination string.
61 | //If failure, returns an QTSS errorcode: OS_NotEnoughSpace
62 | //
63 | // If function returns E2BIG, ioDest will be valid, but will contain
64 | // only the portion of the URL that fit.
65 | static SInt32 EncodeURL(const char* inSrc, SInt32 inSrcLen, char* ioDest, SInt32 inDestLen);
66 |
67 | // DecodePath:
68 | //
69 | // This function converts "network" or "URL" path delimiters (the '/' char) to
70 | // the path delimiter of the local file system. It does this conversion in place,
71 | // so the old data will be overwritten
72 | static void DecodePath(char* inSrc, UInt32 inSrcLen);
73 |
74 | #if STRINGTRANSLATORTESTING
75 | static Bool16 Test();
76 | #endif
77 | };
78 | #endif // __STRINGTRANSLATOR_H__
79 |
80 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/daemon.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | * Copyright (c) 1990, 1993
27 | * The Regents of the University of California. All rights reserved.
28 | *
29 | * Redistribution and use in source and binary forms, with or without
30 | * modification, are permitted provided that the following conditions
31 | * are met:
32 | * 1. Redistributions of source code must retain the above copyright
33 | * notice, this list of conditions and the following disclaimer.
34 | * 2. Redistributions in binary form must reproduce the above copyright
35 | * notice, this list of conditions and the following disclaimer in the
36 | * documentation and/or other materials provided with the distribution.
37 | * 3. All advertising materials mentioning features or use of this software
38 | * must display the following acknowledgement:
39 | * This product includes software developed by the University of
40 | * California, Berkeley and its contributors.
41 | * 4. Neither the name of the University nor the names of its contributors
42 | * may be used to endorse or promote products derived from this software
43 | * without specific prior written permission.
44 | *
45 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 | * SUCH DAMAGE.
56 | */
57 |
58 | #ifndef _DAEMON_H_
59 | #define _DAEMON_H_
60 |
61 | #ifdef __cplusplus
62 | extern "C" {
63 | #endif
64 |
65 | int daemon(int nochdir, int noclose);
66 |
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 | #endif
73 |
74 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/UserAgentParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: UserAgentParser.h
27 |
28 | Contains: API interface for parsing the user agent field received from RTSP clients.
29 |
30 | Change History (most recent first):
31 |
32 |
33 |
34 |
35 | */
36 | #ifndef _USERAGENTPARSER_H_
37 | #define _USERAGENTPARSER_H_
38 |
39 | #include "StringParser.h"
40 | #include "StringFormatter.h"
41 | #include "StrPtrLen.h"
42 |
43 | class UserAgentParser
44 | {
45 | public:
46 | enum{ eMaxAttributeSize = 60 };
47 | struct UserAgentFields
48 | {
49 | char fFieldName[eMaxAttributeSize + 1];
50 | UInt32 fLen;
51 | UInt32 fID;
52 | };
53 |
54 | struct UserAgentData
55 | {
56 | StrPtrLen fData;
57 | bool fFound;
58 | };
59 |
60 | enum
61 | { eQtid = 0,
62 | eQtver = 1,
63 | eLang = 2,
64 | eOs = 3,
65 | eOsver = 4,
66 | eCpu = 5,
67 | eNumAttributes = 6
68 | };
69 |
70 | static UserAgentFields sFieldIDs[];
71 | static UInt8 sEOLWhitespaceEqualMask[];
72 | static UInt8 sEOLSemicolonCloseParenMask[];
73 | static UInt8 sWhitespaceMask[];
74 |
75 | UserAgentData fFieldData[eNumAttributes];
76 |
77 | void Parse(StrPtrLen *inStream);
78 |
79 | StrPtrLen* GetUserID() { return &(fFieldData[eQtid].fData); };
80 | StrPtrLen* GetUserVersion() { return &(fFieldData[eQtver].fData); };
81 | StrPtrLen* GetUserLanguage() { return &(fFieldData[eLang].fData); };
82 | StrPtrLen* GetrUserOS() { return &(fFieldData[eOs].fData); };
83 | StrPtrLen* GetUserOSVersion() { return &(fFieldData[eOsver].fData); };
84 | StrPtrLen* GetUserCPU() { return &(fFieldData[eCpu].fData); };
85 |
86 | UserAgentParser (StrPtrLen *inStream) { if (inStream != NULL) Parse(inStream); }
87 |
88 |
89 | };
90 |
91 |
92 | #endif // _USERAGENTPARSER_H_
93 |
--------------------------------------------------------------------------------
/Server.tproj/QTSSDataConverter.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QTSSDataConverter.h
27 |
28 | Contains: Utility routines for converting to and from
29 | QTSS_AttrDataTypes and text
30 |
31 | Written By: Denis Serenyi
32 |
33 | Change History (most recent first):
34 |
35 | */
36 |
37 | #include "QTSS.h"
38 |
39 | class QTSSDataConverter
40 | {
41 | public:
42 |
43 | //
44 | // This function converts a type string, eg, "UInt32" to the enum, qtssAttrDataTypeUInt32
45 | static QTSS_AttrDataType TypeStringToType( char* inTypeString);
46 |
47 | //
48 | // This function does the opposite conversion
49 | static char* TypeToTypeString( QTSS_AttrDataType inType);
50 |
51 | //
52 | // This function converts a text-formatted value of a certain type
53 | // to its type. Returns: QTSS_NotEnoughSpace if the buffer provided
54 | // is not big enough.
55 |
56 | // String must be NULL-terminated.
57 | // If output value is a string, it will not be NULL-terminated
58 | static QTSS_Error StringToValue( char* inValueAsString,
59 | QTSS_AttrDataType inType,
60 | void* ioBuffer,
61 | UInt32* ioBufSize);
62 |
63 | // If value is a string, doesn't have to be NULL-terminated.
64 | // Output string will be NULL terminated.
65 | static char* ValueToString( void* inValue,
66 | const UInt32 inValueLen,
67 | const QTSS_AttrDataType inType);
68 |
69 |
70 | // Takes a pointer to buffer and converts to hex in high to low order
71 | static char* ConvertBytesToCHexString( void* inValue, const UInt32 inValueLen);
72 |
73 | // Takes a string of hex values and converts to bytes in high to low order
74 | static QTSS_Error ConvertCHexStringToBytes( char* inValueAsString,
75 | void* ioBuffer,
76 | UInt32* ioBufSize);
77 | };
78 |
79 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/atomic.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | *
27 | * History:
28 | * 11-Feb-1999 Umesh Vaishampayan (umeshv@apple.com)
29 | * Added atomic_or().
30 | *
31 | * 26-Oct-1998 Umesh Vaishampayan (umeshv@apple.com)
32 | * Made the header c++ friendly.
33 | *
34 | * 12-Oct-1998 Umesh Vaishampayan (umeshv@apple.com)
35 | * Changed simple_ to spin_ so as to coexist with cthreads till
36 | * the merge to the system framework.
37 | *
38 | * 8-Oct-1998 Umesh Vaishampayan (umeshv@apple.com)
39 | * Created from the kernel code to be in a dynamic shared library.
40 | * Kernel code created by: Bill Angell (angell@apple.com)
41 | */
42 |
43 | #ifndef _ATOMIC_H_
44 | #define _ATOMIC_H_
45 |
46 | #ifdef __cplusplus
47 | extern "C" {
48 | #endif
49 |
50 | /* Locking routines */
51 |
52 | struct spin_lock { /* sizeof cache line */
53 | unsigned int lock_data;
54 | unsigned int pad[7];
55 | };
56 |
57 | typedef struct spin_lock *spin_lock_t;
58 |
59 | extern void spin_lock_init(spin_lock_t);
60 |
61 | extern void spin_lock_unlock(spin_lock_t);
62 |
63 | extern unsigned int spin_lock_lock(spin_lock_t);
64 |
65 | extern unsigned int spin_lock_bit(spin_lock_t, unsigned int bits);
66 |
67 | extern unsigned int spin_unlock_bit(spin_lock_t, unsigned int bits);
68 |
69 | extern unsigned int spin_lock_try(spin_lock_t);
70 |
71 | extern unsigned int spin_lock_held(spin_lock_t);
72 |
73 | /* Other atomic routines */
74 |
75 | extern unsigned int compare_and_store(unsigned int oval,
76 | unsigned int nval, unsigned int *area);
77 |
78 | extern unsigned int atomic_add(unsigned int *area, int val);
79 |
80 | extern unsigned int atomic_or(unsigned int *area, unsigned int mask);
81 |
82 | extern unsigned int atomic_sub(unsigned int *area, int val);
83 |
84 | extern void queue_atomic(unsigned int *anchor,
85 | unsigned int *elem, unsigned int disp);
86 |
87 | extern void queue_atomic_list(unsigned int *anchor,
88 | unsigned int *first, unsigned int *last,
89 | unsigned int disp);
90 |
91 | extern unsigned int *dequeue_atomic(unsigned int *anchor, unsigned int disp);
92 |
93 | #ifdef __cplusplus
94 | }
95 | #endif
96 |
97 | #endif /* _ATOMIC_H_ */
98 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/TCPListenerSocket.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: TCPListenerSocket.h
27 |
28 | Contains: A TCP listener socket. When a new connection comes in, the listener
29 | attempts to assign the new connection to a socket object and a Task
30 | object. Derived classes must implement a method of getting new
31 | Task & socket objects
32 |
33 |
34 | */
35 |
36 |
37 | #ifndef __TCPLISTENERSOCKET_H__
38 | #define __TCPLISTENERSOCKET_H__
39 |
40 | #include "TCPSocket.h"
41 | #include "IdleTask.h"
42 |
43 | class TCPListenerSocket : public TCPSocket, public IdleTask
44 | {
45 | public:
46 |
47 | TCPListenerSocket() : TCPSocket(NULL, Socket::kNonBlockingSocketType), IdleTask(),
48 | fAddr(0), fPort(0), fOutOfDescriptors(false), fSleepBetweenAccepts(false) {this->SetTaskName("TCPListenerSocket");}
49 | virtual ~TCPListenerSocket() {}
50 |
51 | //
52 | // Send a TCPListenerObject a Kill event to delete it.
53 |
54 | //addr = listening address. port = listening port. Automatically
55 | //starts listening
56 | OS_Error Initialize(UInt32 addr, UInt16 port);
57 |
58 | //You can query the listener to see if it is failing to accept
59 | //connections because the OS is out of descriptors.
60 | Bool16 IsOutOfDescriptors() { return fOutOfDescriptors; }
61 |
62 | void SlowDown() { fSleepBetweenAccepts = true; }
63 | void RunNormal() { fSleepBetweenAccepts = false; }
64 | //derived object must implement a way of getting tasks & sockets to this object
65 | virtual Task* GetSessionTask(TCPSocket** outSocket) = 0;
66 |
67 | virtual SInt64 Run();
68 |
69 | private:
70 |
71 | enum
72 | {
73 | kTimeBetweenAcceptsInMsec = 1000, //UInt32
74 | kListenQueueLength = 128 //UInt32
75 | };
76 |
77 | virtual void ProcessEvent(int eventBits);
78 | OS_Error Listen(UInt32 queueLength);
79 |
80 | UInt32 fAddr;
81 | UInt16 fPort;
82 |
83 | Bool16 fOutOfDescriptors;
84 | Bool16 fSleepBetweenAccepts;
85 | };
86 | #endif // __TCPLISTENERSOCKET_H__
87 |
88 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/GetWord.c:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #include "GetWord.h"
27 |
28 | char* GetWord( char* toWordPtr, char* fromStrPtr, SInt32 limit )
29 | {
30 | // get a word from a string
31 | // copy result into toWordPtr, return one past end of the
32 | // word, limit is max for toWordPtr
33 | // fromStrPtr
34 |
35 | // trim any leading white space
36 | while ( (unsigned char)*fromStrPtr <= 0x20 && *fromStrPtr )
37 | fromStrPtr++;
38 |
39 | // copy until we find more white space
40 | while ( limit && (unsigned char)*fromStrPtr > 0x20 && *fromStrPtr )
41 | {
42 | *toWordPtr++ = *fromStrPtr++;
43 | limit--;
44 | }
45 |
46 | *toWordPtr = 0x00;
47 |
48 | return (char *) fromStrPtr;
49 | }
50 |
51 | char * GetQuotedWord( char* toWordPtr, char* fromStrPtr, SInt32 limit )
52 | {
53 | // get a quote encoded word from a string
54 | // make include white space
55 | int lastWasQuote = 0;
56 |
57 | // trim any leading white space
58 | while ( ( (unsigned char)*fromStrPtr <= 0x20 ) && *fromStrPtr )
59 | fromStrPtr++;
60 |
61 |
62 | if ( (unsigned char)*fromStrPtr == '"' )
63 | { // must lead with quote sign after white space
64 | fromStrPtr++;
65 |
66 |
67 |
68 | // copy until we find the last single quote
69 | while ( limit && *fromStrPtr )
70 | {
71 | if ( (unsigned char)*fromStrPtr == '"' )
72 | {
73 | if ( lastWasQuote )
74 | {
75 | *toWordPtr++ = '"';
76 | lastWasQuote = 0;
77 | limit--;
78 | }
79 | else
80 | lastWasQuote = 1;
81 | }
82 | else
83 | {
84 | if ( !lastWasQuote )
85 | { *toWordPtr++ = *fromStrPtr;
86 | limit--;
87 | }
88 | else // we're done, hit a quote by itself
89 | break;
90 |
91 | }
92 |
93 | // consume the char we read
94 | fromStrPtr++;
95 |
96 | }
97 | }
98 |
99 | *toWordPtr = 0x00;
100 |
101 | return (char *) fromStrPtr;
102 | }
103 |
--------------------------------------------------------------------------------
/Server.tproj/QTSSStream.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: QTSSStream.h
27 |
28 | Contains: Abstract base class containing the prototypes for generalized
29 | stream functions.
30 |
31 | Any server object that wants to act as a QTSS_StreamRef should
32 | derive off of this and implement one or more of the stream APIs.
33 |
34 | */
35 |
36 |
37 | #ifndef __QTSS_STREAM_H__
38 | #define __QTSS_STREAM_H__
39 |
40 | #include "QTSS.h"
41 | #include "Task.h"
42 |
43 | class QTSSStream
44 | {
45 | public:
46 |
47 | QTSSStream() : fTask(NULL) {}
48 | virtual ~QTSSStream() {}
49 |
50 | //
51 | // A stream can have a task associated with it. If this stream supports
52 | // async I/O, the task is needed to know what to wakeup when there is an event
53 | void SetTask(Task* inTask) { fTask = inTask; }
54 | Task* GetTask() { return fTask; }
55 |
56 | virtual QTSS_Error Read(void* /*ioBuffer*/, UInt32 /*inLen*/, UInt32* /*outLen*/)
57 | { return QTSS_Unimplemented; }
58 |
59 | virtual QTSS_Error Write(void* /*inBuffer*/, UInt32 /*inLen*/, UInt32* /*outLenWritten*/, UInt32 /*inFlags*/)
60 | { return QTSS_Unimplemented; }
61 |
62 | virtual QTSS_Error WriteV(iovec* /*inVec*/, UInt32 /*inNumVectors*/, UInt32 /*inTotalLength*/, UInt32* /*outLenWritten*/)
63 | { return QTSS_Unimplemented; }
64 |
65 | virtual QTSS_Error Flush() { return QTSS_Unimplemented; }
66 |
67 | virtual QTSS_Error Seek(UInt64 /*inNewPosition*/) { return QTSS_Unimplemented; }
68 |
69 | virtual QTSS_Error Advise(UInt64 /*inPosition*/, UInt32 /*inAdviseSize*/)
70 | { return QTSS_Unimplemented; }
71 |
72 | virtual QTSS_Error RequestEvent(QTSS_EventType /*inEventMask*/)
73 | { return QTSS_Unimplemented; }
74 |
75 | private:
76 |
77 | Task* fTask;
78 | };
79 |
80 | #endif //__QTSS_STREAM_H__
81 |
--------------------------------------------------------------------------------
/PrefsSourceLib/NetInfoPrefsSource.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: NetInfoPrefsSource.cpp
27 |
28 | Contains: Implements object defined in NetInfoPrefsSource.h.
29 |
30 | Written by: Denis Serenyi
31 |
32 | Change History (most recent first):
33 |
34 |
35 |
36 | */
37 |
38 | #include "nilib2.h"
39 |
40 | #include "NetInfoPrefsSource.h"
41 |
42 | static char* gQTSSPropertiesPath = "/services/QuickTimeStreamingServer";
43 |
44 | NetInfoPrefsSource::NetInfoPrefsSource()
45 | {}
46 |
47 | int NetInfoPrefsSource::GetValue(const char* inKey, char* ioValue)
48 | {
49 | return this->GetValueByIndex(inKey, 0, ioValue);
50 | }
51 |
52 | int NetInfoPrefsSource::GetValueByIndex(const char* inKey, UInt32 inIndex, char* ioValue)
53 | {
54 | ni_status status = NI_OK;
55 | ni_namelist nameList = {};
56 | void* localDomain = NULL;
57 | ni_id qtssDir = {};
58 |
59 | ioValue[0] = '\0';
60 |
61 | status = ni_open(NULL, ".", &localDomain);
62 | if (status != NI_OK)
63 | return false;
64 |
65 | if (status == NI_OK)
66 | status = ni_pathsearch(localDomain, &qtssDir, gQTSSPropertiesPath);
67 |
68 | if (status == NI_OK)
69 | status = ni_lookupprop(localDomain, &qtssDir, inKey, &nameList);
70 |
71 | if (status == NI_OK)
72 | {
73 | if (nameList.ni_namelist_len > inIndex)
74 | strcpy(ioValue, nameList.ni_namelist_val[inIndex]);
75 | else
76 | status = NI_BADID;
77 | ni_namelist_free(&nameList);
78 | }
79 |
80 | ni_free(localDomain);
81 |
82 | return (status == NI_OK);
83 | }
84 |
85 | void NetInfoPrefsSource::SetValue(char* inKey, char* inValue)
86 | {
87 | this->SetValueByIndex(inKey, inValue, NI_INDEX_NULL);
88 | }
89 |
90 | void NetInfoPrefsSource::SetValueByIndex(char* inKey, char* inValue, UInt32 inIndex)
91 | {
92 | void* localDomain = NULL;
93 | ni_status status = NI_OK;
94 | ni_namelist nameList = {};
95 |
96 | //ni_namelist_insert(&nameList, (char*)inValue, NI_INDEX_NULL);
97 | ni_namelist_insert(&nameList, inValue, inIndex);
98 |
99 | status = ni_open(NULL, ".", &localDomain);
100 |
101 | if (status == NI_OK)
102 | {
103 | //create the path if it doesn't already exist
104 | status = ni2_create(localDomain, gQTSSPropertiesPath);
105 |
106 | if (status == NI_OK)
107 | status = ni2_appendprop(localDomain, gQTSSPropertiesPath, inKey, nameList);
108 | }
109 | ni_namelist_free(&nameList);
110 | ni_free(localDomain);
111 | }
112 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/daemon.c:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | * Copyright (c) 1990, 1993
27 | * The Regents of the University of California. All rights reserved.
28 | *
29 | * Redistribution and use in source and binary forms, with or without
30 | * modification, are permitted provided that the following conditions
31 | * are met:
32 | * 1. Redistributions of source code must retain the above copyright
33 | * notice, this list of conditions and the following disclaimer.
34 | * 2. Redistributions in binary form must reproduce the above copyright
35 | * notice, this list of conditions and the following disclaimer in the
36 | * documentation and/or other materials provided with the distribution.
37 | * 3. All advertising materials mentioning features or use of this software
38 | * must display the following acknowledgement:
39 | * This product includes software developed by the University of
40 | * California, Berkeley and its contributors.
41 | * 4. Neither the name of the University nor the names of its contributors
42 | * may be used to endorse or promote products derived from this software
43 | * without specific prior written permission.
44 | *
45 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 | * SUCH DAMAGE.
56 | */
57 |
58 | #include
59 | #include
60 | #include "daemon.h"
61 |
62 | int daemon(int nochdir, int noclose)
63 | {
64 | int fd;
65 |
66 | switch (fork()) {
67 | case -1:
68 | return (-1);
69 | case 0:
70 | break;
71 | default:
72 | _exit(0);
73 | }
74 |
75 | if (setsid() == -1)
76 | return (-1);
77 |
78 | if (!nochdir)
79 | (void)chdir("/");
80 |
81 | if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) {
82 | (void)dup2(fd, STDIN_FILENO);
83 | (void)dup2(fd, STDOUT_FILENO);
84 | (void)dup2(fd, STDERR_FILENO);
85 | if (fd > 2)
86 | (void)close (fd);
87 | }
88 | return (0);
89 | }
90 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/OSCond.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: OSCond.cpp
27 |
28 | Contains: Implementation of OSCond class
29 |
30 |
31 |
32 | */
33 |
34 | #include "OSCond.h"
35 | #include "OSMutex.h"
36 | #include "OSThread.h"
37 | #include "MyAssert.h"
38 |
39 | #if __PTHREADS_MUTEXES__
40 | #include
41 | #endif
42 |
43 |
44 | OSCond::OSCond()
45 | {
46 | #ifdef __Win32__
47 | fCondition = ::CreateEvent(NULL, FALSE, FALSE, NULL);
48 | Assert(fCondition != NULL);
49 | #elif __PTHREADS_MUTEXES__
50 | #if __MacOSX__
51 | int ret = pthread_cond_init(&fCondition, NULL);
52 | Assert(ret == 0);
53 | #else
54 | pthread_condattr_t cond_attr;
55 | pthread_condattr_init(&cond_attr);
56 | int ret = pthread_cond_init(&fCondition, &cond_attr);
57 | Assert(ret == 0);
58 | #endif
59 | #else
60 | fCondition = mycondition_alloc();
61 | Assert(fCondition != NULL);
62 | #endif
63 | }
64 |
65 | OSCond::~OSCond()
66 | {
67 | #ifdef __Win32__
68 | BOOL theErr = ::CloseHandle(fCondition);
69 | Assert(theErr == TRUE);
70 | #elif __PTHREADS_MUTEXES__
71 | pthread_cond_destroy(&fCondition);
72 | #else
73 | Assert(fCondition != NULL);
74 | mycondition_free(fCondition);
75 | #endif
76 | }
77 |
78 | #if __PTHREADS_MUTEXES__
79 | void OSCond::TimedWait(OSMutex* inMutex, SInt32 inTimeoutInMilSecs)
80 | {
81 | struct timespec ts;
82 | struct timeval tv;
83 | struct timezone tz;
84 | int sec, usec;
85 |
86 | //These platforms do refcounting manually, and wait will release the mutex,
87 | // so we need to update the counts here
88 |
89 | inMutex->fHolderCount--;
90 | inMutex->fHolder = 0;
91 |
92 |
93 | if (inTimeoutInMilSecs == 0)
94 | (void)pthread_cond_wait(&fCondition, &inMutex->fMutex);
95 | else
96 | {
97 | gettimeofday(&tv, &tz);
98 | sec = inTimeoutInMilSecs / 1000;
99 | inTimeoutInMilSecs = inTimeoutInMilSecs - (sec * 1000);
100 | Assert(inTimeoutInMilSecs < 1000);
101 | usec = inTimeoutInMilSecs * 1000;
102 | Assert(tv.tv_usec < 1000000);
103 | ts.tv_sec = tv.tv_sec + sec;
104 | ts.tv_nsec = (tv.tv_usec + usec) * 1000;
105 | Assert(ts.tv_nsec < 2000000000);
106 | if(ts.tv_nsec > 999999999)
107 | {
108 | ts.tv_sec++;
109 | ts.tv_nsec -= 1000000000;
110 | }
111 | (void)pthread_cond_timedwait(&fCondition, &inMutex->fMutex, &ts);
112 | }
113 |
114 |
115 | inMutex->fHolderCount++;
116 | inMutex->fHolder = pthread_self();
117 |
118 | }
119 | #endif
120 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/DssStopwatch.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | #ifndef __DSS_STOPWATCH__
26 | #define __DSS_STOPWATCH__
27 | //#include "DssStopwatch.h"
28 |
29 | #include "OS.h"
30 |
31 |
32 | class DssEggtimer {
33 | public:
34 | enum { kDurationNeverExpire = -1 };
35 |
36 | DssEggtimer( SInt64 inMilliseconds ) { fTimerDuration = inMilliseconds; Reset(); }
37 |
38 | void OneShotSetTo( SInt64 inMilliseconds )
39 | {
40 | // set the egg timer to this time for one cycle.
41 | // there after Reset will use fTimerDuration
42 | fExpirationMilliseconds = OS::Milliseconds() + inMilliseconds;
43 | }
44 | void Reset()
45 | {
46 | //if ( fTimerDuration != (SInt64)kDurationNeverExpire )
47 | fExpirationMilliseconds = OS::Milliseconds() + fTimerDuration;
48 | }
49 |
50 | void ResetTo(SInt64 inMilliseconds)
51 | {
52 | fTimerDuration = inMilliseconds;
53 | this->Reset();
54 | }
55 |
56 | Bool16 Expired()
57 | {
58 | //if (fTimerDuration == (SInt64)kDurationNeverExpire )
59 | // return false;
60 |
61 | return fExpirationMilliseconds <= OS::Milliseconds();
62 | }
63 | SInt64 MaxDuration() { return fTimerDuration; }
64 |
65 | private:
66 | SInt64 fTimerDuration;
67 | SInt64 fExpirationMilliseconds;
68 |
69 | };
70 |
71 | class DssMillisecondStopwatch {
72 |
73 | public:
74 | DssMillisecondStopwatch() :
75 | fIsStarted(false)
76 | , fTimerDuration(-1)
77 | {}
78 | ;
79 | void Start() { fStartedAt = OS::Milliseconds(); fIsStarted = true; }
80 | void Stop() { fTimerDuration = OS::Milliseconds() - fStartedAt; }
81 |
82 | SInt64 Duration() { return fTimerDuration; }
83 |
84 | private:
85 | Bool16 fIsStarted;
86 | SInt64 fTimerDuration;
87 | SInt64 fStartedAt;
88 | };
89 |
90 | class DssDurationTimer {
91 |
92 | public:
93 | DssDurationTimer() { fStartedAtMsec = OS::Milliseconds(); }
94 | void Reset() { fStartedAtMsec = OS::Milliseconds(); }
95 | void ResetToDuration( SInt64 inDurationInMsec ) { fStartedAtMsec = OS::Milliseconds() - inDurationInMsec; }
96 | SInt64 DurationInMilliseconds() { return OS::Milliseconds() - fStartedAtMsec; }
97 | SInt64 DurationInSeconds() { return (OS::Milliseconds() - fStartedAtMsec) / (SInt64)1000; }
98 |
99 |
100 | private:
101 | SInt64 fStartedAtMsec;
102 | };
103 |
104 |
105 | #endif
106 |
107 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/SafeStdLib.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: SafeStdLib.h
27 |
28 | Contains: Thread safe std lib calls
29 |
30 |
31 | */
32 |
33 | #ifndef _INTERNAL_STDLIB_H_
34 | #define _INTERNAL_STDLIB_H_
35 |
36 | #include
37 | #include "OSHeaders.h"
38 |
39 | #define kTimeStrSize 32
40 | #define kErrorStrSize 256
41 | extern int qtss_maxprintf(const char *fmt, ...);
42 | extern void qtss_setmaxprintfcharsinK(UInt32 newMaxCharsInK);
43 | extern UInt32 qtss_getmaxprintfcharsinK();
44 |
45 | #ifndef USE_DEFAULT_STD_LIB
46 |
47 |
48 | #include
49 | #include
50 |
51 |
52 | #ifdef __cplusplus
53 | extern "C" {
54 | #endif
55 |
56 |
57 |
58 | #ifdef __USE_MAX_PRINTF__
59 | #define qtss_printf qtss_maxprintf
60 | #else
61 | extern int qtss_printf(const char *fmt, ...);
62 |
63 | #endif
64 |
65 | extern int qtss_sprintf(char *buffer, const char *fmt,...);
66 | extern int qtss_fprintf(FILE *file, const char *fmt, ...);
67 | extern int qtss_snprintf(char *str, size_t size, const char *format, ...);
68 | extern size_t qtss_strftime(char *buf, size_t maxsize, const char *format, const struct tm *timeptr);
69 |
70 | // These calls return the pointer passed into the call as the result.
71 |
72 | extern char *qtss_strerror(int errnum, char* buffer, int buffLen);
73 | extern char *qtss_ctime(const time_t *timep, char* buffer, int buffLen);
74 | extern char *qtss_asctime(const struct tm *timeptr, char* buffer, int buffLen);
75 | extern struct tm *qtss_gmtime (const time_t *, struct tm *result);
76 | extern struct tm *qtss_localtime (const time_t *, struct tm *result);
77 |
78 | #ifdef __cplusplus
79 | }
80 | #endif
81 |
82 |
83 | #else //USE_DEFAULT_STD_LIB
84 |
85 | #define qtss_sprintf sprintf
86 |
87 | #define qtss_fprintf fprintf
88 |
89 | #ifdef __USE_MAX_PRINTF__
90 | #define qtss_printf qtss_maxprintf
91 | #else
92 | #define qtss_printf printf
93 | #endif
94 |
95 | #if __Win32__
96 | #define qtss_snprintf _snprintf
97 | #else
98 |
99 | #define qtss_snprintf snprintf
100 |
101 | #endif
102 |
103 |
104 |
105 | #define qtss_strftime strftime
106 |
107 | // Use our calls for the following.
108 | // These calls return the pointer passed into the call as the result.
109 |
110 | extern char *qtss_strerror(int errnum, char* buffer, int buffLen);
111 | extern char *qtss_ctime(const time_t *timep, char* buffer, int buffLen);
112 | extern char *qtss_asctime(const struct tm *timeptr, char* buffer, int buffLen);
113 | extern struct tm *qtss_gmtime (const time_t *, struct tm *result);
114 | extern struct tm *qtss_localtime (const time_t *, struct tm *result);
115 |
116 | #endif //USE_DEFAULT_STD_LIB
117 | #endif //_INTERNAL_STDLIB_H_
118 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/IdleTask.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: IdleTask.h
27 |
28 | Contains: IdleTasks are identical to normal tasks (see task.h) with one exception:
29 |
30 | You can schedule them for timeouts. If you call SetIdleTimer
31 | on one, after the time has elapsed the task object will receive an
32 | OS_IDLE event.
33 |
34 |
35 |
36 | */
37 |
38 |
39 | #ifndef _IDLETASK_H_
40 | #define _IDLETASK_H_
41 |
42 | #include "Task.h"
43 |
44 | #include "OSThread.h"
45 | #include "OSHeap.h"
46 | #include "OSMutex.h"
47 | #include "OSCond.h"
48 |
49 | class IdleTask;
50 |
51 | //merely a private implementation detail of IdleTask
52 | class IdleTaskThread : private OSThread
53 | {
54 | private:
55 |
56 | IdleTaskThread() : OSThread(), fHeapMutex() {}
57 | virtual ~IdleTaskThread() { Assert(fIdleHeap.CurrentHeapSize() == 0); }
58 |
59 | void SetIdleTimer(IdleTask *idleObj, SInt64 msec);
60 | void CancelTimeout(IdleTask *idleObj);
61 |
62 | virtual void Entry();
63 | OSHeap fIdleHeap;
64 | OSMutex fHeapMutex;
65 | OSCond fHeapCond;
66 | friend class IdleTask;
67 | };
68 |
69 |
70 | class IdleTask : public Task
71 | {
72 |
73 | public:
74 |
75 | //Call Initialize before using this class
76 | static void Initialize();
77 |
78 | IdleTask() : Task(), fIdleElem() { this->SetTaskName("IdleTask"); fIdleElem.SetEnclosingObject(this); }
79 |
80 | //This object does a "best effort" of making sure a timeout isn't
81 | //pending for an object being deleted. In other words, if there is
82 | //a timeout pending, and the destructor is called, things will get cleaned
83 | //up. But callers must ensure that SetIdleTimer isn't called at the same
84 | //time as the destructor, or all hell will break loose.
85 | virtual ~IdleTask();
86 |
87 | //SetIdleTimer:
88 | //This object will receive an OS_IDLE event in the following number of milliseconds.
89 | //Only one timeout can be outstanding, if there is already a timeout scheduled, this
90 | //does nothing.
91 | void SetIdleTimer(SInt64 msec) { sIdleThread->SetIdleTimer(this, msec); }
92 |
93 | //CancelTimeout
94 | //If there is a pending timeout for this object, this function cancels it.
95 | //If there is no pending timeout, this function does nothing.
96 | //Currently not supported because OSHeap doesn't support random remove
97 | void CancelTimeout() { sIdleThread->CancelTimeout(this); }
98 |
99 | private:
100 |
101 | OSHeapElem fIdleElem;
102 |
103 | //there is only one idle thread shared by all idle tasks.
104 | static IdleTaskThread* sIdleThread;
105 |
106 | friend class IdleTaskThread;
107 | };
108 | #endif
109 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/OSHeap.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: OSHeap.h
27 |
28 | Contains: Implements a heap
29 |
30 |
31 | */
32 |
33 | #ifndef _OSHEAP_H_
34 | #define _OSHEAP_H_
35 |
36 | #define _OSHEAP_TESTING_ 0
37 |
38 | #include "OSCond.h"
39 |
40 | class OSHeapElem;
41 |
42 | class OSHeap
43 | {
44 | public:
45 |
46 | enum
47 | {
48 | kDefaultStartSize = 1024 //UInt32
49 | };
50 |
51 | OSHeap(UInt32 inStartSize = kDefaultStartSize);
52 | ~OSHeap() { if (fHeap != NULL) delete fHeap; }
53 |
54 | //ACCESSORS
55 | UInt32 CurrentHeapSize() { return fFreeIndex - 1; }
56 | OSHeapElem* PeekMin() { if (CurrentHeapSize() > 0) return fHeap[1]; return NULL; }
57 |
58 | //MODIFIERS
59 |
60 | //These are the two primary operations supported by the heap
61 | //abstract data type. both run in log(n) time.
62 | void Insert(OSHeapElem* inElem);
63 | OSHeapElem* ExtractMin() { return Extract(1); }
64 | //removes specified element from the heap
65 | OSHeapElem* Remove(OSHeapElem* elem);
66 |
67 | #if _OSHEAP_TESTING_
68 | //returns true if it passed the test, false otherwise
69 | static Bool16 Test();
70 | #endif
71 |
72 | private:
73 |
74 | OSHeapElem* Extract(UInt32 index);
75 |
76 | #if _OSHEAP_TESTING_
77 | //verifies that the heap is in fact a heap
78 | void SanityCheck(UInt32 root);
79 | #endif
80 |
81 | OSHeapElem** fHeap;
82 | UInt32 fFreeIndex;
83 | UInt32 fArraySize;
84 | };
85 |
86 | class OSHeapElem
87 | {
88 | public:
89 | OSHeapElem(void* enclosingObject = NULL)
90 | : fValue(0), fEnclosingObject(enclosingObject), fCurrentHeap(NULL) {}
91 | ~OSHeapElem() {}
92 |
93 | //This data structure emphasizes performance over extensibility
94 | //If it were properly object-oriented, the compare routine would
95 | //be virtual. However, to avoid the use of v-functions in this data
96 | //structure, I am assuming that the objects are compared using a 64 bit number.
97 | //
98 | void SetValue(SInt64 newValue) { fValue = newValue; }
99 | SInt64 GetValue() { return fValue; }
100 | void* GetEnclosingObject() { return fEnclosingObject; }
101 | void SetEnclosingObject(void* obj) { fEnclosingObject = obj; }
102 | Bool16 IsMemberOfAnyHeap() { return fCurrentHeap != NULL; }
103 |
104 | private:
105 |
106 | SInt64 fValue;
107 | void* fEnclosingObject;
108 | OSHeap* fCurrentHeap;
109 |
110 | friend class OSHeap;
111 | };
112 | #endif //_OSHEAP_H_
113 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/OSCond.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: OSCond.h
27 |
28 | Contains: A simple condition variable abstraction
29 |
30 |
31 |
32 |
33 | */
34 |
35 | #ifndef _OSCOND_H_
36 | #define _OSCOND_H_
37 |
38 | #ifndef __Win32__
39 | #if __PTHREADS_MUTEXES__
40 | #include
41 | #else
42 | #include "mycondition.h"
43 | #endif
44 | #endif
45 |
46 | #include "OSMutex.h"
47 | #include "MyAssert.h"
48 |
49 | class OSCond
50 | {
51 | public:
52 |
53 | OSCond();
54 | ~OSCond();
55 |
56 | inline void Signal();
57 | inline void Wait(OSMutex* inMutex, SInt32 inTimeoutInMilSecs = 0);
58 | inline void Broadcast();
59 |
60 | private:
61 |
62 | #ifdef __Win32__
63 | HANDLE fCondition;
64 | UInt32 fWaitCount;
65 | #elif __PTHREADS_MUTEXES__
66 | pthread_cond_t fCondition;
67 | void TimedWait(OSMutex* inMutex, SInt32 inTimeoutInMilSecs);
68 | #else
69 | mycondition_t fCondition;
70 | #endif
71 | };
72 |
73 | inline void OSCond::Wait(OSMutex* inMutex, SInt32 inTimeoutInMilSecs)
74 | {
75 | #ifdef __Win32__
76 | DWORD theTimeout = INFINITE;
77 | if (inTimeoutInMilSecs > 0)
78 | theTimeout = inTimeoutInMilSecs;
79 | inMutex->Unlock();
80 | fWaitCount++;
81 | DWORD theErr = ::WaitForSingleObject(fCondition, theTimeout);
82 | fWaitCount--;
83 | Assert((theErr == WAIT_OBJECT_0) || (theErr == WAIT_TIMEOUT));
84 | inMutex->Lock();
85 | #elif __PTHREADS_MUTEXES__
86 | this->TimedWait(inMutex, inTimeoutInMilSecs);
87 | #else
88 | Assert(fCondition != NULL);
89 | mycondition_wait(fCondition, inMutex->fMutex, inTimeoutInMilSecs);
90 | #endif
91 | }
92 |
93 | inline void OSCond::Signal()
94 | {
95 | #ifdef __Win32__
96 | BOOL theErr = ::SetEvent(fCondition);
97 | Assert(theErr == TRUE);
98 | #elif __PTHREADS_MUTEXES__
99 | pthread_cond_signal(&fCondition);
100 | #else
101 | Assert(fCondition != NULL);
102 | mycondition_signal(fCondition);
103 | #endif
104 | }
105 |
106 | inline void OSCond::Broadcast()
107 | {
108 | #ifdef __Win32__
109 | //
110 | // There doesn't seem like any more elegant way to
111 | // implement Broadcast using events in Win32.
112 | // This will work, it may generate spurious wakeups,
113 | // but condition variables are allowed to generate
114 | // spurious wakeups
115 | UInt32 waitCount = fWaitCount;
116 | for (UInt32 x = 0; x < waitCount; x++)
117 | {
118 | BOOL theErr = ::SetEvent(fCondition);
119 | Assert(theErr == TRUE);
120 | }
121 | #elif __PTHREADS_MUTEXES__
122 | pthread_cond_broadcast(&fCondition);
123 | #else
124 | Assert(fCondition != NULL);
125 | mycondition_broadcast(fCondition);
126 | #endif
127 | }
128 |
129 | #endif //_OSCOND_H_
130 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/TCPSocket.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: TCPSocket.h
27 |
28 | Contains: TCP socket object
29 |
30 |
31 |
32 |
33 | */
34 |
35 | #ifndef __TCPSOCKET_H__
36 | #define __TCPSOCKET_H__
37 |
38 | #include
39 | #include
40 | #include "SafeStdLib.h"
41 | #ifndef __Win32__
42 | #include
43 | #include
44 | #endif
45 |
46 | #include "Socket.h"
47 | #include "Task.h"
48 | #include "StrPtrLen.h"
49 |
50 | class TCPSocket : public Socket
51 | {
52 | public:
53 |
54 | //TCPSocket takes an optional task object which will get notified when
55 | //certain events happen on this socket. Those events are:
56 | //
57 | //S_DATA: Data is currently available on the socket.
58 | //S_CONNECTIONCLOSING: Client is closing the connection. No longer necessary
59 | // to call Close or Disconnect, Snd & Rcv will fail.
60 | TCPSocket(Task *notifytask, UInt32 inSocketType)
61 | : Socket(notifytask, inSocketType),
62 | fRemoteStr(fRemoteBuffer, kIPAddrBufSize) {}
63 | virtual ~TCPSocket() {}
64 |
65 | //Open
66 | OS_Error Open() { return Socket::Open(SOCK_STREAM); }
67 |
68 | // Connect. Attempts to connect to the specified remote host. If this
69 | // is a non-blocking socket, this function may return EINPROGRESS, in which
70 | // case caller must wait for either an EV_RE or an EV_WR. You may call
71 | // CheckAsyncConnect at any time, which will return OS_NoErr if the connect
72 | // has completed, EINPROGRESS if it is still in progress, or an appropriate error
73 | // if the connect failed.
74 | OS_Error Connect(UInt32 inRemoteAddr, UInt16 inRemotePort);
75 | //OS_Error CheckAsyncConnect();
76 |
77 | // Basically a copy constructor for this object, also NULLs out the data
78 | // in tcpSocket.
79 | void SnarfSocket( TCPSocket & tcpSocket );
80 |
81 | //ACCESSORS:
82 | //Returns NULL if not currently available.
83 |
84 | UInt32 GetRemoteAddr() { return ntohl(fRemoteAddr.sin_addr.s_addr); }
85 | UInt16 GetRemotePort() { return ntohs(fRemoteAddr.sin_port); }
86 | //This function is NOT thread safe!
87 | StrPtrLen* GetRemoteAddrStr();
88 |
89 | protected:
90 |
91 | void Set(int inSocket, struct sockaddr_in* remoteaddr);
92 |
93 | enum
94 | {
95 | kIPAddrBufSize = 20 //UInt32
96 | };
97 |
98 | struct sockaddr_in fRemoteAddr;
99 | char fRemoteBuffer[kIPAddrBufSize];
100 | StrPtrLen fRemoteStr;
101 |
102 |
103 | friend class TCPListenerSocket;
104 | };
105 | #endif // __TCPSOCKET_H__
106 |
107 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/DateTranslator.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: DateTranslator.h
27 |
28 | Contains: Efficient routines & data structures for converting from
29 | RFC 1123 compliant date strings to local file system dates & vice versa.
30 |
31 |
32 |
33 | */
34 |
35 | #ifndef _DATE_TRANSLATOR_H_
36 | #define _DATE_TRANSLATOR_H_
37 |
38 | #include
39 | #include
40 | #include "StrPtrLen.h"
41 |
42 | class DateBuffer;
43 |
44 | class DateTranslator
45 | {
46 | public:
47 |
48 | // this updates the DateBuffer to be the current date / time.
49 | // If you wish to set the DateBuffer to a particular date, pass in that date.
50 | // Dates should be in the OS.h compliant format
51 | static void UpdateDateBuffer(DateBuffer* inDateBuffer, const SInt64& inDate, time_t gmtoffset = 0);
52 |
53 | //Given an HTTP/1.1 compliant date string (in one of the three 1.1 formats)
54 | //this returns an OS.h compliant date/time value.
55 | static SInt64 ParseDate(StrPtrLen* inDateString);
56 |
57 | private:
58 |
59 | static UInt32 ConvertCharToMonthTableIndex(int inChar)
60 | {
61 | return (UInt32)(toupper(inChar) - 'A'); // Convert to a value between 0 - 25
62 | }
63 | };
64 |
65 | class DateBuffer
66 | {
67 | public:
68 |
69 | // This class provides no protection against being accessed from multiple threads
70 | // simultaneously. Update & InexactUpdate rewrite the date buffer, so care should
71 | // be taken to protect against simultaneous access.
72 |
73 | DateBuffer() : fLastDateUpdate(0) { fDateBuffer[0] = 0; }
74 | ~DateBuffer() {}
75 |
76 | //SEE RFC 1123 for details on the date string format
77 | //ex: Mon, 04 Nov 1996 21:42:17 GMT
78 |
79 | //RFC 1123 date strings are always of this length
80 | enum
81 | {
82 | kDateBufferLen = 29
83 | };
84 |
85 | // Updates this date buffer to reflect the current time.
86 | // If a date is provided, this updates the DateBuffer to be that date.
87 | void Update(const SInt64& inDate) { DateTranslator::UpdateDateBuffer(this, inDate); }
88 |
89 | // Updates this date buffer to reflect the current time, with a certain degree
90 | // of inexactitude (the range of error is defined by the kUpdateInterval value)
91 | void InexactUpdate();
92 |
93 | //returns a NULL terminated C-string always of kHTTPDateLen length.
94 | char *GetDateBuffer() { return fDateBuffer; }
95 |
96 | private:
97 |
98 | enum
99 | {
100 | kUpdateInterval = 60000 // Update every minute
101 | };
102 |
103 | //+1 for terminator +1 for padding
104 | char fDateBuffer[kDateBufferLen + 2];
105 | SInt64 fLastDateUpdate;
106 |
107 | friend class DateTranslator;
108 | };
109 |
110 |
111 | #endif
112 |
113 |
114 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/TCPSocket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: TCPSocket.cpp
27 |
28 | Contains: implements TCPSocket class
29 |
30 |
31 |
32 | */
33 |
34 | #ifndef __Win32__
35 | #include
36 | #include
37 | #include
38 | #endif
39 |
40 | #include
41 |
42 | #include "TCPSocket.h"
43 | #include "SocketUtils.h"
44 | #include "OS.h"
45 |
46 | #ifdef USE_NETLOG
47 | #include
48 | #endif
49 |
50 | void TCPSocket::SnarfSocket( TCPSocket & fromSocket )
51 | {
52 | // take the connection away from the other socket
53 | // and use it as our own.
54 | Assert(fFileDesc == EventContext::kInvalidFileDesc);
55 | this->Set( fromSocket.fFileDesc, &fromSocket.fRemoteAddr );
56 |
57 | // clear the old socket so he doesn't close and the like
58 | struct sockaddr_in remoteaddr;
59 |
60 | ::memset( &remoteaddr, 0, sizeof( remoteaddr ) );
61 |
62 | fromSocket.Set( EventContext::kInvalidFileDesc, &remoteaddr );
63 |
64 | // get the event context too
65 | this->SnarfEventContext( fromSocket );
66 |
67 | }
68 |
69 | void TCPSocket::Set(int inSocket, struct sockaddr_in* remoteaddr)
70 | {
71 | fRemoteAddr = *remoteaddr;
72 | fFileDesc = inSocket;
73 |
74 | if ( inSocket != EventContext::kInvalidFileDesc )
75 | {
76 | //make sure to find out what IP address this connection is actually occuring on. That
77 | //way, we can report correct information to clients asking what the connection's IP is
78 | #if __Win32__ || __osf__ || __sgi__ || __hpux__
79 | int len = sizeof(fLocalAddr);
80 | #else
81 | socklen_t len = sizeof(fLocalAddr);
82 | #endif
83 | int err = ::getsockname(fFileDesc, (struct sockaddr*)&fLocalAddr, &len);
84 | AssertV(err == 0, OSThread::GetErrno());
85 | fState |= kBound;
86 | fState |= kConnected;
87 | }
88 | else
89 | fState = 0;
90 | }
91 |
92 | StrPtrLen* TCPSocket::GetRemoteAddrStr()
93 | {
94 | if (fRemoteStr.Len == kIPAddrBufSize)
95 | SocketUtils::ConvertAddrToString(fRemoteAddr.sin_addr, &fRemoteStr);
96 | return &fRemoteStr;
97 | }
98 |
99 | OS_Error TCPSocket::Connect(UInt32 inRemoteAddr, UInt16 inRemotePort)
100 | {
101 | ::memset(&fRemoteAddr, 0, sizeof(fRemoteAddr));
102 | fRemoteAddr.sin_family = AF_INET; /* host byte order */
103 | fRemoteAddr.sin_port = htons(inRemotePort); /* short, network byte order */
104 | fRemoteAddr.sin_addr.s_addr = htonl(inRemoteAddr);
105 |
106 | /* don't forget to error check the connect()! */
107 | int err = ::connect(fFileDesc, (sockaddr *)&fRemoteAddr, sizeof(fRemoteAddr));
108 | fState |= kConnected;
109 |
110 | if (err == -1)
111 | {
112 | fRemoteAddr.sin_port = 0;
113 | fRemoteAddr.sin_addr.s_addr = 0;
114 | return (OS_Error)OSThread::GetErrno();
115 | }
116 |
117 | return OS_NoErr;
118 |
119 | }
120 |
121 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # There exist several targets which are by default empty and which can be
3 | # used for execution of your targets. These targets are usually executed
4 | # before and after some main targets. They are:
5 | #
6 | # .build-pre: called before 'build' target
7 | # .build-post: called after 'build' target
8 | # .clean-pre: called before 'clean' target
9 | # .clean-post: called after 'clean' target
10 | # .clobber-pre: called before 'clobber' target
11 | # .clobber-post: called after 'clobber' target
12 | # .all-pre: called before 'all' target
13 | # .all-post: called after 'all' target
14 | # .help-pre: called before 'help' target
15 | # .help-post: called after 'help' target
16 | #
17 | # Targets beginning with '.' are not intended to be called on their own.
18 | #
19 | # Main targets can be executed directly, and they are:
20 | #
21 | # build build a specific configuration
22 | # clean remove built files from a configuration
23 | # clobber remove all built files
24 | # all build all configurations
25 | # help print help mesage
26 | #
27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28 | # .help-impl are implemented in nbproject/makefile-impl.mk.
29 | #
30 | # Available make variables:
31 | #
32 | # CND_BASEDIR base directory for relative paths
33 | # CND_DISTDIR default top distribution directory (build artifacts)
34 | # CND_BUILDDIR default top build directory (object files, ...)
35 | # CONF name of current configuration
36 | # CND_PLATFORM_${CONF} platform name (current configuration)
37 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
38 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
39 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
40 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
41 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration)
42 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration)
43 | #
44 | # NOCDDL
45 |
46 |
47 | # Environment
48 | MKDIR=mkdir
49 | CP=cp
50 | CCADMIN=CCadmin
51 |
52 |
53 | # build
54 | build: .build-post
55 |
56 | .build-pre:
57 | # Add your pre 'build' code here...
58 |
59 | .build-post: .build-impl
60 | # Add your post 'build' code here...
61 |
62 |
63 | # clean
64 | clean: .clean-post
65 |
66 | .clean-pre:
67 | # Add your pre 'clean' code here...
68 |
69 | .clean-post: .clean-impl
70 | # Add your post 'clean' code here...
71 |
72 |
73 | # clobber
74 | clobber: .clobber-post
75 |
76 | .clobber-pre:
77 | # Add your pre 'clobber' code here...
78 |
79 | .clobber-post: .clobber-impl
80 | # Add your post 'clobber' code here...
81 |
82 |
83 | # all
84 | all: .all-post
85 |
86 | .all-pre:
87 | # Add your pre 'all' code here...
88 |
89 | .all-post: .all-impl
90 | # Add your post 'all' code here...
91 |
92 |
93 | # build tests
94 | build-tests: .build-tests-post
95 |
96 | .build-tests-pre:
97 | # Add your pre 'build-tests' code here...
98 |
99 | .build-tests-post: .build-tests-impl
100 | # Add your post 'build-tests' code here...
101 |
102 |
103 | # run tests
104 | test: .test-post
105 |
106 | .test-pre: build-tests
107 | # Add your pre 'test' code here...
108 |
109 | .test-post: .test-impl
110 | # Add your post 'test' code here...
111 |
112 |
113 | # help
114 | help: .help-post
115 |
116 | .help-pre:
117 | # Add your pre 'help' code here...
118 |
119 | .help-post: .help-impl
120 | # Add your post 'help' code here...
121 |
122 |
123 |
124 | # include project implementation makefile
125 | include nbproject/Makefile-impl.mk
126 |
127 | # include project make variables
128 | include nbproject/Makefile-variables.mk
129 |
--------------------------------------------------------------------------------
/Server.tproj/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # There exist several targets which are by default empty and which can be
3 | # used for execution of your targets. These targets are usually executed
4 | # before and after some main targets. They are:
5 | #
6 | # .build-pre: called before 'build' target
7 | # .build-post: called after 'build' target
8 | # .clean-pre: called before 'clean' target
9 | # .clean-post: called after 'clean' target
10 | # .clobber-pre: called before 'clobber' target
11 | # .clobber-post: called after 'clobber' target
12 | # .all-pre: called before 'all' target
13 | # .all-post: called after 'all' target
14 | # .help-pre: called before 'help' target
15 | # .help-post: called after 'help' target
16 | #
17 | # Targets beginning with '.' are not intended to be called on their own.
18 | #
19 | # Main targets can be executed directly, and they are:
20 | #
21 | # build build a specific configuration
22 | # clean remove built files from a configuration
23 | # clobber remove all built files
24 | # all build all configurations
25 | # help print help mesage
26 | #
27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28 | # .help-impl are implemented in nbproject/makefile-impl.mk.
29 | #
30 | # Available make variables:
31 | #
32 | # CND_BASEDIR base directory for relative paths
33 | # CND_DISTDIR default top distribution directory (build artifacts)
34 | # CND_BUILDDIR default top build directory (object files, ...)
35 | # CONF name of current configuration
36 | # CND_PLATFORM_${CONF} platform name (current configuration)
37 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
38 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
39 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
40 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
41 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration)
42 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration)
43 | #
44 | # NOCDDL
45 |
46 |
47 | # Environment
48 | MKDIR=mkdir
49 | CP=cp
50 | CCADMIN=CCadmin
51 |
52 |
53 | # build
54 | build: .build-post
55 |
56 | .build-pre:
57 | # Add your pre 'build' code here...
58 |
59 | .build-post: .build-impl
60 | # Add your post 'build' code here...
61 |
62 |
63 | # clean
64 | clean: .clean-post
65 |
66 | .clean-pre:
67 | # Add your pre 'clean' code here...
68 |
69 | .clean-post: .clean-impl
70 | # Add your post 'clean' code here...
71 |
72 |
73 | # clobber
74 | clobber: .clobber-post
75 |
76 | .clobber-pre:
77 | # Add your pre 'clobber' code here...
78 |
79 | .clobber-post: .clobber-impl
80 | # Add your post 'clobber' code here...
81 |
82 |
83 | # all
84 | all: .all-post
85 |
86 | .all-pre:
87 | # Add your pre 'all' code here...
88 |
89 | .all-post: .all-impl
90 | # Add your post 'all' code here...
91 |
92 |
93 | # build tests
94 | build-tests: .build-tests-post
95 |
96 | .build-tests-pre:
97 | # Add your pre 'build-tests' code here...
98 |
99 | .build-tests-post: .build-tests-impl
100 | # Add your post 'build-tests' code here...
101 |
102 |
103 | # run tests
104 | test: .test-post
105 |
106 | .test-pre: build-tests
107 | # Add your pre 'test' code here...
108 |
109 | .test-post: .test-impl
110 | # Add your post 'test' code here...
111 |
112 |
113 | # help
114 | help: .help-post
115 |
116 | .help-pre:
117 | # Add your pre 'help' code here...
118 |
119 | .help-post: .help-impl
120 | # Add your post 'help' code here...
121 |
122 |
123 |
124 | # include project implementation makefile
125 | include nbproject/Makefile-impl.mk
126 |
127 | # include project make variables
128 | include nbproject/Makefile-variables.mk
129 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # There exist several targets which are by default empty and which can be
3 | # used for execution of your targets. These targets are usually executed
4 | # before and after some main targets. They are:
5 | #
6 | # .build-pre: called before 'build' target
7 | # .build-post: called after 'build' target
8 | # .clean-pre: called before 'clean' target
9 | # .clean-post: called after 'clean' target
10 | # .clobber-pre: called before 'clobber' target
11 | # .clobber-post: called after 'clobber' target
12 | # .all-pre: called before 'all' target
13 | # .all-post: called after 'all' target
14 | # .help-pre: called before 'help' target
15 | # .help-post: called after 'help' target
16 | #
17 | # Targets beginning with '.' are not intended to be called on their own.
18 | #
19 | # Main targets can be executed directly, and they are:
20 | #
21 | # build build a specific configuration
22 | # clean remove built files from a configuration
23 | # clobber remove all built files
24 | # all build all configurations
25 | # help print help mesage
26 | #
27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28 | # .help-impl are implemented in nbproject/makefile-impl.mk.
29 | #
30 | # Available make variables:
31 | #
32 | # CND_BASEDIR base directory for relative paths
33 | # CND_DISTDIR default top distribution directory (build artifacts)
34 | # CND_BUILDDIR default top build directory (object files, ...)
35 | # CONF name of current configuration
36 | # CND_PLATFORM_${CONF} platform name (current configuration)
37 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
38 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
39 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
40 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
41 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration)
42 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration)
43 | #
44 | # NOCDDL
45 |
46 |
47 | # Environment
48 | MKDIR=mkdir
49 | CP=cp
50 | CCADMIN=CCadmin
51 |
52 |
53 | # build
54 | build: .build-post
55 |
56 | .build-pre:
57 | # Add your pre 'build' code here...
58 |
59 | .build-post: .build-impl
60 | # Add your post 'build' code here...
61 |
62 |
63 | # clean
64 | clean: .clean-post
65 |
66 | .clean-pre:
67 | # Add your pre 'clean' code here...
68 |
69 | .clean-post: .clean-impl
70 | # Add your post 'clean' code here...
71 |
72 |
73 | # clobber
74 | clobber: .clobber-post
75 |
76 | .clobber-pre:
77 | # Add your pre 'clobber' code here...
78 |
79 | .clobber-post: .clobber-impl
80 | # Add your post 'clobber' code here...
81 |
82 |
83 | # all
84 | all: .all-post
85 |
86 | .all-pre:
87 | # Add your pre 'all' code here...
88 |
89 | .all-post: .all-impl
90 | # Add your post 'all' code here...
91 |
92 |
93 | # build tests
94 | build-tests: .build-tests-post
95 |
96 | .build-tests-pre:
97 | # Add your pre 'build-tests' code here...
98 |
99 | .build-tests-post: .build-tests-impl
100 | # Add your post 'build-tests' code here...
101 |
102 |
103 | # run tests
104 | test: .test-post
105 |
106 | .test-pre: build-tests
107 | # Add your pre 'test' code here...
108 |
109 | .test-post: .test-impl
110 | # Add your post 'test' code here...
111 |
112 |
113 | # help
114 | help: .help-post
115 |
116 | .help-pre:
117 | # Add your pre 'help' code here...
118 |
119 | .help-post: .help-impl
120 | # Add your post 'help' code here...
121 |
122 |
123 |
124 | # include project implementation makefile
125 | include nbproject/Makefile-impl.mk
126 |
127 | # include project make variables
128 | include nbproject/Makefile-variables.mk
129 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/TimeoutTask.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: TimeoutTask.h
27 |
28 | Contains: Just like a normal task, but can be scheduled for timeouts. Unlike
29 | IdleTask, which is VERY aggressive about being on time, but high
30 | overhead for maintaining the timing information, this is a low overhead,
31 | low priority timing mechanism. Timeouts may not happen exactly when
32 | they are supposed to, but who cares?
33 |
34 |
35 |
36 |
37 | */
38 |
39 | #ifndef __TIMEOUTTASK_H__
40 | #define __TIMEOUTTASK_H__
41 |
42 |
43 | #include "StrPtrLen.h"
44 | #include "IdleTask.h"
45 |
46 | #include "OSThread.h"
47 | #include "OSQueue.h"
48 | #include "OSMutex.h"
49 | #include "OS.h"
50 |
51 | #define TIMEOUT_DEBUGGING 0 //messages to help debugging timeouts
52 |
53 | class TimeoutTaskThread : public IdleTask
54 | {
55 | public:
56 |
57 | //All timeout tasks get timed out from this thread
58 | TimeoutTaskThread() : IdleTask(), fMutex() {this->SetTaskName("TimeoutTask");}
59 | virtual ~TimeoutTaskThread(){}
60 |
61 | private:
62 |
63 | //this thread runs every minute and checks for timeouts
64 | enum
65 | {
66 | kIntervalSeconds = 60 //UInt32
67 | };
68 |
69 | virtual SInt64 Run();
70 | OSMutex fMutex;
71 | OSQueue fQueue;
72 |
73 | friend class TimeoutTask;
74 | };
75 |
76 | class TimeoutTask
77 | {
78 | //TimeoutTask is not a derived object off of Task, to add flexibility as
79 | //to how this object can be utilitized
80 |
81 | public:
82 |
83 | //Call Initialize before using this class
84 | static void Initialize();
85 | //Pass in the task you'd like to send timeouts to.
86 | //Also pass in the timeout you'd like to use. By default, the timeout is 0 (NEVER).
87 | TimeoutTask(Task* inTask, SInt64 inTimeoutInMilSecs = 60);
88 | ~TimeoutTask();
89 |
90 | //MODIFIERS
91 |
92 | // Changes the timeout time, also refreshes the timeout
93 | void SetTimeout(SInt64 inTimeoutInMilSecs);
94 |
95 | // Specified task will get a Task::kTimeoutEvent if this
96 | // function isn't called within the timeout period
97 | void RefreshTimeout() { fTimeoutAtThisTime = OS::Milliseconds() + fTimeoutInMilSecs; Assert(fTimeoutAtThisTime > 0); }
98 |
99 | void SetTask(Task* inTask) { fTask = inTask; }
100 | private:
101 |
102 | Task* fTask;
103 | SInt64 fTimeoutAtThisTime;
104 | SInt64 fTimeoutInMilSecs;
105 | //for putting on our global queue of timeout tasks
106 | OSQueueElem fQueueElem;
107 |
108 | static TimeoutTaskThread* sThread;
109 |
110 | friend class TimeoutTaskThread;
111 | };
112 | #endif //__TIMEOUTTASK_H__
113 |
114 |
--------------------------------------------------------------------------------
/PrefsSourceLib/XMLParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #ifndef __XMLParser_h__
27 | #define __XMLParser_h__
28 |
29 | #include "StringParser.h"
30 | #include "OSQueue.h"
31 | #include "OSFileSource.h"
32 | #include "ResizeableStringFormatter.h"
33 |
34 | class DTDVerifier
35 | {
36 | public:
37 | virtual bool IsValidSubtag(char* tagName, char* subTagName) = 0;
38 | virtual bool IsValidAttributeName(char* tagName, char* attrName) = 0;
39 | virtual bool IsValidAttributeValue(char* tagName, char* attrName, char* attrValue) = 0;
40 | virtual char* GetRequiredAttribute(char* tagName, int index) = 0;
41 | virtual bool CanHaveValue(char* tagName) = 0;
42 | virtual ~DTDVerifier(){};
43 | };
44 |
45 | class XMLTag
46 | {
47 | public:
48 | XMLTag();
49 | XMLTag(char* tagName);
50 | ~XMLTag();
51 |
52 | bool ParseTag(StringParser* parser, DTDVerifier* verifier, char* errorBuffer = NULL, int errorBufferSize = 0);
53 |
54 | char* GetAttributeValue(const char* attrName);
55 | char* GetValue() { return fValue; }
56 | char* GetTagName() { return fTag; }
57 |
58 | UInt32 GetNumEmbeddedTags() { return fEmbeddedTags.GetLength(); }
59 |
60 | XMLTag* GetEmbeddedTag(const UInt32 index = 0);
61 | XMLTag* GetEmbeddedTagByName(const char* tagName, const UInt32 index = 0);
62 | XMLTag* GetEmbeddedTagByAttr(const char* attrName, const char* attrValue, const UInt32 index = 0);
63 | XMLTag* GetEmbeddedTagByNameAndAttr(const char* tagName, const char* attrName, const char* attrValue, const UInt32 index = 0);
64 |
65 | void AddAttribute(char* attrName, char* attrValue);
66 | void RemoveAttribute(char* attrName);
67 | void AddEmbeddedTag(XMLTag* tag);
68 | void RemoveEmbeddedTag(XMLTag* tag);
69 |
70 | void SetTagName( char* name);
71 | void SetValue( char* value);
72 |
73 | void FormatData(ResizeableStringFormatter* formatter, UInt32 indent);
74 |
75 | private:
76 | void ConsumeIfComment(StringParser* parser);
77 |
78 | char* fTag;
79 | char* fValue;
80 | OSQueue fAttributes;
81 | OSQueue fEmbeddedTags;
82 |
83 | OSQueueElem fElem;
84 |
85 | static UInt8 sNonNameMask[]; // stop when you hit a word
86 | };
87 |
88 | class XMLAttribute
89 | {
90 | public:
91 | XMLAttribute();
92 | ~XMLAttribute();
93 |
94 | char* fAttrName;
95 | char* fAttrValue;
96 |
97 | OSQueueElem fElem;
98 | };
99 |
100 | class XMLParser
101 | {
102 | public:
103 | XMLParser( char* inPath, DTDVerifier* verifier = NULL);
104 | ~XMLParser();
105 |
106 | // Check for existence, man.
107 | Bool16 DoesFileExist();
108 | Bool16 DoesFileExistAsDirectory();
109 | Bool16 CanWriteFile();
110 |
111 | Bool16 ParseFile(char* errorBuffer = NULL, int errorBufferSize = 0);
112 |
113 | XMLTag* GetRootTag() { return fRootTag; }
114 | void SetRootTag(XMLTag* tag);
115 |
116 | void WriteToFile(char** fileHeader);
117 |
118 | private:
119 | XMLTag* fRootTag;
120 |
121 | OSFileSource fFile;
122 | char* fFilePath;
123 | DTDVerifier* fVerifier;
124 | };
125 |
126 | #endif
127 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/OSMutex.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: OSMutex.h
27 |
28 | Contains: Platform - independent mutex header. The implementation of this object
29 | is platform - specific. Each platform must define an independent
30 | OSMutex.h & OSMutex.cpp file.
31 |
32 | This file is for Mac OS X Server only
33 |
34 |
35 |
36 | */
37 |
38 | #ifndef _OSMUTEX_H_
39 | #define _OSMUTEX_H_
40 |
41 | #include
42 | #include "SafeStdLib.h"
43 | #ifndef __Win32__
44 | #include
45 | #if __PTHREADS_MUTEXES__
46 | #if __MacOSX__
47 | #ifndef _POSIX_PTHREAD_H
48 | #include
49 | #endif
50 | #else
51 | #include
52 | #endif
53 | #include
54 |
55 | #else
56 | #include "mymutex.h"
57 | #endif
58 | #endif
59 |
60 | #include "OSHeaders.h"
61 | #include "OSThread.h"
62 | #include "MyAssert.h"
63 |
64 | class OSCond;
65 |
66 | class OSMutex
67 | {
68 | public:
69 |
70 | OSMutex();
71 | ~OSMutex();
72 |
73 | inline void Lock();
74 | inline void Unlock();
75 |
76 | // Returns true on successful grab of the lock, false on failure
77 | inline Bool16 TryLock();
78 |
79 | private:
80 |
81 | #ifdef __Win32__
82 | CRITICAL_SECTION fMutex;
83 |
84 | DWORD fHolder;
85 | UInt32 fHolderCount;
86 |
87 | #elif !__PTHREADS_MUTEXES__
88 | mymutex_t fMutex;
89 | #else
90 | pthread_mutex_t fMutex;
91 | // These two platforms don't implement pthreads recursive mutexes, so
92 | // we have to do it manually
93 | pthread_t fHolder;
94 | UInt32 fHolderCount;
95 | #endif
96 |
97 | #if __PTHREADS_MUTEXES__ || __Win32__
98 | void RecursiveLock();
99 | void RecursiveUnlock();
100 | Bool16 RecursiveTryLock();
101 | #endif
102 | friend class OSCond;
103 | };
104 |
105 | class OSMutexLocker
106 | {
107 | public:
108 |
109 | OSMutexLocker(OSMutex *inMutexP) : fMutex(inMutexP) { if (fMutex != NULL) fMutex->Lock(); }
110 | ~OSMutexLocker() { if (fMutex != NULL) fMutex->Unlock(); }
111 |
112 | void Lock() { if (fMutex != NULL) fMutex->Lock(); }
113 | void Unlock() { if (fMutex != NULL) fMutex->Unlock(); }
114 |
115 | private:
116 |
117 | OSMutex* fMutex;
118 | };
119 |
120 | void OSMutex::Lock()
121 | {
122 | #if __PTHREADS_MUTEXES__ || __Win32__
123 | this->RecursiveLock();
124 | #else
125 | mymutex_lock(fMutex);
126 | #endif //!__PTHREADS__
127 | }
128 |
129 | void OSMutex::Unlock()
130 | {
131 | #if __PTHREADS_MUTEXES__ || __Win32__
132 | this->RecursiveUnlock();
133 | #else
134 | mymutex_unlock(fMutex);
135 | #endif //!__PTHREADS__
136 | }
137 |
138 | Bool16 OSMutex::TryLock()
139 | {
140 | #if __PTHREADS_MUTEXES__ || __Win32__
141 | return this->RecursiveTryLock();
142 | #else
143 | return (Bool16)mymutex_try_lock(fMutex);
144 | #endif //!__PTHREADS__
145 | }
146 |
147 | #endif //_OSMUTEX_H_
148 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/MyAssert.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 |
26 | #ifndef _MYASSERT_H_
27 | #define _MYASSERT_H_
28 |
29 | #include
30 | #include "SafeStdLib.h"
31 |
32 | #ifdef __cplusplus
33 | class AssertLogger
34 | {
35 | public:
36 | // An interface so the MyAssert function can write a message
37 | virtual void LogAssert(char* inMessage) = 0;
38 | virtual ~AssertLogger(){};
39 | };
40 |
41 | // If a logger is provided, asserts will be logged. Otherwise, asserts will cause a bus error
42 | void SetAssertLogger(AssertLogger* theLogger);
43 | #endif
44 |
45 | #if ASSERT
46 | void MyAssert(char *s);
47 |
48 | #define kAssertBuffSize 256
49 |
50 | #define Assert(condition) { \
51 | \
52 | if (!(condition)) \
53 | { \
54 | char s[kAssertBuffSize]; \
55 | s[kAssertBuffSize -1] = 0; \
56 | qtss_snprintf (s,kAssertBuffSize -1, "_Assert: %s, %d",__FILE__, __LINE__ ); \
57 | MyAssert(s); \
58 | } }
59 |
60 |
61 | #define AssertV(condition,errNo) { \
62 | if (!(condition)) \
63 | { \
64 | char s[kAssertBuffSize]; \
65 | s[kAssertBuffSize -1] = 0; \
66 | qtss_snprintf( s,kAssertBuffSize -1, "_AssertV: %s, %d (%d)",__FILE__, __LINE__, errNo ); \
67 | MyAssert(s); \
68 | } }
69 |
70 |
71 | #define Warn(condition) { \
72 | if (!(condition)) \
73 | qtss_printf( "_Warn: %s, %d\n",__FILE__, __LINE__ ); }
74 |
75 | #define WarnV(condition,msg) { \
76 | if (!(condition)) \
77 | qtss_printf ("_WarnV: %s, %d (%s)\n",__FILE__, __LINE__, msg ); }
78 |
79 | #define WarnVE(condition,msg,err) { \
80 | if (!(condition)) \
81 | { char buffer[kAssertBuffSize]; \
82 | buffer[kAssertBuffSize -1] = 0; \
83 | qtss_printf ("_WarnV: %s, %d (%s, %s [err=%d])\n",__FILE__, __LINE__, msg, qtss_strerror(err,buffer,sizeof(buffer) -1), err ); \
84 | } }
85 |
86 | #else
87 |
88 | #define Assert(condition) ((void) 0)
89 | #define AssertV(condition,errNo) ((void) 0)
90 | #define Warn(condition) ((void) 0)
91 | #define WarnV(condition,msg) ((void) 0)
92 |
93 | #endif
94 | #endif //_MY_ASSERT_H_
95 |
--------------------------------------------------------------------------------
/CommonUtilitiesLib/IdleTask.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * @APPLE_LICENSE_HEADER_START@
4 | *
5 | * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
6 | *
7 | * This file contains Original Code and/or Modifications of Original Code
8 | * as defined in and that are subject to the Apple Public Source License
9 | * Version 2.0 (the 'License'). You may not use this file except in
10 | * compliance with the License. Please obtain a copy of the License at
11 | * http://www.opensource.apple.com/apsl/ and read it before using this
12 | * file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 | * Please see the License for the specific language governing rights and
20 | * limitations under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | */
25 | /*
26 | File: IdleTask.cpp
27 |
28 | Contains: IdleTasks are identical to normal tasks (see task.h) with one exception:
29 |
30 | You can schedule them for timeouts. If you call SetIdleTimer
31 | on one, after the time has elapsed the task object will receive an
32 | OS_IDLE event.
33 |
34 |
35 |
36 | */
37 |
38 | #include "IdleTask.h"
39 | #include "OSMemory.h"
40 | #include "OS.h"
41 |
42 | //IDLETASKTHREAD IMPLEMENTATION:
43 | IdleTaskThread* IdleTask::sIdleThread = NULL;
44 |
45 | void IdleTaskThread::SetIdleTimer(IdleTask *activeObj, SInt64 msec)
46 | {
47 | //note: OSHeap doesn't support a random remove, so this function
48 | //won't change the timeout value if there is already one set
49 | if (activeObj->fIdleElem.IsMemberOfAnyHeap())
50 | return;
51 | activeObj->fIdleElem.SetValue(OS::Milliseconds() + msec);
52 |
53 | {
54 | OSMutexLocker locker(&fHeapMutex);
55 | fIdleHeap.Insert(&activeObj->fIdleElem);
56 | }
57 | fHeapCond.Signal();
58 | }
59 |
60 | void IdleTaskThread::CancelTimeout(IdleTask* idleObj)
61 | {
62 | Assert(idleObj != NULL);
63 | OSMutexLocker locker(&fHeapMutex);
64 | fIdleHeap.Remove(&idleObj->fIdleElem);
65 | }
66 |
67 | void
68 | IdleTaskThread::Entry()
69 | {
70 | OSMutexLocker locker(&fHeapMutex);
71 |
72 | while (true)
73 | {
74 | //if there are no events to process, block.
75 | if (fIdleHeap.CurrentHeapSize() == 0)
76 | fHeapCond.Wait(&fHeapMutex);
77 | SInt64 msec = OS::Milliseconds();
78 |
79 | //pop elements out of the heap as long as their timeout time has arrived
80 | while ((fIdleHeap.CurrentHeapSize() > 0) && (fIdleHeap.PeekMin()->GetValue() <= msec))
81 | {
82 | IdleTask* elem = (IdleTask*)fIdleHeap.ExtractMin()->GetEnclosingObject();
83 | Assert(elem != NULL);
84 | elem->Signal(Task::kIdleEvent);
85 | }
86 |
87 | //we are done sending idle events. If there is a lowest tick count, then
88 | //we need to sleep until that time.
89 | if (fIdleHeap.CurrentHeapSize() > 0)
90 | {
91 | SInt64 timeoutTime = fIdleHeap.PeekMin()->GetValue();
92 | //because sleep takes a 32 bit number
93 | timeoutTime -= msec;
94 | Assert(timeoutTime > 0);
95 | UInt32 smallTime = (UInt32)timeoutTime;
96 | fHeapCond.Wait(&fHeapMutex, smallTime);
97 | }
98 | }
99 | }
100 |
101 | void IdleTask::Initialize()
102 | {
103 | if (sIdleThread == NULL)
104 | {
105 | sIdleThread = NEW IdleTaskThread();
106 | sIdleThread->Start();
107 | }
108 | }
109 |
110 | IdleTask::~IdleTask()
111 | {
112 | //clean up stuff used by idle thread routines
113 | Assert(sIdleThread != NULL);
114 |
115 | OSMutexLocker locker(&sIdleThread->fHeapMutex);
116 |
117 | //Check to see if there is a pending timeout. If so, get this object
118 | //out of the heap
119 | if (fIdleElem.IsMemberOfAnyHeap())
120 | sIdleThread->CancelTimeout(this);
121 | }
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------