lists.cpp 1.8 KB

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