PROG = lib$(LIB_NAME).a
+SEARCH_DIRS = -I $(DIR_INCLUDE) -I . -I ./include
+
ifeq ($(STG_TIME), yes)
DEFS += -DSTG_TIME
endif
-ifneq ($(ADD_DEFS),)
-DEFS += $(ADD_DEFS)
+ifneq ($(LIB_DEFS),)
+DEFS += $(LIB_DEFS)
endif
-SEARCH_DIRS = -I $(DIR_INCLUDE) -I ./
+ifneq ($(LIB_INCS),)
+SEARCH_DIRS += $(LIB_INCS)
+endif
OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
-INST_INCS = $(addprefix $(DIR_INCLUDE)/, $(notdir $(INCS)))
-INST_LIBS = $(DIR_LIB)/lib$(LIB_NAME)
+#INST_INCS = $(addprefix $(DIR_INCLUDE)/, $(notdir $(INCS)))
+#INST_LIBS = $(DIR_LIB)/lib$(LIB_NAME)
CXXFLAGS += -fPIC
CFLAGS += -fPIC
$(PROG): $(OBJS) $(STGLIBS)
ar rc lib$(LIB_NAME).a $(OBJS)
ranlib lib$(LIB_NAME).a
- cp *.a $(DIR_LIB)
+ #cp *.a $(DIR_LIB)
-includes: $(INCS)
- cp -p $(INCS) $(DIR_INCLUDE)/stg
+#includes: $(INCS)
+# cp -p $(INCS) $(DIR_INCLUDE)/stg
clean:
rm -f deps $(PROG) *.o *.a *.so tags *.*~
- for file in $(INCS); do \
- rm -f $(DIR_INCLUDE)/stg/$$file; \
- done
+ #for file in $(INCS); do \
+ # rm -f $(DIR_INCLUDE)/stg/$$file; \
+ #done
install: $(PROG)
mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/lib/stg
#include <fstream>
-#include "conffiles.h"
-#include "stg/common.h"
+#include "stg/conffiles.h"
using namespace std;
error = 0;
return e;
}
-/*//---------------------------------------------------------------------------
-int CONFIGFILE::ReadString(const string & param, char * str, int * maxLen, const char * defaultVal) const
-{
-it = param_val.find(param);
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
-
-if (it != param_val.end())
- {
- // þÔÏ-ÔÏ ÓÔÏÉÔ
- strncpy(str, param_val[param].c_str(), *maxLen);
- *maxLen = param_val[param].size();
- return 0;
- }
-
-strncpy(str, defaultVal, *maxLen);
-*maxLen = strlen(defaultVal);
-return -1;
-}*/
//---------------------------------------------------------------------------
int CONFIGFILE::ReadString(const string & param, string * val, const string & defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
*val = it->second;
return 0;
}
int CONFIGFILE::ReadInt(const string & param, int * val, int defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = strtol(it->second.c_str(), &res, 10);
if (*res != 0)
int CONFIGFILE::ReadUInt(const string & param, unsigned int * val, unsigned int defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = strtoul(it->second.c_str(), &res, 10);
if (*res != 0)
int CONFIGFILE::ReadLongInt(const string & param, long int * val, long int defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = strtol(it->second.c_str(), &res, 10);
if (*res != 0)
int CONFIGFILE::ReadULongInt(const string & param, unsigned long int * val, unsigned long int defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = strtoul(it->second.c_str(), &res, 10);
if (*res != 0)
int CONFIGFILE::ReadLongLongInt(const string & param, int64_t * val, int64_t defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = strtoll(it->second.c_str(), &res, 10);
if (*res != 0)
int CONFIGFILE::ReadULongLongInt(const string & param, uint64_t * val, uint64_t defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = strtoull(it->second.c_str(), &res, 10);
if (*res != 0)
int CONFIGFILE::ReadShortInt(const string & param, short int * val, short int defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = (short)strtol(it->second.c_str(), &res, 10);
if (*res != 0)
int CONFIGFILE::ReadUShortInt(const string & param, unsigned short int * val, unsigned short int defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = (short)strtoul(it->second.c_str(), &res, 10);
if (*res != 0)
//---------------------------------------------------------------------------
void CONFIGFILE::WriteInt(const string & param, int64_t val)
{
-string s;
-x2str(val, s);
-param_val[param] = s;
+char buf[32];
+snprintf(buf, sizeof(buf), "%lld", static_cast<long long int>(val));
+param_val[param] = buf;
changed = true;
}
//---------------------------------------------------------------------------
int CONFIGFILE::ReadDouble(const string & param, double * val, double defaultVal) const
{
const map<string, string>::const_iterator it(param_val.find(param));
-// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ
if (it != param_val.end())
{
- // þÔÏ-ÔÏ ÓÔÏÉÔ
char *res;
*val = strtod(it->second.c_str(), &res);
if (*res != 0)
if (!changed)
return 0;
-std::string pid;
-x2str(getpid(), pid);
+char pid[6];
+snprintf(pid, sizeof(pid), "%d", getpid());
if (Flush(fileName + "." + pid))
return -1;