Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

iKlax Tools Library (KToolLib)

1.0.1

Summary

A. What's KToolLib ?
B. KToolLib Architecture
   1. System
   2. Types
   3. Multithreading
   4. Network
   5. Audio
C. Compilation
D. Example
E. Licence
F. Authors & Partners

A. What's KToolLib ?

KToolLib is for iKlax Tools Library, and is a great tools box for C development. All C standard libraries & functions had been rewritten in KToolLib, for multiplatform using. This library had been developed and tested on Windows XP & Vista, MacOS 10.4 & 10.5 (Intel & PowerPC), iPhone OS 3.x, Windows Mobile 6.5 and GNU/Linux (Ubuntu & Gentoo) for 32 & 64 bit processors. Actually the iKlax Team works on versions of KToolLib for Windows 7, MacOS 10.6, Android and Symbian.

Other versions with updates and for another platforms will be available later. If your prefered platform is not available, please contact us on iklaxmedia.com.

B. KToolLib Architecture

1. System

This section regroups lot of functions of the C Standard Library.

1-1. Basic Types

This file contains all redeclarations of basic types.
See the ktypes.h file reference.

1-2. Memory

All functions to allocate, free, copy memory zones.
See the ksystem.h file reference.

1-3. Input / Output

All functions to :

See the kio.h file reference.

1-4. Errors

Some functions to help errors managment.
See the kerror.h file reference.

1-5. Math

All mathematic functions.
See the kmath.h file reference.

1-6. Tools

Some functions to:

See the ktool.h file reference.

1-7. Conversions

A lot of functions to convert everything to everything!
See the kconvert.h file reference.

1-8. K-Objects

Some preprocessor macros to generate automaticly a structure and its bases functions.
See the kobjects.h file reference.

2. Types

This module is a set of types and structures...

2-1. Standard Strings

All functions to manage ASCII strings...
See the KString.h file reference.

2-2. Unicode Strings

All functions to manage unicode strings...
See the KWString.h file reference.

2-3. General Single Lists

Declaration of a basic single list. This list is single-linked, and all its elements have got a pointer to an user data.
See the KList.h file reference.

2-4. Lists with Constants Pointer

Declaration of a constant list. This list is single-linked, and all its elements have got a constant pointer to an user data.
See the KCList.h file reference.

2-5. Strings Lists

Declaration of a string list. This list is single-linked, and all its elements have got a constant pointer to an ASCII string
See the KStrList.h file reference.

2-6. Numerical Lists

Declarations of a numerical lists. These lists are single-linked, and all its elements have got a numerical value.
This is the list of type available for numerical values:

See the KIntList.h file reference.

2-7. Hash Tables

All function to manage hash tables
See the KHash.h file reference.

2-8. Processes Progressions

Declaration of a structure and its functions to manage progessions in process.
See the KProgress.h file reference.

2-9. Time

All functions to manage time.
See the KTime.h file reference.

2-10. Color

Some preprocessor macros about color...
See the KColor.h file reference.

2-11. Xml

Declaration of a structure and its functions to manage XML stream.
See the KXml.h file reference.

2-12. Box File Format Structure

Declaration of a structure and its functions to manage stream in box file format.
See the k_io_box.h file reference.

3. Multithreading

3-1. Threads

Declaration of a thread structure and all its functions.
See the KThread.h file reference.

3-2. Mutex

Declaration of a mutex structure and all its functions.
See the KMutex.h file reference.

3-3. Semaphores

Declaration of a semaphore structure and all its functions.
See the KSemaphore.h file reference.

4. Network

4-1. Sockets

Declaration of a socket structure and all its functions.
See the KSocket.h file reference.

4-2. Server Sockets

Declaration of a server socket structure and all its functions.
See the KServerSocket.h file reference.

4-3. Simple Server

Declaration of a simple server and its functions. Very useful to create a server in a very short time!
See the KServer.h file reference.

5. Audio

5-1. Fomats Emumeration

This is an enumerator of audio format and some functions to manage them.
See the EAudioFmt.h file reference.

5-2. Fomat Structure

This is a structure and its functions to manage an audio format and its options.
See the KAudioFormat.h file reference.

5-3. Frequency Filter Structure

Structure used to apply frequency filter on audio streams.
See the KEqualization.h file reference.

C. Compilation

Windows

The only available binary for Windows OS is a dynamic library (a .dll file).

Mac OS

The only available binary for Mac OS is a dynamic library (a .dylib file).

iPhone OS

The only available binary for iPhone OS is a static library (a .a file).

D. Example

This example shows you how find a file a the file system and read it, with the KToolLib.

Declarations

#include <KToolLib.h>

static KCString m_sLicenceFileName = "LICENCE.TXT";

