shared code: use medocutils namespace and other small include adjustments
This commit is contained in:
parent
baf0df0c7e
commit
be758e2c94
@ -27,7 +27,6 @@
|
|||||||
#endif // IDX_THREADS
|
#endif // IDX_THREADS
|
||||||
|
|
||||||
class FIMissingStore;
|
class FIMissingStore;
|
||||||
struct PathStat;
|
|
||||||
|
|
||||||
class DbUpdTask;
|
class DbUpdTask;
|
||||||
class InternfileTask;
|
class InternfileTask;
|
||||||
|
|||||||
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "pathut.h"
|
||||||
|
|
||||||
class RclConfig;
|
class RclConfig;
|
||||||
struct PathStat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to determine a mime type for file.
|
* Try to determine a mime type for file.
|
||||||
|
|||||||
@ -37,7 +37,6 @@ class Doc;
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Uncomp;
|
class Uncomp;
|
||||||
struct PathStat;
|
|
||||||
|
|
||||||
/** Storage for missing helper program info. We want to keep this out of the
|
/** Storage for missing helper program info. We want to keep this out of the
|
||||||
* FileInterner class, because the data will typically be accumulated by several
|
* FileInterner class, because the data will typically be accumulated by several
|
||||||
|
|||||||
@ -39,7 +39,6 @@ public:
|
|||||||
DesktopDb::AppMap *m_appdefs;
|
DesktopDb::AppMap *m_appdefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PathStat;
|
|
||||||
FsTreeWalker::Status FstCb::processone(
|
FsTreeWalker::Status FstCb::processone(
|
||||||
const string& fn, const struct PathStat*, FsTreeWalker::CbFlag flg)
|
const string& fn, const struct PathStat*, FsTreeWalker::CbFlag flg)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct PathStat;
|
#include "pathut.h"
|
||||||
|
|
||||||
class FsTreeWalkerCB;
|
class FsTreeWalkerCB;
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,8 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace MedocUtils {
|
||||||
|
|
||||||
#define PUT_BIT_LE(i, cp, value) do { \
|
#define PUT_BIT_LE(i, cp, value) do { \
|
||||||
(cp)[i] = uint8_t(((value) >> 8 * i) & 0xFF); \
|
(cp)[i] = uint8_t(((value) >> 8 * i) & 0xFF); \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -306,3 +308,5 @@ string& MD5HexScan(const string& xdigest, string& digest)
|
|||||||
}
|
}
|
||||||
return digest;
|
return digest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // End namespace MedocUtils
|
||||||
|
|||||||
@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace MedocUtils {
|
||||||
|
|
||||||
#define MD5_BLOCK_LENGTH 64
|
#define MD5_BLOCK_LENGTH 64
|
||||||
#define MD5_DIGEST_LENGTH 16
|
#define MD5_DIGEST_LENGTH 16
|
||||||
@ -33,10 +36,14 @@ void MD5Final(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
|
|||||||
void MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]);
|
void MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]);
|
||||||
|
|
||||||
/** md5 c++ utility wrappers */
|
/** md5 c++ utility wrappers */
|
||||||
#include <string>
|
|
||||||
extern void MD5Final(std::string& digest, MD5_CTX *);
|
extern void MD5Final(std::string& digest, MD5_CTX *);
|
||||||
extern std::string& MD5String(const std::string& data, std::string& digest);
|
extern std::string& MD5String(const std::string& data, std::string& digest);
|
||||||
extern std::string& MD5HexPrint(const std::string& digest, std::string& out);
|
extern std::string& MD5HexPrint(const std::string& digest, std::string& out);
|
||||||
extern std::string& MD5HexScan(const std::string& xdigest, std::string& digest);
|
extern std::string& MD5HexScan(const std::string& xdigest, std::string& digest);
|
||||||
extern std::string MD5Hex(const std::string& data);
|
extern std::string MD5Hex(const std::string& data);
|
||||||
|
|
||||||
|
} // End namespace MedocUtils
|
||||||
|
|
||||||
|
using namespace MedocUtils;
|
||||||
|
|
||||||
#endif /* _MD5_H_ */
|
#endif /* _MD5_H_ */
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2004-2019 J.F.Dockes
|
/* Copyright (C) 2004-2022 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation; either version 2.1 of the License, or
|
* the Free Software Foundation; either version 2.1 of the License, or
|
||||||
@ -189,6 +189,7 @@ using namespace std;
|
|||||||
#define PATHUT_SSIZE_T ssize_t
|
#define PATHUT_SSIZE_T ssize_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace MedocUtils {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
@ -1643,3 +1644,5 @@ void pathut_init_mt()
|
|||||||
{
|
{
|
||||||
path_home();
|
path_home();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // End namespace MedocUtils
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2004 J.F.Dockes
|
/* Copyright (C) 2004-2022 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation; either version 2.1 of the License, or
|
* the Free Software Foundation; either version 2.1 of the License, or
|
||||||
@ -22,6 +22,13 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace MedocUtils {
|
||||||
|
|
||||||
// Must be called in main thread before starting other threads
|
// Must be called in main thread before starting other threads
|
||||||
extern void pathut_init_mt();
|
extern void pathut_init_mt();
|
||||||
@ -99,7 +106,6 @@ bool path_readable(const std::string& path);
|
|||||||
|
|
||||||
// Conversion between utf-8 and wide char file names.
|
// Conversion between utf-8 and wide char file names.
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
bool wchartoutf8(const wchar_t *in, std::string& out, size_t len = 0);
|
bool wchartoutf8(const wchar_t *in, std::string& out, size_t len = 0);
|
||||||
std::string wchartoutf8(const wchar_t *in, size_t len = 0);
|
std::string wchartoutf8(const wchar_t *in, size_t len = 0);
|
||||||
bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap);
|
bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap);
|
||||||
@ -113,7 +119,6 @@ extern std::string path_shortpath(const std::string& path);
|
|||||||
|
|
||||||
#else // !_WIN32 ->
|
#else // !_WIN32 ->
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#define path_shortpath(path) (path)
|
#define path_shortpath(path) (path)
|
||||||
#ifndef O_BINARY
|
#ifndef O_BINARY
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
@ -271,4 +276,8 @@ private:
|
|||||||
int flopen();
|
int flopen();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // End namespace MedocUtils
|
||||||
|
|
||||||
|
using namespace MedocUtils;
|
||||||
|
|
||||||
#endif /* _PATHUT_H_INCLUDED_ */
|
#endif /* _PATHUT_H_INCLUDED_ */
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2006-2020 J.F.Dockes
|
/* Copyright (C) 2006-2022 J.F.Dockes
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -53,6 +53,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace MedocUtils {
|
||||||
|
|
||||||
int stringicmp(const string& s1, const string& s2)
|
int stringicmp(const string& s1, const string& s2)
|
||||||
{
|
{
|
||||||
return strcasecmp(s1.c_str(), s2.c_str());
|
return strcasecmp(s1.c_str(), s2.c_str());
|
||||||
@ -1352,3 +1354,5 @@ string valToString(const vector<CharFlags>& flags, unsigned int val)
|
|||||||
void smallut_init_mt()
|
void smallut_init_mt()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // End namespace MedocUtils
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2006-2016 J.F.Dockes
|
/* Copyright (C) 2006-2022 J.F.Dockes
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -24,6 +24,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
struct tm;
|
||||||
|
|
||||||
|
namespace MedocUtils {
|
||||||
|
|
||||||
// Miscellaneous mostly string-oriented small utilities
|
// Miscellaneous mostly string-oriented small utilities
|
||||||
// Note that none of the following code knows about utf-8.
|
// Note that none of the following code knows about utf-8.
|
||||||
|
|
||||||
@ -206,7 +210,6 @@ void catstrerror(std::string *reason, const char *what, int _errno);
|
|||||||
|
|
||||||
/** Portable timegm. MS C has _mkgmtime, but there is a bug in Gminw which
|
/** Portable timegm. MS C has _mkgmtime, but there is a bug in Gminw which
|
||||||
* makes it inaccessible */
|
* makes it inaccessible */
|
||||||
struct tm;
|
|
||||||
time_t portable_timegm(struct tm *tm);
|
time_t portable_timegm(struct tm *tm);
|
||||||
|
|
||||||
inline void leftzeropad(std::string& s, unsigned len)
|
inline void leftzeropad(std::string& s, unsigned len)
|
||||||
@ -275,4 +278,8 @@ extern std::string flagsToString(const std::vector<CharFlags>&,
|
|||||||
/// Translate a value into a name
|
/// Translate a value into a name
|
||||||
extern std::string valToString(const std::vector<CharFlags>&, unsigned int val);
|
extern std::string valToString(const std::vector<CharFlags>&, unsigned int val);
|
||||||
|
|
||||||
|
} // End namespace MedocUtils
|
||||||
|
|
||||||
|
using namespace MedocUtils;
|
||||||
|
|
||||||
#endif /* _SMALLUT_H_INCLUDED_ */
|
#endif /* _SMALLUT_H_INCLUDED_ */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user