]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/bobtoolz/lists.cpp
fixed eol-style
[xonotic/netradiant.git] / contrib / bobtoolz / lists.cpp
1 /*
2 BobToolz plugin for GtkRadiant
3 Copyright (C) 2001 Gordon Biggans
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20 #include "StdAfx.h"
21
22 #ifdef WIN32
23 #pragma warning(disable : 4786)
24 #endif
25
26 #include "gtkr_list.h"
27 #include "str.h"
28
29 #include "lists.h"
30 #include "misc.h"
31
32 bool LoadExclusionList(char* filename, list<Str>* exclusionList)
33 {
34         FILE* eFile = fopen(filename, "r");
35         if(eFile)
36         {
37                 char buffer[256];
38                 int cnt = 0;
39                 while(!feof(eFile))
40                 {
41                         memset(buffer, 0, 256);
42                         fscanf(eFile, "%s\n", buffer);
43
44                         if(strlen(buffer) > 0)
45                                 exclusionList->push_back(buffer);
46                         else
47                                 cnt++;
48                 }
49
50                 fclose(eFile);
51
52                 return TRUE;
53         }
54
55         Sys_ERROR("Failed To Load Exclusion List: %s\n", filename);
56         return FALSE;
57 }
58
59 bool LoadGList(char* filename, GList** loadlist)
60 {
61         FILE* eFile = fopen(filename, "r");
62         if(eFile)
63         {
64                 char buffer[256];
65                 int cnt = 0;
66                 while(!feof(eFile))
67                 {
68                         memset(buffer, 0, 256);
69                         fscanf(eFile, "%s\n", buffer);
70
71                         if(strlen(buffer) > 0)
72                         {
73                                 char* buffer2 = new char[strlen(buffer) + 1];
74                                 strcpy(buffer2, buffer);
75                                 *loadlist = g_list_append(*loadlist, buffer2);
76                         }
77                         else
78                                 cnt++;
79                 }
80
81                 fclose(eFile);
82
83                 return TRUE;
84         }
85
86         Sys_ERROR("Failed To Load GList: %s\n", filename);
87         return FALSE;
88 }