liblingoteach: lingoteach.h File Reference

Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

# lingoteach.h File Reference

`#include <stdlib.h>`
`#include "lingdefs.h"`

## Defines
#define | LINGOTEACH_H 1
## Functions
lingConfig * | ling_conf_init_config (lingchar *name, lingchar *file, const lingchar *lang_dtd, const lingchar *lesson_dtd)
void | ling_conf_free_config (lingConfig *settings)
lingchar ** | ling_lang_get_languages (lingConfig *settings)
int | ling_lang_get_language_amount (lingConfig *settings)
lingchar * | ling_lang_get_lang_translation (lingConfig *settings, lingchar *language, lingchar *translation)
lingchar * | ling_lang_get_trans_language (lingConfig *settings, lingchar *translation, lingchar *language)
lingchar ** | ling_lang_get_lang_translations (lingConfig *settings, lingchar **languages, lingchar *translation)
lingLesson * | ling_lesson_new (void)
void | ling_lesson_free (lingLesson *lesson)
lingLesson * | ling_lesson_create (char *filename, lingConfig *settings)
lingLesson * | ling_lesson_add (lingLesson *list, lingLesson *lesson)
lingLesson * | ling_lesson_remove (lingLesson *lesson, lingLesson *node)
char * | ling_lesson_get_path (lingLesson *lesson)
char * | ling_lesson_set_path (lingLesson *lesson, char *path)
int | ling_lesson_get_last_meaning_id (lingLesson *lesson)
int | ling_lesson_get_meaning_amount (lingLesson *lesson)
int | ling_lesson_get_translation_amount (lingLesson *lesson)
lingbool | ling_lesson_save_lesson (lingLesson *lesson, char *filename)
char * | ling_lesson_create_template (char *filename, int meanings, lingConfig *settings)
lingMeaning * | ling_lesson_create_tree (lingLesson *lesson)
lingMeaning * | ling_meaning_new (void)
lingMInfo * | ling_meaning_info_new (void)
lingMeaning * | ling_meaning_get_by_id (lingLesson *lesson, unsigned int id, lingchar *language)
lingMInfo * | ling_meaning_get_information (lingMeaning *meaning)
lingchar * | ling_meaning_get_description (lingMeaning *meaning)
lingchar * | ling_meaning_get_phonetic (lingMeaning *meaning)
void | ling_meaning_free (lingMeaning *meaning)
lingMeaning * | ling_meaning_free_1 (lingMeaning *tree, lingMeaning *node)
void | ling_meaning_info_free (lingMInfo *info)
lingLesson * | ling_meaning_create_lesson (lingMeaning *meaning, lingConfig *settings, lingchar *type, lingchar *sound)
lingMeaning * | ling_meaning_add (lingMeaning *tree, lingMeaning *meaning)
lingMeaning * | ling_meaning_insert_after (lingMeaning *tree, lingMeaning *parent, lingMeaning *child)
lingMeaning * | ling_meaning_replace (lingMeaning *tree, unsigned int id, lingMeaning *meaning)
lingchar * | ling_meaning_get_sound (lingMeaning *meaning)
lingchar ** | ling_meaning_get_images (lingMeaning *meaning)
void * | ling_malloc (size_t size)
void | ling_free (void *ptr)
void | ling_strings_free (lingchar **array)

## Define Documentation

#define LINGOTEACH_H 1

## Function Documentation

void ling_conf_free_config | ( | lingConfig * | settings | ) |

  | Frees the memory hold by a lingConfig. Parameters:
  | settings | The lingConfig to free.

lingConfig* ling_conf_init_config | ( | lingchar * | name,
|  | lingchar * | file,
|  | const lingchar * | lang_dtd,
|  | const lingchar * | lesson_dtd
| ) |

  | Creates a new, empty lingConfig for usage. The lingConfig should be freed using ling_conf_free_config(). Parameters:
  | name | The name of the application, which uses the library.
  | file | The file, which contains the languages.
  | lang_dtd | The DTD file, the language file has to validate against.
  | lesson_dtd | The DTD file, the lessons have to validate against.
Returns: A new lingConfig.

void ling_free | ( | void * | ptr | ) |

  | Frees the memory hold by a pointer, which was previously allocated using ling_malloc(). Parameters:
  | ptr | The pointer to free.

lingchar* ling_lang_get_lang_translation | ( | lingConfig * | settings,
|  | lingchar * | language,
|  | lingchar * | translation
| ) |

  | Gets the translation of a language (based on the language file set in the lingConfig). The return value should be freed using ling_free(). Parameters:
  | settings | The lingConfig to use for looking up the languages.
  | language | The language to translate.
  | translation | The language, in which the translation should be returned.
Returns: A language translation or NULL, if none found or an error occured.

lingchar** ling_lang_get_lang_translations | ( | lingConfig * | settings,
|  | lingchar ** | languages,
|  | lingchar * | translation
| ) |

  | Gets a list of translations of a passed language list (based on the language file set in the lingConfig). The return value should be freed using ling_strings_free(). Parameters:
  | settings | The lingConfig to use for looking up the languages.
  | languages | The language list to translate.
  | translation | The language, in which the translation should be returned.
