Example #1
0
struct tankdef
readTankFromDir(char* path) {
  DIR* dp;
  if( (dp=opendir(path))==NULL ) {
    perror(path);
    exit(1);
  }

  struct tankdef theTank;
  initTank(&theTank);
  struct dirent* files;
  while( (files=readdir(dp)) != NULL ) {
    if( isNotRealDir(files) ) {
      continue;
    }
    char file[1000];
    sprintf(file, "%s/%s", path, files->d_name);
    if( isSensor(files->d_name) ) {
      int sensorId = files->d_name[strlen("sensor")]-'0';
      theTank.sensors[sensorId] = parseSensor(file);
    } else if( strcmp(files->d_name, "name") == MATCH ) {
      loadFileContent( theTank.name, file, max_size(NAME) );
    } else if( strcmp(files->d_name, "author") == MATCH ) {
      loadFileContent( theTank.author, file, max_size(AUTHOR) );
    } else if( strcmp(files->d_name, "program") == MATCH ) {
      loadFileContent( theTank.program, file, max_size(PROGRAM) );
    } else if( strcmp(files->d_name, "color") == MATCH ) {
      loadFileContent( theTank.color, file, max_size(COLOR) );
    }
  }
  closedir(dp);
  return theTank;
}
Example #2
0
static int  parseZigbee(Resolver * const me, xmlNodePtr cur)
{
        int ZigbeeNUM = getZigbeeMac(me, cur);
        parseSensor(me, cur, ZigbeeNUM);

        return 0;
}