shared code: use medocutils namespace and other small include adjustments

This commit is contained in:
Jean-Francois Dockes 2022-05-09 19:03:57 +02:00
parent baf0df0c7e
commit be758e2c94
11 changed files with 45 additions and 13 deletions

View File

@ -27,7 +27,6 @@
#endif // IDX_THREADS
class FIMissingStore;
struct PathStat;
class DbUpdTask;
class InternfileTask;

View File

@ -19,8 +19,9 @@
#include <string>
#include "pathut.h"
class RclConfig;
struct PathStat;
/**
* Try to determine a mime type for file.

View File

@ -37,7 +37,6 @@ class Doc;
}
class Uncomp;
struct PathStat;
/** 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

View File

@ -39,7 +39,6 @@ public:
DesktopDb::AppMap *m_appdefs;
};
struct PathStat;
FsTreeWalker::Status FstCb::processone(
const string& fn, const struct PathStat*, FsTreeWalker::CbFlag flg)
{

View File

@ -20,7 +20,7 @@
#include <string>
#include <vector>
struct PathStat;
#include "pathut.h"
class FsTreeWalkerCB;

View File

@ -28,6 +28,8 @@
#include <cstring>
#include <cstdint>
namespace MedocUtils {
#define PUT_BIT_LE(i, cp, value) do { \
(cp)[i] = uint8_t(((value) >> 8 * i) & 0xFF); \
} while (0)
@ -306,3 +308,5 @@ string& MD5HexScan(const string& xdigest, string& digest)
}
return digest;
}
} // End namespace MedocUtils

View File

@ -17,6 +17,9 @@
#include <stddef.h>
#include <stdint.h>
#include <string>
namespace MedocUtils {
#define MD5_BLOCK_LENGTH 64
#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]);
/** md5 c++ utility wrappers */
#include <string>
extern void MD5Final(std::string& digest, MD5_CTX *);
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& MD5HexScan(const std::string& xdigest, std::string& digest);
extern std::string MD5Hex(const std::string& data);
} // End namespace MedocUtils
using namespace MedocUtils;
#endif /* _MD5_H_ */

View File

@ -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
* 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
@ -189,6 +189,7 @@ using namespace std;
#define PATHUT_SSIZE_T ssize_t
#endif
namespace MedocUtils {
#ifdef _WIN32
@ -1643,3 +1644,5 @@ void pathut_init_mt()
{
path_home();
}
} // End namespace MedocUtils

View File

@ -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
* 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
@ -22,6 +22,13 @@
#include <set>
#include <cstdint>
#include <fstream>
#include <memory>
#ifndef _WIN32
#include <unistd.h>
#endif
namespace MedocUtils {
// Must be called in main thread before starting other threads
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.
#include <memory>
bool wchartoutf8(const wchar_t *in, std::string& out, 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);
@ -113,7 +119,6 @@ extern std::string path_shortpath(const std::string& path);
#else // !_WIN32 ->
#include <unistd.h>
#define path_shortpath(path) (path)
#ifndef O_BINARY
#define O_BINARY 0
@ -271,4 +276,8 @@ private:
int flopen();
};
} // End namespace MedocUtils
using namespace MedocUtils;
#endif /* _PATHUT_H_INCLUDED_ */

View File

@ -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
* modify it under the terms of the GNU Lesser General Public
@ -53,6 +53,8 @@
using namespace std;
namespace MedocUtils {
int stringicmp(const string& s1, const string& s2)
{
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()
{
}
} // End namespace MedocUtils

View File

@ -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
* modify it under the terms of the GNU Lesser General Public
@ -24,6 +24,10 @@
#include <vector>
#include <map>
struct tm;
namespace MedocUtils {
// Miscellaneous mostly string-oriented small utilities
// 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
* makes it inaccessible */
struct tm;
time_t portable_timegm(struct tm *tm);
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
extern std::string valToString(const std::vector<CharFlags>&, unsigned int val);
} // End namespace MedocUtils
using namespace MedocUtils;
#endif /* _SMALLUT_H_INCLUDED_ */