/*----------------------------------------------------------------------------*- YAdmin system - INI Core Reads the INI and also exports a number of functions to other "classes" for easy reading of data files there Changelog: 24/03/07: First version. -*----------------------------------------------------------------------------*/ #define MAX_INI_TAG 16 /*----------------------------------------------------------------------------*- Function: INI_INI Params: - Return: - Notes: - -*----------------------------------------------------------------------------*/ stock INI_INI() {} /*----------------------------------------------------------------------------*- Function: INI_GetTagName Params: source - The string you want to get a tag from. dest - The place you want to store the tag to Return: bool: Found the tag correctly. Notes: - -*----------------------------------------------------------------------------*/ bool:INI_GetTagName(source[], dest[]) { if (source[0] != '[') return false; new len = chrfind(']', source); if (len == -1) return false; strcpy(dest, source[1], len - 1); return true; } /*----------------------------------------------------------------------------*- Function: INI_GetEntryName Params: source - The string you want to get an entry name from. dest - The place you want to store the entry name to Return: bool: Found the name correctly. Notes: - -*----------------------------------------------------------------------------*/ bool:INI_GetEntryName(source[], dest[]) { new i; while (source[i] > ' ' && source[i] != '=') i++; if (!i) return false; strcpy(dest, source, i); return true; } /*----------------------------------------------------------------------------*- Function: INI_GetEntryText Params: source - The string you want to get an entry from. dest - The place you want to store the entry to Return: bool: Found the entry correctly. Notes: - -*----------------------------------------------------------------------------*/ bool:INI_GetEntryText(source[], dest[]) { new i; while (source[i] > ' ' && source[i] != '=') i++; while (source[i] && (source[i] <= ' ' || source[i] == '=')) i++; if (!source[i]) return false; strcpy(dest, source[i], strlen(source) - i); return true; }