+bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table)
+{
+ if (!table)
+ table = wxDefaultResourceTable;
+
+ // static or #define
+ if (!wxGetResourceToken(fd))
+ {
+ *eof = TRUE;
+ return FALSE;
+ }
+
+ if (strcmp(wxResourceBuffer, "#define") == 0)
+ {
+ wxGetResourceToken(fd);
+ char *name = copystring(wxResourceBuffer);
+ wxGetResourceToken(fd);
+ char *value = copystring(wxResourceBuffer);
+ if (isalpha(value[0]))
+ {
+ int val = (int)atol(value);
+ wxResourceAddIdentifier(name, val, table);
+ }
+ else
+ {
+ wxLogWarning(_("#define %s must be an integer."), name);
+ delete[] name;
+ delete[] value;
+ return FALSE;
+ }
+ delete[] name;
+ delete[] value;
+
+ return TRUE;
+ }
+ else if (strcmp(wxResourceBuffer, "#include") == 0)
+ {
+ wxGetResourceToken(fd);
+ char *name = copystring(wxResourceBuffer);
+ char *actualName = name;
+ if (name[0] == '"')
+ actualName = name + 1;
+ int len = strlen(name);
+ if ((len > 0) && (name[len-1] == '"'))
+ name[len-1] = 0;
+ if (!wxResourceParseIncludeFile(actualName, table))
+ {
+ wxLogWarning(_("Could not find resource include file %s."), actualName);
+ }
+ delete[] name;
+ return TRUE;
+ }
+ else if (strcmp(wxResourceBuffer, "static") != 0)
+ {
+ char buf[300];
+ strcpy(buf, _("Found "));
+ strncat(buf, wxResourceBuffer, 30);
+ strcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
+ wxLogWarning(buf);
+ return FALSE;
+ }
+
+ // char
+ if (!wxGetResourceToken(fd))
+ {
+ wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ *eof = TRUE;
+ return FALSE;
+ }
+
+ if (strcmp(wxResourceBuffer, "char") != 0)
+ {
+ wxLogWarning(_("Expected 'char' whilst parsing resource."));
+ return FALSE;
+ }
+
+ // *name
+ if (!wxGetResourceToken(fd))
+ {
+ wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ *eof = TRUE;
+ return FALSE;
+ }
+
+ if (wxResourceBuffer[0] != '*')
+ {
+ wxLogWarning(_("Expected '*' whilst parsing resource."));
+ return FALSE;
+ }
+ char nameBuf[100];
+ strncpy(nameBuf, wxResourceBuffer+1, 99);
+
+ // =
+ if (!wxGetResourceToken(fd))
+ {
+ wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ *eof = TRUE;
+ return FALSE;
+ }
+
+ if (strcmp(wxResourceBuffer, "=") != 0)
+ {
+ wxLogWarning(_("Expected '=' whilst parsing resource."));
+ return FALSE;
+ }
+
+ // String
+ if (!wxGetResourceToken(fd))
+ {
+ wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ *eof = TRUE;
+ return FALSE;
+ }
+ else
+ {
+ if (!db.ReadPrologFromString(wxResourceBuffer))
+ {
+ wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf);
+ return FALSE;
+ }
+ }
+ // Semicolon
+ if (!wxGetResourceToken(fd))
+ {
+ *eof = TRUE;
+ }
+ return TRUE;
+}
+