aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ini.h
blob: 6ae0bde5aa71dd0382d4badf6ca9bf128779633b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  /********************************************************************\
  * BitlBee -- An IRC to other IM-networks gateway                     *
  *                                                                    *
  * Copyright 2002-2004 Wilmer van der Gaast and others                *
  \********************************************************************/

/* INI file reading code						*/

/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License with
  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef _INI_H
#define _INI_H

typedef struct
{
	int line;
	char *c_section;
	char *section;
	char *key;
	char *value;
	int size;
	char *cur, *tok;
	char file[];
} ini_t;

ini_t *ini_open( char *file );
int ini_read( ini_t *file );
void ini_close( ini_t *file );

#endif
>"thisisaveryveryveryveryl", "test", "test123", "_123test", "_123", NULL }; for (i = 0; get[i]; i++) { char copy[60]; strcpy(copy, get[i]); nick_strip(NULL, copy); fail_unless(strcmp(copy, expected[i]) == 0, "(%d) nick_strip broken: %s -> %s (expected: %s)", i, get[i], copy, expected[i]); } } END_TEST START_TEST(test_nick_ok_ok) { const char *nicks[] = { "foo", "bar123", "bla[", "blie]", "BreEZaH", "\\od^~", "_123", "_123test", NULL }; int i; for (i = 0; nicks[i]; i++) { fail_unless(nick_ok(NULL, nicks[i]) == 1, "nick_ok() failed: %s", nicks[i]); } } END_TEST START_TEST(test_nick_ok_notok) { const char *nicks[] = { "thisisaveryveryveryveryveryveryverylongnick", "\nillegalchar", "", "nick%", "123test", NULL }; int i; for (i = 0; nicks[i]; i++) { fail_unless(nick_ok(NULL, nicks[i]) == 0, "nick_ok() succeeded for invalid: %s", nicks[i]); } } END_TEST Suite *nick_suite(void) { Suite *s = suite_create("Nick"); TCase *tc_core = tcase_create("Core"); suite_add_tcase(s, tc_core); tcase_add_test(tc_core, test_nick_ok_ok); tcase_add_test(tc_core, test_nick_ok_notok); tcase_add_test(tc_core, test_nick_strip); return s; }