Returns: A NULL terminated list of language translations.

int ling_lang_get_language_amount | ( | lingConfig * | settings | ) |

  | Gets the amount of languages contained in a lingConfig. Parameters:
  | settings | The lingConfig to use for looking up the languages.
Returns: The total amount of languages or -1 on failure.

lingchar** ling_lang_get_languages | ( | lingConfig * | settings | ) |

  | Gets a NULL terminated list of the available languages (based on the language file set in the lingConfig). The return value should be freed using ling_strings_free(). Parameters:
  | settings | The lingConfig to use for looking up the languages.
Returns: A NULL terminated list of the languages.

lingchar* ling_lang_get_trans_language | ( | lingConfig * | settings,
|  | lingchar * | translation,
|  | lingchar * | language
| ) |

  | Gets the language id of a translated language (based on the file set in the lingConfig). The return value should be freed using ling_free(). Parameters:
  | settings | The lingConfig to use for looking up the languages.
  | translation | The translated language.
  | language | The language which was used for the translation.
Returns: A language id or NULL, if none found or an error occured.

lingLesson* ling_lesson_add | ( | lingLesson * | list,
|  | lingLesson * | lesson
| ) |

  | Adds a lingLesson to a list of lingLessons. Parameters:
  | list | The lesson list, the new lesson should be added to.
  | lesson | The lesson to add.
Returns: The modified list.

lingLesson* ling_lesson_create | ( | char * | filename,
|  | lingConfig * | settings
| ) |

  | Creates a lingLesson from a lesson file. Parameters:
  | filename | The full qualified path of the file.
  | settings | The settings to use for the lesson.
Returns: A new lingLesson.

char* ling_lesson_create_template | ( | char * | filename,
|  | int | meanings,
|  | lingConfig * | settings
| ) |

  | Creates a new template lesson with optional empty meanings. The function uses the application name specified in the settings as DTD indentifier. Parameters:
  | filename | The lesson file to create.
  | meanings | The amount of meaning templates to create.
  | settings | The settings to use.
Returns: The filename on success or NULL in case of an error.

lingMeaning* ling_lesson_create_tree | ( | lingLesson * | lesson | ) |

  | Creates a linked list of all meanings, which are available in the given lesson. Parameters:
  | lesson | The lesson, for which the meaning tree should be created.
Returns: A linked list of meanings of the lesson or NULL if an error occurs.

void ling_lesson_free | ( | lingLesson * | lesson | ) |

  | Frees the memory hold by a lingLesson. Parameters:
  | lesson | The lingLesson to free.

int ling_lesson_get_last_meaning_id | ( | lingLesson * | lesson | ) |

  | Returns the last meaning id of the given lesson. Parameters:
  | lesson | The lesson, for which the last meaning id should be returned.
Returns: The last meaning id of the lesson or -1 on failure.

int ling_lesson_get_meaning_amount | ( | lingLesson * | lesson | ) |

  | Returns the total amount of meanings for the given lesson. Parameters:
  | lesson | The lesson, the amount should be got for.
Returns: The total amount of meanings or -1 on failure.

char* ling_lesson_get_path | ( | lingLesson * | lesson | ) |

  | Returns the full qualified file path of the lesson. Parameters:
  | lesson | The lesson for which the path should be returned.
Returns: The lesson path of the lesson.

int ling_lesson_get_translation_amount | ( | lingLesson * | lesson | ) |

  | Returns the total amount of translations for the given lesson. Parameters:
  | lesson | The lesson, the amount should be got for.
Returns: The total amount of translations or -1 on failure.

lingLesson* ling_lesson_new | ( | void |  | ) |

| Creates a new, empty lingLesson. The lingLesson should be freed using ling_lesson_free(). Returns: A new, empty lingLesson.

lingLesson* ling_lesson_remove | ( | lingLesson * | lesson,
|  | lingLesson * | node
| ) |

  | Removes a lesson from a lingLesson list and frees it. Parameters:
  | lesson | The lesson list to the lesson should be removed from.
  | node | The lesson to remove.
Returns: The modified lesson list.

lingbool ling_lesson_save_lesson | ( | lingLesson * | lesson,
|  | char * | filename
| ) |

  | Saves a lesson into the passed file. If the file does not exist, it will be automatically created, else its contents will be completely overwritten. Parameters:
  | lesson | The lesson to save.
  | filename | The file to save the lesson to.
Returns: TRUE, if the lesson could be saved, else FALSE.

char* ling_lesson_set_path | ( | lingLesson * | lesson,
|  | char * | path
| ) |

  | Sets the full qualified file path of the lesson to path and returns it. The return value must not be freed. Parameters:
  | lesson | The lesson for which the path should be set.
  | path | The path to set.
Returns: The new path of the lesson or NULL on error.

void* ling_malloc | ( | size_t | size | ) |

  | Allocates a chunk of memory for usage. Parameters:
  | size | The amount of bytes to allocate.
Returns: A pointer to the newly allocated space.

