Code/CFLite/CFNetwork/Old

From kJams Wiki
Jump to navigation Jump to search

OpenCFLite project and file changes

  • CFNetTest\CFTest\win_vs\pre_build.bat; Change VS vars path to call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"
  • CFTest.vcproj - change QuickTime libraries path in Linker to $(SolutionDir)..\..\kJams\External\QuickTime SDK\Libraries
  • Add explicit direction __WIN32__ to PreprocessorDefinitions so that VS2008 properly reflects disabled code
  • mDNSResponder support (dns-sd)
    • Add mDNSResponder folder to the include path to OpenCFLite project;
    • Add lib file to linker configuration $(ProjectDir)..\..\mDNSResponder\lib\dnssd.lib

File modifications

  • CFBase.h - make typedef for Boolean type available to WINDOWS target
    • Line added to CFBase.h - "typedef unsigned char Boolean;
  • CFRuntime.c - Added two new functions for socket initialization (WinSock requires startup code)
    • Added __CFSocketInitialize
    • Added __CFSocketInitializeWinSock
  • Socket initialization is added to __CFInitialize
    • CFSocket ensures initialization on creation. However this is needed so that any other code could reference WinSock API (Ex: AddressLookup)
  • CFSocketStream.c - instead of the default need to use the code in CFNetwork (NOTE: This file needs to be references in includes)
  • CFUrlAccess.c - merge in new functionality from _CFUrlAccess.c available in CFNetwork distribution
    • Added _CFHTTPMessageSendRequest
    • Added _CFURLCreateDataAndPropertiesFromResource
    • Added _CFURLWriteDataAndPropertiesToResource
    • Added _CFURLDestroyResource
  • Add support for HTTP URL into the existing function CFURLCreateDataAndPropertiesFromResource
  • ForFoundationOnly.h - added HTTP cleanup routines


External libraries changes

  • QuickTime ConditionalMacros.h issue fix:
    • the file is available in both QuickTime and OpenCFLite, which makes it confusing for the compiler
    • if it uses the wrong file, CFTest compilation fails with ~100 errors
    • To fix this, change includes <ConditionalMacroh.h> to "ConditionalMacros.h" (File MacTypes.h)


Porting CFNetwork to VS complier

First import thing to note is compiler differences on difference platforms - Visual Studio 2008 supports C90 standard. A newer complier was used to develop CFNetwork. Hence the most important differences:

  • All variable definitions must be placed at the beginning of each scope (otherwise it fails with "illegal type as an expression" errors)
  • C90 allows structure initialization only by compile time constants (no pointers or even constants pointers to constant data)
  • inline support - Visual studio uses keyword __inline (double underscore is required)
  • Visual Studio compiler does not allow double class storage specifier such as "static static int var"