Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
readstrings.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  StringTable
 Provides a GC-able table of interned strings. More...

Defines

#define MAX_TEXT_LEN   200

Functions

int ReadStrings (const char *path, StringTable *results)
 This function reads in localized strings from updater.ini.

Define Documentation

#define MAX_TEXT_LEN   200

Definition at line 42 of file readstrings.h.


Function Documentation

int ReadStrings ( const char *  path,
StringTable results 
)

This function reads in localized strings from updater.ini.

Definition at line 57 of file readstrings.cpp.

{
  AutoFILE fp = fopen(path, "r");
  if (!fp)
    return READ_ERROR;

  // Trim leading junk -- this is a hack!
  if (!fgets(results->title, MAX_TEXT_LEN, fp))
    return READ_ERROR;
  if (!fgets(results->title, MAX_TEXT_LEN, fp))
    return READ_ERROR;

  // Now, read the values we care about.
  if (!fgets(results->title, MAX_TEXT_LEN, fp))
    return READ_ERROR;
  if (!fgets(results->info, MAX_TEXT_LEN, fp))
    return READ_ERROR;

  // Trim trailing newline character and leading 'key='
  char *strings[] = {
    results->title, results->info, NULL
  };
  for (char **p = strings; *p; ++p) {
    int len = strlen(*p);
    if (len)
      (*p)[len - 1] = '\0';

    char *eq = strchr(*p, '=');
    if (!eq)
      return PARSE_ERROR;
    memmove(*p, eq + 1, len - (eq - *p + 1));
  }

  return OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: