MCPcopy Create free account
hub / github.com/JHRobotics/softgpu / iniLoad

Function iniLoad

winini.c:67–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67BOOL iniLoad(const char *filename)
68{
69 size_t pos = 0;
70 char c;
71 DWORD readed;
72
73 HANDLE file = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
74
75 if(file == INVALID_HANDLE_VALUE)
76 {
77 return FALSE;
78 }
79
80 do
81 {
82 readed = 0;
83 if(ReadFile(file, &c, 1, &readed, NULL))
84 {
85 if(readed == 1)
86 {
87 if(pos == 0)
88 {
89 switch(c)
90 {
91 case '\n':
92 case '\r':
93 case ' ':
94 case '\t':
95 continue; /* garbage on line begin */
96 }
97 }
98
99 if(c == '\n')
100 {
101 linebuf[pos] = '\0';
102 lineadd(pos);
103 pos = 0;
104 }
105 else
106 {
107 if(pos < MAX_LINE)
108 {
109 linebuf[pos++] = c;
110 }
111 }
112
113 continue;
114 } // readed 1
115 }
116
117 if(pos > 0)
118 {
119 linebuf[pos] = '\0';
120 lineadd(pos);
121 }
122 } while(readed > 0);
123
124 return (ini != NULL);

Callers 1

mainFunction · 0.85

Calls 1

lineaddFunction · 0.85

Tested by

no test coverage detected