static KString k_getTextFromFile (KCString sFilePath);
static KString k_searchFile (KCString sFileName);

Search a file

// Searchs a file in parent directories
KString k_searchFile (KCString sFileName) {
   static const KUInt8 iIterMax = 10;
   KUInt8 i = 0;
   KFILE* pFile = knull;
   KString sPath = knull;
   KString sTmpPath = knull;
   KBool bRet = kfalse;

   // Check paramter
   bRet = knull != sFileName;

   // Copy the file name - This function copy all the string until
   //  and with the character '\0'.
   bRet = bRet && knull != (sPath = k_strcpy (sFileName));

   for (i=0; bRet && i<iIterMax; i++) {
      // Try to open the file
      pFile = k_fmopen (sPath, K_OPEN_READ);
      if (knull != pFile) {
         // The file exists
         k_fclose (pFile);
         return sPath;
      } 

      // Create a new file path
      sTmpPath = sPath;
      bRet = bRet && knull != (sPath = 
         KString_new (k_strlen (sTmpPath) + 3));
      bRet = bRet && knull != k_memcpy (sPath, "../", 3);
      bRet = bRet && knull != k_memcpy (
         sPath + 3, sTmpPath, k_strlen (sTmpPath));
      k_free (sTmpPath);
   }

   k_free (sPath);
   return knull;
}

Read a file

// Reads a file and returns its contents in a string
KString k_getTextFromFile (KCString sFilePath) {
   KFILE* pFile = knull;
   KBool bRet = kfalse;
   KString sText = knull;
   KInt32 iBytes = 0;

   // Check paramter
   bRet = knull != sFilePath;

   // Open the file
   bRet = bRet && knull != (pFile = k_fmopen (sFilePath, K_OPEN_READ));
   // Go to the end of the file
   bRet = bRet && 0 == k_fseek (pFile, 0, K_SEEK_END);
   // iBytes = size of file
   bRet = bRet && 0 < (iBytes = k_ftell (pFile));
   // Go to the begin of the file
   bRet = bRet && 0 == k_fseek (pFile, 0, K_SEEK_SET);
   // Initialize the string
   bRet = bRet && knull != (sText = KString_new (iBytes));
   // Read in the file
   bRet = bRet && 1 == k_fread (sText, iBytes, 1, pFile);
   // Close the file. It's not necessary to check the pointer
   //  before this call: this function do it, and resets the
   //  pointer to knull.
   k_fclose (pFile);

   // Error & return
   if (!bRet) {
      // It's not necessary to check the pointer before this call: 
      //  this function do it, and resets the pointer to knull.
      k_free (sText);
      return knull;
   }
   return sText;
}

Main function

KBool ktest_ktoollib () {
   KString sFilePath = knull;
   KString sText = knull;

   // Search the licence file
   sFilePath = k_searchFile (m_sLicenceFileName);
   if (knull == sFilePath) {
      k_print_std (
         "Cannot find the licence file (%s)!\n", m_sLicenceFileName);
      return kfalse;
   }

   // Read the file
   sText = k_getTextFromFile (sFilePath);
   if (knull == sText) {
      k_free (sFilePath);
      k_print_std ("Cannot read the licence file (%s)!\n", sFilePath);
      return kfalse;
   }

   // Write on standard output the licence file
   k_print_std ("This is the licence of iKlax Librairies:\n%s\n", sText);

   k_free (sText);
   k_free (sFilePath);

   return ktrue;
}

E. Licence

IKLAX LIBRARY LICENSE AGREEMENT This software is proprietary to iKlax Media SAS, is protected under french Software Protection Agency (APP) and is copyrighted (C) by iKlax Media SAS. Its use and disclosure is limited by the terms and conditions of this license agreement. The following terms apply to all files associated with the software.

iKlax Media SAS hereby grant permission to use, copy and distribute this software and its documentation for any non-commercial purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in non-commercial distributions. No written agreement, license, or royalty fee is required for non-commercial uses. For commercial uses, distribution of this software or for modification on this this software, please contact iKlax Media SAS. (http://www.iklaxmedia.com)

IN NO EVENT SHALL IKLAX MEDIA SAS, THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

IKLAX MEDIA SAS, THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE AND ITS DOCUMENTATION ARE PROVIDED ON AN "AS IS" BASIS, AND IKLAX MEDIA SAS, THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

F. Authors & Partners

Authors

The following authors have contributed to iKlax Libraries and its documentations. All authors are or were employee by iKlax Media SAS. (In alphabetical order of firstname):

Partners


Generated on Tue Mar 9 10:49:29 2010 for iKlax Tools Library (KToolLib) by doxygen 1.3.8