Start to abstract model

This commit is contained in:
Will 2013-12-05 16:17:41 +01:00
parent bf1c7df8bb
commit 6afadafa1e
22 changed files with 123 additions and 126 deletions

View File

@ -1280,9 +1280,8 @@ void MainWindow::loadModel(string path) {
if(timer) timer->Stop(); if(timer) timer->Stop();
delete model; delete model;
Model *tmpModel= new ModelGl(); model = NULL;
if(renderer) renderer->loadTheModel(tmpModel, modelPath); model = renderer? renderer->newModel(rsGlobal, modelPath): NULL;
model= tmpModel;
statusbarText = getModelInfo(); statusbarText = getModelInfo();
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY); string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY);

View File

@ -196,9 +196,8 @@ Texture2D * Renderer::getNewTexture2D() {
return newTexture; return newTexture;
} }
Model * Renderer::getNewModel() { Model * Renderer::newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) {
Model *newModel = modelManager->newModel(); return modelManager->newModel(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
return newModel;
} }
void Renderer::init() { void Renderer::init() {
@ -416,13 +415,6 @@ void Renderer::toggleGrid() {
grid= grid? false: true; grid= grid? false: true;
} }
void Renderer::loadTheModel(Model *model, string file) {
model->setTextureManager(textureManager);
model->loadG3d(file);
textureManager->init();
modelManager->init();
}
void Renderer::renderTheModel(Model *model, float f) { void Renderer::renderTheModel(Model *model, float f) {
if(model != NULL){ if(model != NULL){
modelRenderer->begin(true, true, !wireframe, false, &meshCallbackTeamColor); modelRenderer->begin(true, true, !wireframe, false, &meshCallbackTeamColor);

View File

@ -137,7 +137,6 @@ public:
void toggleWireframe(); void toggleWireframe();
void toggleGrid(); void toggleGrid();
void loadTheModel(Model *model, string file);
void renderTheModel(Model *model, float f); void renderTheModel(Model *model, float f);
void manageParticleSystem(ParticleSystem *particleSystem); void manageParticleSystem(ParticleSystem *particleSystem);
@ -146,9 +145,8 @@ public:
Texture2D *getPlayerColorTexture(PlayerColor playerColor); Texture2D *getPlayerColorTexture(PlayerColor playerColor);
Texture2D * getNewTexture2D(); Texture2D * getNewTexture2D();
Model * getNewModel();
Model *newModel(ResourceScope rs) { return getNewModel(); } Model *newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL);
Texture2D *newTexture2D(ResourceScope rs) { return getNewTexture2D(); } Texture2D *newTexture2D(ResourceScope rs) { return getNewTexture2D(); }
void initTextureManager(); void initTextureManager();

View File

@ -170,10 +170,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
endPathWithSlash(currentPath); endPathWithSlash(currentPath);
string path= modelNode->getAttribute("path")->getRestrictedValue(currentPath); string path= modelNode->getAttribute("path")->getRestrictedValue(currentPath);
model= renderer->newModel(rsGame); model= renderer->newModel(rsGame,path, false, &loadedFileList, &parentLoader);
if(model) {
model->load(path, false, &loadedFileList, &parentLoader);
}
loadedFileList[path].push_back(make_pair(parentLoader,modelNode->getAttribute("path")->getRestrictedValue())); loadedFileList[path].push_back(make_pair(parentLoader,modelNode->getAttribute("path")->getRestrictedValue()));
if(modelNode->hasChild("cycles")) { if(modelNode->hasChild("cycles")) {

View File

@ -598,12 +598,10 @@ void Renderer::manageDeferredParticleSystems() {
if(dynamic_cast<GameParticleSystem *>(ps) != NULL) { if(dynamic_cast<GameParticleSystem *>(ps) != NULL) {
GameParticleSystem *gps = dynamic_cast<GameParticleSystem *>(ps); GameParticleSystem *gps = dynamic_cast<GameParticleSystem *>(ps);
if(gps->getModelFileLoadDeferred() != "" && gps->getModel() == NULL) { if(gps->getModelFileLoadDeferred() != "" && gps->getModel() == NULL) {
Model *model= newModel(rsGame); std::map<string,vector<pair<string, string> > > loadedFileList;
if(model) { Model *model= newModel(rsGame, gps->getModelFileLoadDeferred(), false, &loadedFileList, NULL);
std::map<string,vector<pair<string, string> > > loadedFileList; if(model)
model->load(gps->getModelFileLoadDeferred(), false, &loadedFileList, NULL); gps->setModel(model);
gps->setModel(model);
}
} }
} }
manageParticleSystem(ps, rs); manageParticleSystem(ps, rs);
@ -886,12 +884,12 @@ void Renderer::endLastTexture(ResourceScope rs, bool mustExistInList) {
textureManager[rs]->endLastTexture(mustExistInList); textureManager[rs]->endLastTexture(mustExistInList);
} }
Model *Renderer::newModel(ResourceScope rs){ Model *Renderer::newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader){
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
return NULL; return NULL;
} }
return modelManager[rs]->newModel(); return modelManager[rs]->newModel(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
} }
void Renderer::endModel(ResourceScope rs, Model *model,bool mustExistInList) { void Renderer::endModel(ResourceScope rs, Model *model,bool mustExistInList) {

View File

@ -458,7 +458,7 @@ public:
void endTexture(ResourceScope rs, Texture *texture,bool mustExistInList=false); void endTexture(ResourceScope rs, Texture *texture,bool mustExistInList=false);
void endLastTexture(ResourceScope rs, bool mustExistInList=false); void endLastTexture(ResourceScope rs, bool mustExistInList=false);
Model *newModel(ResourceScope rs); Model *newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL);
void endModel(ResourceScope rs, Model *model, bool mustExistInList=false); void endModel(ResourceScope rs, Model *model, bool mustExistInList=false);
void endLastModel(ResourceScope rs, bool mustExistInList=false); void endLastModel(ResourceScope rs, bool mustExistInList=false);

View File

@ -208,10 +208,9 @@ Intro::Intro(Program *program):
findAll(introPath, introModels, false, false); findAll(introPath, introModels, false, false);
for(int i = 0; i < (int)introModels.size(); ++i) { for(int i = 0; i < (int)introModels.size(); ++i) {
string logo = introModels[i]; string logo = introModels[i];
Model *model= renderer.newModel(rsMenu); Model *model= renderer.newModel(rsMenu, getGameCustomCoreDataPath(data_path, "") + "data/core/menu/main_model/" + logo);
if(model) { if(model) {
model->load(getGameCustomCoreDataPath(data_path, "") + "data/core/menu/main_model/" + logo); models.push_back(model);
models.push_back(model);
//printf("#1 Intro model [%s]\n",model->getFileName().c_str()); //printf("#1 Intro model [%s]\n",model->getFileName().c_str());
} }
} }
@ -222,9 +221,8 @@ Intro::Intro(Program *program):
findAll(introPath, introModels, false, false); findAll(introPath, introModels, false, false);
for(int i = 0; i < (int)introModels.size(); ++i) { for(int i = 0; i < (int)introModels.size(); ++i) {
string logo = introModels[i]; string logo = introModels[i];
Model *model= renderer.newModel(rsMenu); Model *model= renderer.newModel(rsMenu, data_path + "data/core/menu/main_model/" + logo);
if(model) { if(model) {
model->load(data_path + "data/core/menu/main_model/" + logo);
models.push_back(model); models.push_back(model);
//printf("#2 Intro model [%s]\n",model->getFileName().c_str()); //printf("#2 Intro model [%s]\n",model->getFileName().c_str());
} }

View File

@ -5160,8 +5160,7 @@ int glestMain(int argc, char** argv) {
char szTextBuf[8096]=""; char szTextBuf[8096]="";
for(unsigned int i =0; i < models.size(); ++i) { for(unsigned int i =0; i < models.size(); ++i) {
string &file = models[i]; string &file = models[i];
bool modelLoadedOk = false;
renderer.clearBuffers(); renderer.clearBuffers();
renderer.clearZBuffer(); renderer.clearZBuffer();
renderer.reset2d(); renderer.reset2d();
@ -5187,23 +5186,18 @@ int glestMain(int argc, char** argv) {
::Shared::Platform::Window::handleEvent(); ::Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
Model *model = renderer.newModel(rsGlobal);
try { try {
printf("About to load model [%s] [%u of " MG_SIZE_T_SPECIFIER "]\n",file.c_str(),i,models.size()); printf("About to load model [%s] [%u of " MG_SIZE_T_SPECIFIER "]\n",file.c_str(),i,models.size());
model->load(file); Model *model = renderer.newModel(rsGlobal, file);
modelLoadedOk = true; printf("About to save converted model [%s]\n",file.c_str());
model->save(file,textureFormat,keepsmallest);
Renderer::getInstance().endModel(rsGlobal, model);
} }
catch(const exception &ex) { catch(const exception &ex) {
result = 1; result = 1;
printf("ERROR loading model [%s] message [%s]\n",file.c_str(),ex.what()); printf("ERROR loading model [%s] message [%s]\n",file.c_str(),ex.what());
} }
if(modelLoadedOk == true) {
printf("About to save converted model [%s]\n",file.c_str());
model->save(file,textureFormat,keepsmallest);
}
Renderer::getInstance().endModel(rsGlobal, model);
} }
delete mainWindow; delete mainWindow;

View File

@ -98,23 +98,17 @@ MenuBackground::MenuBackground() : rps(NULL) {
degToRad(startRotation.z)))); degToRad(startRotation.z))));
//load main model //load main model
mainModel= renderer.newModel(rsMenu); string mainModelFile = "data/core/menu/main_model/menu_main.g3d";
if(mainModel) { if(menuNode->hasChild("menu-background-model") == true) {
string mainModelFile = "data/core/menu/main_model/menu_main.g3d"; //mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
if(menuNode->hasChild("menu-background-model") == true) { const XmlNode *mainMenuModelNode= menuNode->getChild("menu-background-model");
//mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d"); mainModelFile = mainMenuModelNode->getAttribute("value")->getRestrictedValue();
const XmlNode *mainMenuModelNode= menuNode->getChild("menu-background-model"); }
mainModelFile = mainMenuModelNode->getAttribute("value")->getRestrictedValue(); mainModel = renderer.newModel(rsMenu, getGameCustomCoreDataPath(data_path, mainModelFile));
}
mainModel->load(getGameCustomCoreDataPath(data_path, mainModelFile));
}
//models //models
for(int i=0; i<5; ++i){ for(int i=0; i<5; ++i) {
characterModels[i]= renderer.newModel(rsMenu); characterModels[i] = renderer.newModel(rsMenu, getGameCustomCoreDataPath(data_path, "data/core/menu/about_models/character"+intToStr(i)+".g3d"));
if(characterModels[i]) {
characterModels[i]->load(getGameCustomCoreDataPath(data_path, "data/core/menu/about_models/character"+intToStr(i)+".g3d"));
}
} }
//about position //about position

View File

@ -37,10 +37,7 @@ ObjectType::~ObjectType(){
TilesetModelType* ObjectType::loadModel(const string &path, std::map<string,vector<pair<string, string> > > *loadedFileList, TilesetModelType* ObjectType::loadModel(const string &path, std::map<string,vector<pair<string, string> > > *loadedFileList,
string parentLoader) { string parentLoader) {
Model *model= Renderer::getInstance().newModel(rsGame); Model *model= Renderer::getInstance().newModel(rsGame, path, false, loadedFileList, &parentLoader);
if(model) {
model->load(path, false, loadedFileList, &parentLoader);
}
color= Vec3f(0.f); color= Vec3f(0.f);
if(model && model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) { if(model && model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) {
const Pixmap2D *p= model->getMesh(0)->getTexture(0)->getPixmapConst(); const Pixmap2D *p= model->getMesh(0)->getTexture(0)->getPixmapConst();

View File

@ -110,10 +110,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
const XmlNode *modelNode= typeNode->getChild("model"); const XmlNode *modelNode= typeNode->getChild("model");
string modelPath= modelNode->getAttribute("path")->getRestrictedValue(currentPath); string modelPath= modelNode->getAttribute("path")->getRestrictedValue(currentPath);
model= renderer.newModel(rsGame); model= renderer.newModel(rsGame, modelPath, false, &loadedFileList, &sourceXMLFile);
if(model) {
model->load(modelPath, false, &loadedFileList, &sourceXMLFile);
}
loadedFileList[modelPath].push_back(make_pair(sourceXMLFile,modelNode->getAttribute("path")->getRestrictedValue())); loadedFileList[modelPath].push_back(make_pair(sourceXMLFile,modelNode->getAttribute("path")->getRestrictedValue()));
if(modelNode->hasChild("particles")){ if(modelNode->hasChild("particles")){

View File

@ -419,10 +419,7 @@ void SkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
for(unsigned int i = 0; i < animationList.size(); ++i) { for(unsigned int i = 0; i < animationList.size(); ++i) {
string path= animationList[i]->getAttribute("path")->getRestrictedValue(currentPath); string path= animationList[i]->getAttribute("path")->getRestrictedValue(currentPath);
if(fileExists(path) == true) { if(fileExists(path) == true) {
Model *animation= Renderer::getInstance().newModel(rsGame); Model *animation= Renderer::getInstance().newModel(rsGame, path, false, &loadedFileList, &parentLoader);
if(animation) {
animation->load(path, false, &loadedFileList, &parentLoader);
}
loadedFileList[path].push_back(make_pair(parentLoader,animationList[i]->getAttribute("path")->getRestrictedValue())); loadedFileList[path].push_back(make_pair(parentLoader,animationList[i]->getAttribute("path")->getRestrictedValue()));
animations.push_back(animation); animations.push_back(animation);

View File

@ -33,7 +33,7 @@ public:
virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();} virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();}
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();} virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
virtual Context *newContext() {return new ContextGl();} virtual Context *newContext() {return new ContextGl();}
virtual Model *newModel() {return new ModelGl();} virtual Model *newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) { return new ModelGl(path,deletePixMapAfterLoad,loadedFileList,sourceLoader); }
virtual Texture2D *newTexture2D() {return new Texture2DGl();} virtual Texture2D *newTexture2D() {return new Texture2DGl();}
virtual Font2D *newFont2D() {return new Font2DGl();} virtual Font2D *newFont2D() {return new Font2DGl();}
virtual Font3D *newFont3D() {return new Font3DGl();} virtual Font3D *newFont3D() {return new Font3DGl();}

View File

@ -47,7 +47,7 @@ public:
//models //models
virtual ModelManager *newModelManager() {return new ModelManager();} virtual ModelManager *newModelManager() {return new ModelManager();}
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();} virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
virtual Model *newModel() {return new ModelGl();} virtual Model *newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) { return new ModelGl(path,deletePixMapAfterLoad,loadedFileList,sourceLoader); }
//text //text
virtual FontManager *newFontManager() {return new FontManager();} virtual FontManager *newFontManager() {return new FontManager();}

View File

@ -22,6 +22,9 @@ namespace Shared{ namespace Graphics{ namespace Gl{
// ===================================================== // =====================================================
class ModelGl: public Model{ class ModelGl: public Model{
friend class GraphicsFactoryGl;
protected:
ModelGl(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader);
public: public:
virtual void init(){} virtual void init(){}
virtual void end(){} virtual void end(){}

View File

@ -13,6 +13,11 @@
#define _SHARED_GRAPHICS_GRAPHICSFACTORY_H_ #define _SHARED_GRAPHICS_GRAPHICSFACTORY_H_
#include <cstdlib> #include <cstdlib>
#include <string>
#include <map>
#include <vector>
using std::string;
#include "leak_dumper.h" #include "leak_dumper.h"
namespace Shared{ namespace Graphics{ namespace Shared{ namespace Graphics{
@ -64,7 +69,7 @@ public:
//models //models
virtual ModelManager *newModelManager() {return NULL;} virtual ModelManager *newModelManager() {return NULL;}
virtual ModelRenderer *newModelRenderer() {return NULL;} virtual ModelRenderer *newModelRenderer() {return NULL;}
virtual Model *newModel() {return NULL;} virtual Model *newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,std::vector<std::pair<string, string> > > *loadedFileList, string *sourceLoader) {return NULL;}
//text //text
virtual FontManager *newFontManager() {return NULL;} virtual FontManager *newFontManager() {return NULL;}

View File

@ -35,7 +35,7 @@ enum ResourceScope {
class RendererInterface { class RendererInterface {
public: public:
virtual Texture2D *newTexture2D(ResourceScope rs) = 0; virtual Texture2D *newTexture2D(ResourceScope rs) = 0;
virtual Model *newModel(ResourceScope rs) = 0; virtual Model *newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL) = 0;
virtual ~RendererInterface() {} virtual ~RendererInterface() {}
}; };

View File

@ -221,9 +221,7 @@ public:
uint32 getVertexCount() const; uint32 getVertexCount() const;
//io //io
void load(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL);
void save(const string &path, string convertTextureToFormat,bool keepsmallest); void save(const string &path, string convertTextureToFormat,bool keepsmallest);
void loadG3d(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string sourceLoader="");
void saveG3d(const string &path, string convertTextureToFormat,bool keepsmallest); void saveG3d(const string &path, string convertTextureToFormat,bool keepsmallest);
void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;} void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;}
@ -234,6 +232,11 @@ public:
void toEndian(); void toEndian();
void fromEndian(); void fromEndian();
protected:
void load(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL);
void loadG3d(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string sourceLoader="");
private: private:
void buildInterpolationData() const; void buildInterpolationData() const;
void autoJoinMeshFrames(); void autoJoinMeshFrames();

View File

@ -38,7 +38,7 @@ public:
ModelManager(); ModelManager();
virtual ~ModelManager(); virtual ~ModelManager();
Model *newModel(); Model *newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader);
void init(); void init();
void end(); void end();

View File

@ -0,0 +1,20 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2008 Martiño Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#include "model_gl.h"
namespace Shared{ namespace Graphics{ namespace Gl{
ModelGl::ModelGl(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) {
load(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
}
}}}//end namespace

View File

@ -40,8 +40,8 @@ ModelManager::~ModelManager(){
end(); end();
} }
Model *ModelManager::newModel(){ Model *ModelManager::newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader){
Model *model= GraphicsInterface::getInstance().getFactory()->newModel(); Model *model= GraphicsInterface::getInstance().getFactory()->newModel(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
model->setTextureManager(textureManager); model->setTextureManager(textureManager);
models.push_back(model); models.push_back(model);
return model; return model;

View File

@ -121,55 +121,60 @@ static int getFileAndLine(char *function, void *address, char *file, size_t flen
// prepare command to be executed // prepare command to be executed
// our program need to be passed after the -e parameter // our program need to be passed after the -e parameter
#if __APPLE_CC__
snprintf(buf, 8096,"xcrun atos -v -o %s %p",PlatformExceptionHandler::application_binary.c_str(),address);
fprintf(stderr,"> %s\n",buf);
#else
snprintf(buf, 8096,"addr2line -C -e %s -f -i %p",PlatformExceptionHandler::application_binary.c_str(),address); snprintf(buf, 8096,"addr2line -C -e %s -f -i %p",PlatformExceptionHandler::application_binary.c_str(),address);
#endif
FILE* f = popen (buf, "r"); FILE* f = popen (buf, "r");
if (f == NULL) { if (f == NULL) {
perror (buf); perror (buf);
return 0; return 0;
} }
#if __APPLE_CC__
//### TODO Will: still working this out
int len = fread(buf,1,maxbufSize,f);
buf[len] = 0;
fprintf(stderr,"< %s",buf);
return -1;
#endif
for(;function != NULL && function[0] != '\0';) {
// get function name
char *ret = fgets (buf, maxbufSize, f);
if(ret == NULL) {
pclose(f);
return line;
}
//printf("Looking for [%s] Found [%s]\n",function,ret);
if(strstr(ret,function) != NULL) {
break;
}
// get file and line
ret = fgets (buf, maxbufSize, f);
if(ret == NULL) {
pclose(f);
return line;
}
if(function != NULL && function[0] != '\0') { if(strlen(buf) > 0 && buf[0] != '?') {
line = 0; //int l;
for(;function != NULL && function[0] != '\0';) { char *p = buf;
// get function name // file name is until ':'
char *ret = fgets (buf, maxbufSize, f); while(*p != 0 && *p != ':') {
if(ret == NULL) { p++;
pclose(f); }
return line;
}
//printf("Looking for [%s] Found [%s]\n",function,ret);
if(strstr(ret,function) != NULL) {
break;
}
// get file and line *p++ = 0;
ret = fgets (buf, maxbufSize, f); // after file name follows line number
if(ret == NULL) { strcpy (file , buf);
pclose(f); sscanf (p,"%10d", &line);
return line; }
} else {
strcpy (file,"unknown");
if(strlen(buf) > 0 && buf[0] != '?') { line = 0;
//int l; }
char *p = buf; }
// file name is until ':'
while(*p != 0 && *p != ':') {
p++;
}
*p++ = 0;
// after file name follows line number
strcpy (file , buf);
sscanf (p,"%10d", &line);
}
else {
strcpy (file,"unknown");
line = 0;
}
}
}
// get file and line // get file and line
char *ret = fgets (buf, maxbufSize, f); char *ret = fgets (buf, maxbufSize, f);