diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Makefile.am | 282 | ||||
-rw-r--r-- | src/tools/Makefile.am | 23 | ||||
-rw-r--r-- | src/tools/genrevision/Makefile.am | 35 | ||||
-rw-r--r-- | src/tools/genrevision/genrevision.cpp | 308 |
4 files changed, 372 insertions, 276 deletions
diff --git a/src/game/Makefile.am b/src/game/Makefile.am index 2aee7919cf0..2708d1d5651 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -9,35 +9,25 @@ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## Process this file with automake to produce Makefile.in ## Sub-directories to parse ## CPP flags for includes, defines, etc. -AM_CPPFLAGS = +AM_CPPFLAGS = $(TRINI_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir) -I$(srcdir)/../../dep/include -I$(srcdir)/../framework -I$(srcdir)/../shared -I$(srcdir)/../shared/vmap -I$(srcdir)/../realmd -DSYSCONFDIR=\"$(sysconfdir)/\" ## Build MaNGOS game library as convenience library. # All libraries will be convenience libraries. Might be changed to shared # later. -noinst_LIBRARIES = libgame.a +noinst_LIBRARIES = libmangosgame.a -<<<<<<< HEAD:src/game/Makefile.am -libgame_a_CPPFLAGS = \ -$(MYSQL_INCLUDES) \ -$(POSTGRE_INCLUDES) \ -$(TRINI_INCLUDES) \ --I$(top_srcdir)/dep/include \ --I$(top_srcdir)/src/framework \ --I$(top_srcdir)/src/shared \ --I$(top_srcdir)/src/shared/vmap -======= # libmangossgame library will later be reused by ... libmangosgame_a_SOURCES = \ AccountMgr.cpp \ @@ -288,269 +278,9 @@ libmangosgame_a_SOURCES = \ GroupReference.cpp \ GroupReference.h \ GroupRefManager.h ->>>>>>> upstream/master:src/game/Makefile.am -# libmangossgame library will later be reused by ... -libgame_a_SOURCES = \ -$(srcdir)/AccountMgr.cpp \ -$(srcdir)/AccountMgr.h \ -$(srcdir)/AddonHandler.cpp \ -$(srcdir)/AddonHandler.h \ -$(srcdir)/AggressorAI.cpp \ -$(srcdir)/AggressorAI.h \ -$(srcdir)/AnimalRandomMovementGenerator.h \ -$(srcdir)/ArenaTeam.cpp \ -$(srcdir)/ArenaTeam.h \ -$(srcdir)/ArenaTeamHandler.cpp \ -$(srcdir)/AuctionHouse.cpp \ -$(srcdir)/AuctionHouseObject.h \ -$(srcdir)/Bag.cpp \ -$(srcdir)/Bag.h \ -$(srcdir)/BattleGround.cpp \ -$(srcdir)/BattleGroundAA.cpp \ -$(srcdir)/BattleGroundAB.cpp \ -$(srcdir)/BattleGroundAV.cpp \ -$(srcdir)/BattleGroundBE.cpp \ -$(srcdir)/BattleGroundEY.cpp \ -$(srcdir)/BattleGroundNA.cpp \ -$(srcdir)/BattleGroundRL.cpp \ -$(srcdir)/BattleGroundWS.cpp \ -$(srcdir)/BattleGround.h \ -$(srcdir)/BattleGroundAA.h \ -$(srcdir)/BattleGroundAB.h \ -$(srcdir)/BattleGroundAV.h \ -$(srcdir)/BattleGroundBE.h \ -$(srcdir)/BattleGroundEY.h \ -$(srcdir)/BattleGroundNA.h \ -$(srcdir)/BattleGroundRL.h \ -$(srcdir)/BattleGroundWS.h \ -$(srcdir)/BattleGroundHandler.cpp \ -$(srcdir)/BattleGroundMgr.cpp \ -$(srcdir)/BattleGroundMgr.h \ -$(srcdir)/Cell.h \ -$(srcdir)/CellImpl.h \ -$(srcdir)/Channel.cpp \ -$(srcdir)/Channel.h \ -$(srcdir)/ChannelHandler.cpp \ -$(srcdir)/ChannelMgr.h \ -$(srcdir)/CharacterHandler.cpp \ -$(srcdir)/Chat.cpp \ -$(srcdir)/Chat.h \ -$(srcdir)/ChatHandler.cpp \ -$(srcdir)/CombatHandler.cpp \ -$(srcdir)/ConfusedMovementGenerator.cpp \ -$(srcdir)/ConfusedMovementGenerator.h \ -$(srcdir)/Corpse.cpp \ -$(srcdir)/Corpse.h \ -$(srcdir)/CreatureAI.cpp \ -$(srcdir)/CreatureAI.h \ -$(srcdir)/CreatureAIImpl.h \ -$(srcdir)/CreatureAIRegistry.cpp \ -$(srcdir)/CreatureAIRegistry.h \ -$(srcdir)/CreatureAISelector.cpp \ -$(srcdir)/CreatureAISelector.h \ -$(srcdir)/CreatureGroups.cpp \ -$(srcdir)/CreatureGroups.h \ -$(srcdir)/Creature.cpp \ -$(srcdir)/Creature.h \ -$(srcdir)/debugcmds.cpp \ -$(srcdir)/DestinationHolder.cpp \ -$(srcdir)/DestinationHolder.h \ -$(srcdir)/DestinationHolderImp.h \ -$(srcdir)/DuelHandler.cpp \ -$(srcdir)/DynamicObject.cpp \ -$(srcdir)/DynamicObject.h \ -$(srcdir)/FleeingMovementGenerator.cpp \ -$(srcdir)/FleeingMovementGenerator.h \ -$(srcdir)/Formulas.h \ -$(srcdir)/GameEvent.cpp \ -$(srcdir)/GameEvent.h \ -$(srcdir)/GameObject.cpp \ -$(srcdir)/GameObject.h \ -$(srcdir)/GlobalEvents.cpp \ -$(srcdir)/GlobalEvents.h \ -$(srcdir)/GMTicketHandler.cpp \ -$(srcdir)/GMTicketMgr.cpp \ -$(srcdir)/GMTicketMgr.h \ -$(srcdir)/GossipDef.cpp \ -$(srcdir)/GossipDef.h \ -$(srcdir)/GridDefines.h \ -$(srcdir)/GridNotifiers.cpp \ -$(srcdir)/GridNotifiers.h \ -$(srcdir)/GridNotifiersImpl.h \ -$(srcdir)/GridStates.cpp \ -$(srcdir)/GridStates.h \ -$(srcdir)/Group.cpp \ -$(srcdir)/Group.h \ -$(srcdir)/GroupHandler.cpp \ -$(srcdir)/GuardAI.cpp \ -$(srcdir)/GuardAI.h \ -$(srcdir)/Guild.cpp \ -$(srcdir)/Guild.h \ -$(srcdir)/GuildHandler.cpp \ -$(srcdir)/HomeMovementGenerator.cpp \ -$(srcdir)/HomeMovementGenerator.h \ -$(srcdir)/HostilRefManager.cpp \ -$(srcdir)/HostilRefManager.h \ -$(srcdir)/IdleMovementGenerator.cpp \ -$(srcdir)/IdleMovementGenerator.h \ -$(srcdir)/InstanceData.cpp \ -$(srcdir)/InstanceData.h \ -$(srcdir)/InstanceSaveMgr.cpp \ -$(srcdir)/InstanceSaveMgr.h \ -$(srcdir)/Item.cpp \ -$(srcdir)/Item.h \ -$(srcdir)/ItemEnchantmentMgr.cpp \ -$(srcdir)/ItemEnchantmentMgr.h \ -$(srcdir)/ItemHandler.cpp \ -$(srcdir)/ItemPrototype.h \ -$(srcdir)/Language.h \ -$(srcdir)/Level0.cpp \ -$(srcdir)/Level1.cpp \ -$(srcdir)/Level2.cpp \ -$(srcdir)/Level3.cpp \ -$(srcdir)/LFGHandler.cpp \ -$(srcdir)/LootHandler.cpp \ -$(srcdir)/LootMgr.cpp \ -$(srcdir)/LootMgr.h \ -$(srcdir)/Mail.cpp \ -$(srcdir)/Mail.h \ -$(srcdir)/Map.cpp \ -$(srcdir)/Map.h \ -$(srcdir)/MapInstanced.cpp \ -$(srcdir)/MapInstanced.h \ -$(srcdir)/MapManager.cpp \ -$(srcdir)/MapManager.h \ -$(srcdir)/MiscHandler.cpp \ -$(srcdir)/MotionMaster.cpp \ -$(srcdir)/MotionMaster.h \ -$(srcdir)/MovementGenerator.cpp \ -$(srcdir)/MovementGenerator.h \ -$(srcdir)/MovementGeneratorImpl.h \ -$(srcdir)/MovementHandler.cpp \ -$(srcdir)/NPCHandler.cpp \ -$(srcdir)/NPCHandler.h \ -$(srcdir)/NullCreatureAI.cpp \ -$(srcdir)/NullCreatureAI.h \ -$(srcdir)/ObjectAccessor.cpp \ -$(srcdir)/ObjectAccessor.h \ -$(srcdir)/Object.cpp \ -$(srcdir)/ObjectDefines.h \ -$(srcdir)/ObjectGridLoader.cpp \ -$(srcdir)/ObjectGridLoader.h \ -$(srcdir)/Object.h \ -$(srcdir)/ObjectMgr.cpp \ -$(srcdir)/ObjectMgr.h \ -$(srcdir)/Opcodes.cpp \ -$(srcdir)/Opcodes.h \ -$(srcdir)/OutdoorPvP.cpp \ -$(srcdir)/OutdoorPvP.h \ -$(srcdir)/OutdoorPvPEP.cpp \ -$(srcdir)/OutdoorPvPEP.h \ -$(srcdir)/OutdoorPvPHP.cpp \ -$(srcdir)/OutdoorPvPHP.h \ -$(srcdir)/OutdoorPvPMgr.cpp \ -$(srcdir)/OutdoorPvPMgr.h \ -$(srcdir)/OutdoorPvPNA.cpp \ -$(srcdir)/OutdoorPvPNA.h \ -$(srcdir)/OutdoorPvPObjectiveAI.cpp \ -$(srcdir)/OutdoorPvPObjectiveAI.h \ -$(srcdir)/OutdoorPvPSI.cpp \ -$(srcdir)/OutdoorPvPSI.h \ -$(srcdir)/OutdoorPvPTF.cpp \ -$(srcdir)/OutdoorPvPTF.h \ -$(srcdir)/OutdoorPvPZM.cpp \ -$(srcdir)/OutdoorPvPZM.h \ -$(srcdir)/Path.h \ -$(srcdir)/PetAI.cpp \ -$(srcdir)/PetAI.h \ -$(srcdir)/Pet.cpp \ -$(srcdir)/Pet.h \ -$(srcdir)/PetHandler.cpp \ -$(srcdir)/PetitionsHandler.cpp \ -$(srcdir)/Player.cpp \ -$(srcdir)/Player.h \ -$(srcdir)/PlayerDump.cpp \ -$(srcdir)/PlayerDump.h \ -$(srcdir)/PointMovementGenerator.cpp \ -$(srcdir)/PointMovementGenerator.h \ -$(srcdir)/PossessedAI.cpp \ -$(srcdir)/PossessedAI.h \ -$(srcdir)/QueryHandler.cpp \ -$(srcdir)/QuestDef.cpp \ -$(srcdir)/QuestDef.h \ -$(srcdir)/QuestHandler.cpp \ -$(srcdir)/RandomMovementGenerator.cpp \ -$(srcdir)/RandomMovementGenerator.h \ -$(srcdir)/ReactorAI.cpp \ -$(srcdir)/ReactorAI.h \ -$(srcdir)/ScriptCalls.cpp \ -$(srcdir)/ScriptCalls.h \ -$(srcdir)/SharedDefines.h \ -$(srcdir)/SkillHandler.cpp \ -$(srcdir)/SpellAuraDefines.h \ -$(srcdir)/SpellAuras.cpp \ -$(srcdir)/SpellAuras.h \ -$(srcdir)/Spell.cpp \ -$(srcdir)/SpellEffects.cpp \ -$(srcdir)/Spell.h \ -$(srcdir)/SkillDiscovery.cpp \ -$(srcdir)/SkillDiscovery.h \ -$(srcdir)/SkillExtraItems.cpp \ -$(srcdir)/SkillExtraItems.h \ -$(srcdir)/SpellHandler.cpp \ -$(srcdir)/SocialMgr.cpp \ -$(srcdir)/SocialMgr.h \ -$(srcdir)/SpellMgr.cpp \ -$(srcdir)/SpellMgr.h \ -$(srcdir)/StatSystem.cpp \ -$(srcdir)/TargetedMovementGenerator.cpp \ -$(srcdir)/TargetedMovementGenerator.h \ -$(srcdir)/TaxiHandler.cpp \ -$(srcdir)/TemporarySummon.cpp \ -$(srcdir)/TemporarySummon.h \ -$(srcdir)/tools.cpp \ -$(srcdir)/Tools.h \ -$(srcdir)/TotemAI.cpp \ -$(srcdir)/TotemAI.h \ -$(srcdir)/Totem.cpp \ -$(srcdir)/Totem.h \ -$(srcdir)/TradeHandler.cpp \ -$(srcdir)/Transports.cpp \ -$(srcdir)/Transports.h \ -$(srcdir)/ThreatManager.cpp \ -$(srcdir)/ThreatManager.h \ -$(srcdir)/Traveller.h \ -$(srcdir)/Unit.cpp \ -$(srcdir)/Unit.h \ -$(srcdir)/UnitEvents.h \ -$(srcdir)/UpdateData.cpp \ -$(srcdir)/UpdateData.h \ -$(srcdir)/UpdateFields.h \ -$(srcdir)/UpdateMask.h \ -$(srcdir)/VoiceChatHandler.cpp \ -$(srcdir)/WaypointManager.cpp \ -$(srcdir)/WaypointManager.h \ -$(srcdir)/WaypointMovementGenerator.cpp \ -$(srcdir)/WaypointMovementGenerator.h \ -$(srcdir)/Weather.cpp \ -$(srcdir)/Weather.h \ -$(srcdir)/World.cpp \ -$(srcdir)/World.h \ -$(srcdir)/WorldLog.cpp \ -$(srcdir)/WorldLog.h \ -$(srcdir)/WorldSession.cpp \ -$(srcdir)/WorldSession.h \ -$(srcdir)/WorldSocket.cpp \ -$(srcdir)/WorldSocket.h \ -$(srcdir)/WorldSocketMgr.cpp \ -$(srcdir)/WorldSocketMgr.h \ -$(srcdir)/FollowerReference.cpp \ -$(srcdir)/FollowerReference.h \ -$(srcdir)/FollowerRefManager.h \ -$(srcdir)/GroupReference.cpp \ -$(srcdir)/GroupReference.h \ -$(srcdir)/GroupRefManager.h +## Link against shared library +libmangosgame_a_LIBADD = ../shared/libmangosshared.a ../shared/Auth/libmangosauth.a ../shared/Config/libmangosconfig.a ../shared/Database/libmangosdatabase.a ../shared/vmap/libmangosvmaps.a ## Additional files to include when running 'make dist' # Nothing yet. diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am new file mode 100644 index 00000000000..7b68544e185 --- /dev/null +++ b/src/tools/Makefile.am @@ -0,0 +1,23 @@ +# Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/> +# +# This program is free software; you can redistribute it 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. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +## Process this file with automake to produce Makefile.in + +## Sub-directories to parse +SUBDIRS = genrevision + +## Additional files to include when running 'make dist' +# Nothing yet. diff --git a/src/tools/genrevision/Makefile.am b/src/tools/genrevision/Makefile.am new file mode 100644 index 00000000000..814c6079010 --- /dev/null +++ b/src/tools/genrevision/Makefile.am @@ -0,0 +1,35 @@ +# Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/> +# +# This program is free software; you can redistribute it 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. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +## Process this file with automake to produce Makefile.in + +## CPP flags for includes, defines, etc. +AM_CPPFLAGS = -I$(srcdir) + +## Build world list daemon as standalone program +bin_PROGRAMS = genrevision +genrevision_SOURCES = \ + genrevision.cpp + +## Link world daemon against the shared library +genrevision_LDADD = +genrevision_LDFLAGS = -L$(libdir) + +## Additional files to include when running 'make dist' +# Include world daemon configuration +#EXTRA_DIST = + +## Additional files to install diff --git a/src/tools/genrevision/genrevision.cpp b/src/tools/genrevision/genrevision.cpp new file mode 100644 index 00000000000..a9e39d93c26 --- /dev/null +++ b/src/tools/genrevision/genrevision.cpp @@ -0,0 +1,308 @@ +/* + * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/> + * + * This program is free software; you can redistribute it 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <fstream> +#include <sstream> +#include <time.h> +#include <stdio.h> +#include <string.h> + +#pragma warning(disable:4996) + +struct RawData +{ + char rev_str[200]; + char date_str[200]; + char time_str[200]; +}; + +void extractDataFromSvn(FILE* EntriesFile, bool url, RawData& data) +{ + char buf[200]; + + char repo_str[200]; + char num_str[200]; + + fgets(buf,200,EntriesFile); + fgets(buf,200,EntriesFile); + fgets(buf,200,EntriesFile); + fgets(buf,200,EntriesFile); sscanf(buf,"%s",num_str); + fgets(buf,200,EntriesFile); sscanf(buf,"%s",repo_str); + fgets(buf,200,EntriesFile); + fgets(buf,200,EntriesFile); + fgets(buf,200,EntriesFile); + fgets(buf,200,EntriesFile); + fgets(buf,200,EntriesFile); sscanf(buf,"%10sT%8s",data.date_str,data.time_str); + + if(url) + sprintf(data.rev_str,"%s at %s",num_str,repo_str); + else + strcpy(data.rev_str,num_str); +} + +void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& data) +{ + char buf[200]; + + char hash_str[200]; + char branch_str[200]; + char url_str[200]; + + bool found = false; + while(fgets(buf,200,EntriesFile)) + { + if(sscanf(buf,"%s\t\tbranch %s of %s",hash_str,branch_str,url_str)==3) + { + found = true; + break; + } + } + + if(!found) + { + strcpy(data.rev_str,"*"); + strcpy(data.date_str,"*"); + strcpy(data.time_str,"*"); + return; + } + + if(url) + { + char* host_str = NULL; + char* acc_str = NULL; + char* repo_str = NULL; + + // parse URL like git@github.com:mangos/mangos + char url_buf[200]; + int res = sscanf(url_str,"git@%s",url_buf); + if(res) + { + host_str = strtok(url_buf,":"); + acc_str = strtok(NULL,"/"); + repo_str = strtok(NULL," "); + } + else + { + res = sscanf(url_str,"git://%s",url_buf); + if(res) + { + host_str = strtok(url_buf,"/"); + acc_str = strtok(NULL,"/"); + repo_str = strtok(NULL,"."); + } + } + + // can generate nice link + if(res) + sprintf(data.rev_str,"http://%s/%s/%s/commit/%s",host_str,acc_str,repo_str,hash_str); + // unknonw URL format, use as-is + else + sprintf(data.rev_str,"%s at %s",hash_str,url_str); + } + else + strcpy(data.rev_str,hash_str); + + time_t rev_time = 0; + // extracting date/time + FILE* LogFile = fopen((path+".git/logs/HEAD").c_str(), "r"); + if(LogFile) + { + while(fgets(buf,200,LogFile)) + { + char buf2[200]; + char new_hash[200]; + int unix_time = 0; + int res2 = sscanf(buf,"%s %s %s %s %i",buf2,new_hash,buf2,buf2,&unix_time); + if(res2!=5) + continue; + + if(strcmp(hash_str,new_hash)) + continue; + + rev_time = unix_time; + break; + } + + fclose(LogFile); + + if(rev_time) + { + tm* aTm = localtime(&rev_time); + // YYYY year + // MM month (2 digits 01-12) + // DD day (2 digits 01-31) + // HH hour (2 digits 00-23) + // MM minutes (2 digits 00-59) + // SS seconds (2 digits 00-59) + sprintf(data.date_str,"%04d-%02d-%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday); + sprintf(data.time_str,"%02d:%02d:%02d",aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + } + else + { + strcpy(data.date_str,"*"); + strcpy(data.time_str,"*"); + } + } + else + { + strcpy(data.date_str,"*"); + strcpy(data.time_str,"*"); + } +} + +bool extractDataFromSvn(std::string filename, bool url, RawData& data) +{ + FILE* EntriesFile = fopen(filename.c_str(), "r"); + if(!EntriesFile) + return false; + + extractDataFromSvn(EntriesFile,url,data); + fclose(EntriesFile); + return true; +} + +bool extractDataFromGit(std::string filename, std::string path, bool url, RawData& data) +{ + FILE* EntriesFile = fopen(filename.c_str(), "r"); + if(!EntriesFile) + return false; + + extractDataFromGit(EntriesFile,path,url,data); + fclose(EntriesFile); + return true; +} + +std::string generateHeader(char const* rev_str, char const* date_str, char const* time_str) +{ + std::ostringstream newData; + newData << "#ifndef __REVISION_H__" << std::endl; + newData << "#define __REVISION_H__" << std::endl; + newData << " #define REVISION_ID \"" << rev_str << "\"" << std::endl; + newData << " #define REVISION_DATE \"" << date_str << "\"" << std::endl; + newData << " #define REVISION_TIME \"" << time_str << "\""<< std::endl; + newData << "#endif // __REVISION_H__" << std::endl; + return newData.str(); +} + +int main(int argc, char **argv) +{ + bool use_url = false; + bool svn_prefered = false; + std::string path; + + // Call: tool {options} [path] + // -g use git prefered (default) + // -s use svn prefered + // -r use only revision (without repo URL) (default) + // -u include repositire URL as commit URL or "rev at URL" + for(int k = 1; k <= argc; ++k) + { + if(!argv[k] || !*argv[k]) + break; + + if(argv[k][0]!='-') + { + path = argv[k]; + if(path.size() > 0 && (path[path.size()-1]!='/' || path[path.size()-1]!='\\')) + path += '/'; + break; + } + + switch(argv[k][1]) + { + case 'g': + svn_prefered = false; + continue; + case 'r': + use_url = false; + continue; + case 's': + svn_prefered = true; + continue; + case 'u': + use_url = true; + continue; + default: + printf("Unknown option %s",argv[k]); + return 1; + } + } + + /// new data extraction + std::string newData; + + { + RawData data; + + bool res = false; + + if(svn_prefered) + { + /// SVN data + res = extractDataFromSvn(path+".svn/entries",use_url,data); + if (!res) + res = extractDataFromSvn(path+"_svn/entries",use_url,data); + // GIT data + if (!res) + res = extractDataFromGit(path+".git/FETCH_HEAD",path,use_url,data); + } + else + { + // GIT data + res = extractDataFromGit(path+".git/FETCH_HEAD",path,use_url,data); + /// SVN data + if (!res) + res = extractDataFromSvn(path+".svn/entries",use_url,data); + if (!res) + res = extractDataFromSvn(path+"_svn/entries",use_url,data); + } + + if(res) + newData = generateHeader(data.rev_str,data.date_str,data.time_str); + else + newData = generateHeader("*", "*", "*"); + } + + /// get existed header data for compare + std::string oldData; + + if(FILE* HeaderFile = fopen("revision.h","rb")) + { + while(!feof(HeaderFile)) + { + int c = fgetc(HeaderFile); + if(c < 0) + break; + oldData += (char)c; + } + + fclose(HeaderFile); + } + + /// update header only if different data + if(newData != oldData) + { + if(FILE* OutputFile = fopen("revision.h","wb")) + { + fprintf(OutputFile,"%s",newData.c_str()); + fclose(OutputFile); + } + } + + return 0; +} |