lingMeaning* ling_meaning_add | ( | lingMeaning * | tree,
|  | lingMeaning * | meaning
| ) |

  | Adds a new meaning at the end of the given meaning list. Parameters:
  | tree | The meaning list to which the meaning should be added or NULL to start a new list.
  | meaning | The meaning to add to the tree.
Returns: The new, modified meaning tree.

lingLesson* ling_meaning_create_lesson | ( | lingMeaning * | meaning,
|  | lingConfig * | settings,
|  | lingchar * | type,
|  | lingchar * | sound
| ) |

  | Creates a lingLesson from a list of meanings. The node format is the standard lingoteach lesson format. Parameters:
  | meaning | The list of meanings to put into the lingLesson.
  | settings | The settings to use for the lingLesson.
  | type | The type (name) of the lesson.
  | sound | The sound subdirectory parameter of the lesson.
Returns: the new lingLesson or NULL in case of an error.

void ling_meaning_free | ( | lingMeaning * | meaning | ) |

  | Frees the memory used by a list of lingMeaning and the lingMeanings itself. Parameters:
  | meaning | The meaning list to free.

lingMeaning* ling_meaning_free_1 | ( | lingMeaning * | tree,
|  | lingMeaning * | node
| ) |

  | Frees the memory used by a lingMeaning and the lingMeaning itself. Parameters:
  | tree | The list of meanings, in which the meanings is.
  | node | The meaning, which should be freed.
Returns: The new list without the freed meaning.

lingMeaning* ling_meaning_get_by_id | ( | lingLesson * | lesson,
|  | unsigned int | id,
|  | lingchar * | language
| ) |

  | Gets a specific lingMeaning from the given lesson. The lingMeaning has to be freed by the user. Parameters:
  | lesson | The lesson to get the meaning from.
  | id | The id, which should be searched for.
  | language | The language, which should be used.
Returns: a lingMeaning containing the meaning, which has the given id. If none is found with the given language, the function returns NULL.

lingchar* ling_meaning_get_description | ( | lingMeaning * | meaning | ) |

  | Retrieves the additional description for a specific meaning. The return value has to be freed by the user using ling_free(). Parameters:
  | meaning | The meaning to retrieve the description for.
Returns: The description of the meaning in the given language.

lingchar** ling_meaning_get_images | ( | lingMeaning * | meaning | ) |

  | Returns the path to the images for the given meaning. The result has to be freed by the user using ling_strings_free(). Parameters:
  | meaning | The lingMeaning the images have to be found for.
Returns: A NULL-terminated array containing the full qualified paths of the images for that meaning.

lingMInfo* ling_meaning_get_information | ( | lingMeaning * | meaning | ) |

  | Retrieves additional information of a meaning and returns them. It also fills the info member of the meaning with the return value. Note: If you free the meaning, the lingMInfo return value will be freed, too! Parameters:
  | meaning | The meaning, the information should be retrieved for.
Returns: A lingMInfo with information about the meaning.

lingchar* ling_meaning_get_phonetic | ( | lingMeaning * | meaning | ) |

  | Retrieves the phonetic transcription for the meaning. The return value has to be freed by the user using ling_free(). Parameters:
  | meaning | The meaning to retrieve the phonetic transcription for.
Returns: The phonetic transcription of a meaning translation.

lingchar* ling_meaning_get_sound | ( | lingMeaning * | meaning | ) |

  | Returns the path to the sound snippet for the given meaning. The result has to be freed by the user. Parameters:
  | meaning | The lingMeaning the sound snippet has to be found for.
Returns: The relative path to the sound snippet of the meaning.

void ling_meaning_info_free | ( | lingMInfo * | info | ) |

  | Frees the memory used by a lingMInfo and the lingMInfo itself. Parameters:
  | info | The lingMInfo to free,

lingMInfo* ling_meaning_info_new | ( | void |  | ) |

| Creates a new lingMInfo and returns it. The lingMInfo has to be freed by the user. Returns: A new, empty lingMinfo.

lingMeaning* ling_meaning_insert_after | ( | lingMeaning * | tree,
|  | lingMeaning * | parent,
|  | lingMeaning * | child
| ) |

  | Inserts a meaning after specific meaning into a meaning list. Parameters:
  | tree | The meaning list to which the meaning should be added.
  | parent | The parent meaning, after which the child should be added.
  | child | The meaning to add.
Returns: The new, modified tree.

lingMeaning* ling_meaning_new | ( | void |  | ) |

| Creates a new lingMeaning and returns it. The lingMeaning has to be freed by the user. Returns: A new, empty lingMeaning.

lingMeaning* ling_meaning_replace | ( | lingMeaning * | tree,
|  | unsigned int | id,
|  | lingMeaning * | meaning
| ) |

  | Replaces a meaning in the given list of meanings. Parameters:
  | tree | The list of meanings in which the meaning exists.
  | id | The id of the meaning, which should be replaced.
  | meaning | The meaning to use as replacement.
Returns: The tree with the replaced meaning or NULL in case of an error.

void ling_strings_free | ( | lingchar ** | array | ) |

  | Frees an array of strings, which was previously allocated by the libraray. Parameters:
  | array | The string array to free.