Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 18, 2005, 11:27:40 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/movie_player: merged the trunk back into the movie_player
merged with command:
svn merge -r 4014:HEAD ../trunk/ movie_player/
no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/movie_player/src/lib/util/ini_parser.cc

    r3484 r4217  
    1616
    1717#include "ini_parser.h"
     18#include "resource_manager.h"
    1819
    1920using namespace std;
    2021
    2122/**
    22         \brief constructs an IniParser using a file
    23         \param filename: the path and name of the file to parse
     23   \brief constructs an IniParser using a file
     24   \param filename: the path and name of the file to parse
    2425*/
    25 IniParser::IniParser (char* filename)
     26IniParser::IniParser (const char* filename)
    2627{
    2728  stream = NULL;
    2829  bInSection = false;
    29   openFile(filename);
     30  this->openFile(filename);
    3031}
    3132
    3233/**
    33         \brief removes the IniParser from memory
     34   \brief removes the IniParser from memory
    3435*/
    3536IniParser::~IniParser ()
     
    4344   \return zero on success or -1 if an error occured;
    4445*/
    45 int IniParser::openFile( char* filename)
     46int IniParser::openFile(const char* filename)
    4647{
     48  char* tmpName = ResourceManager::homeDirCheck(filename);
    4749  if( filename == NULL) return -1;
    4850  if( stream != NULL)   fclose (stream);
    49   if( (stream = fopen (filename, "r")) == NULL)
     51  if( (stream = fopen (tmpName, "r")) == NULL)
    5052    {
    51       printf("IniParser could not open %s\n", filename);
     53      PRINTF(1)("IniParser could not open %s\n", filename);
     54      delete tmpName;
    5255      return -1;
    5356    }
    5457  bInSection = false;
     58  delete tmpName;
    5559  return 0;
    5660}
     
    123127          return -1;
    124128        }
    125       if( (ptr = strchr( linebuffer, '=')) != NULL)
     129      sscanf(linebuffer, "%s = %s", name, value);
     130      return 0;
     131      /*
     132        if( (ptr = strchr( tmpBuffer, '=')) != NULL)
    126133        {
    127           if( ptr == linebuffer) continue;
    128           strcpy (value, &ptr[1]);
    129           strncpy (name, linebuffer, strlen (linebuffer) - strlen (value) - 1);
    130           return 0;
     134        if( ptr == linebuffer) continue;
     135        strcpy (value, &ptr[1]);
     136        strncpy (name, linebuffer, strlen (linebuffer) - strlen (value) - 1);
     137        printf ("%s, %s\n", value, name);
     138        return 0;
    131139        }
     140      */
    132141    }
    133142  return -1;   
     
    144153   lead to unwanted behaviour.
    145154*/
    146 char* IniParser::getVar( char* name, char* section, char* defvalue = "")
     155char* IniParser::getVar(const char* name, char* section, char* defvalue = "")
    147156{
    148157  strcpy (internbuf, defvalue);
Note: See TracChangeset for help on using the changeset viewer.