created mimeview and the viewer conf edit dialog
This commit is contained in:
+1
-1
@@ -73,7 +73,7 @@ trutf8iter.o : utf8iter.cpp utf8iter.h
|
||||
utf8iter.cpp
|
||||
|
||||
|
||||
CONFTREE_OBJS= trconftree.o $(BIGLIB)
|
||||
CONFTREE_OBJS= trconftree.o ../lib/pathut.o ../lib/smallut.o ../lib/conftree.o
|
||||
trconftree : $(CONFTREE_OBJS)
|
||||
$(CXX) $(ALL_CXXFLAGS) -o trconftree $(CONFTREE_OBJS)
|
||||
trconftree.o : conftree.cpp
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid [] = "@(#$Id: conftree.cpp,v 1.7 2006-11-08 06:56:41 dockes Exp $ (C) 2003 J.F.Dockes";
|
||||
static char rcsid [] = "@(#$Id: conftree.cpp,v 1.8 2006-12-14 13:53:43 dockes Exp $ (C) 2003 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -28,6 +28,7 @@ static char rcsid [] = "@(#$Id: conftree.cpp,v 1.7 2006-11-08 06:56:41 dockes Ex
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "conftree.h"
|
||||
#include "pathut.h"
|
||||
@@ -342,7 +343,7 @@ ConfSimple::sortwalk(WalkerCode (*walker)(void *,const string&,const string&),
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
void ConfSimple::list()
|
||||
void ConfSimple::listall()
|
||||
{
|
||||
if (!ok())
|
||||
return;
|
||||
@@ -362,6 +363,8 @@ list<string> ConfSimple::getNames(const string &sk)
|
||||
for (it = ss->second.begin();it != ss->second.end();it++) {
|
||||
mylist.push_back(it->first);
|
||||
}
|
||||
mylist.sort();
|
||||
mylist.unique();
|
||||
return mylist;
|
||||
}
|
||||
|
||||
@@ -431,7 +434,7 @@ const char *longvalue =
|
||||
void memtest(ConfSimple &c)
|
||||
{
|
||||
cout << "Initial:" << endl;
|
||||
c.list();
|
||||
c.listall();
|
||||
if (c.set("nom", "avec nl \n 2eme ligne", "")) {
|
||||
fprintf(stderr, "set with embedded nl succeeded !\n");
|
||||
exit(1);
|
||||
@@ -450,7 +453,7 @@ void memtest(ConfSimple &c)
|
||||
}
|
||||
|
||||
cout << "Final:" << endl;
|
||||
c.list();
|
||||
c.listall();
|
||||
}
|
||||
|
||||
static char usage [] =
|
||||
@@ -616,7 +619,7 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
printf("LIST\n");
|
||||
parms.list();
|
||||
parms.listall();
|
||||
//printf("WALK\n");parms.sortwalk(mywalker, 0);
|
||||
printf("\nNAMES in global space:\n");
|
||||
list<string> names = parms.getNames("");
|
||||
|
||||
+46
-35
@@ -42,6 +42,7 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
// rh7.3 likes iostream better...
|
||||
#if defined(__GNUC__) && __GNUC__ < 3
|
||||
#include <iostream>
|
||||
@@ -53,13 +54,16 @@
|
||||
using std::string;
|
||||
using std::list;
|
||||
using std::map;
|
||||
using std::istream;
|
||||
#endif // NO_NAMESPACES
|
||||
|
||||
#include "pathut.h"
|
||||
|
||||
/**
|
||||
* Manages a simple configuration file with subsections.
|
||||
*/
|
||||
class ConfSimple {
|
||||
public:
|
||||
public:
|
||||
enum StatusCode {STATUS_ERROR=0, STATUS_RO=1, STATUS_RW=2};
|
||||
|
||||
/**
|
||||
@@ -92,7 +96,7 @@ class ConfSimple {
|
||||
* global space if sk is empty).
|
||||
* @return 0 if name not found, 1 else
|
||||
*/
|
||||
virtual int get(const std::string &name, string &value,
|
||||
virtual int get(const string &name, string &value,
|
||||
const string &sk = string(""));
|
||||
/* Note: the version returning char* was buggy and has been removed */
|
||||
|
||||
@@ -100,14 +104,14 @@ class ConfSimple {
|
||||
* Set value for named parameter in specified subsection (or global)
|
||||
* @return 0 for error, 1 else
|
||||
*/
|
||||
virtual int set(const std::string &nm, const std::string &val,
|
||||
const std::string &sk);
|
||||
virtual int set(const string &nm, const string &val,
|
||||
const string &sk);
|
||||
virtual int set(const char *name, const char *value, const char *sk = 0);
|
||||
|
||||
/**
|
||||
* Remove name and value from config
|
||||
*/
|
||||
virtual int erase(const std::string &name, const std::string &sk);
|
||||
virtual int erase(const string &name, const string &sk);
|
||||
|
||||
virtual StatusCode getStatus();
|
||||
virtual bool ok() {return getStatus() != STATUS_ERROR;}
|
||||
@@ -121,17 +125,17 @@ class ConfSimple {
|
||||
*/
|
||||
enum WalkerCode {WALK_STOP, WALK_CONTINUE};
|
||||
virtual WalkerCode sortwalk(WalkerCode
|
||||
(*wlkr)(void *cldata, const std::string &nm,
|
||||
const std::string &val),
|
||||
(*wlkr)(void *cldata, const string &nm,
|
||||
const string &val),
|
||||
void *clidata);
|
||||
virtual void list();
|
||||
virtual void listall();
|
||||
|
||||
/**
|
||||
* Return all names in given submap
|
||||
*/
|
||||
virtual std::list<string> getNames(const string &sk);
|
||||
virtual list<string> getNames(const string &sk);
|
||||
|
||||
virtual std::string getFilename() {return filename;}
|
||||
virtual string getFilename() {return filename;}
|
||||
|
||||
/**
|
||||
* Copy constructor. Expensive but less so than a full rebuild
|
||||
@@ -158,15 +162,15 @@ class ConfSimple {
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
bool dotildexpand;
|
||||
StatusCode status;
|
||||
private:
|
||||
private:
|
||||
string filename; // set if we're working with a file
|
||||
string *data; // set if we're working with an in-memory string
|
||||
map<string, map<string, string> > submaps;
|
||||
|
||||
void parseinput(std::istream &input);
|
||||
void parseinput(istream &input);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -185,7 +189,7 @@ class ConfSimple {
|
||||
*/
|
||||
class ConfTree : public ConfSimple {
|
||||
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Build the object by reading content from file.
|
||||
*/
|
||||
@@ -203,7 +207,7 @@ class ConfTree : public ConfSimple {
|
||||
* parents.
|
||||
* @return 0 if name not found, 1 else
|
||||
*/
|
||||
virtual int get(const std::string &name, string &value, const string &sk);
|
||||
virtual int get(const string &name, string &value, const string &sk);
|
||||
|
||||
virtual int get(const char *name, string &value, const char *sk) {
|
||||
return get(string(name), value, sk ? string(sk) : string(""));
|
||||
@@ -219,15 +223,20 @@ class ConfTree : public ConfSimple {
|
||||
* one must or we generate an error. We open all trees readonly.
|
||||
*/
|
||||
template <class T> class ConfStack {
|
||||
public:
|
||||
ConfStack(const std::list<string> &fns, bool ro = true) {
|
||||
public:
|
||||
/// Construct from list of configuration file names
|
||||
ConfStack(const list<string> &fns, bool ro = true) {
|
||||
construct(fns, ro);
|
||||
}
|
||||
|
||||
ConfStack(const char *nm, bool ro = true) {
|
||||
std::list<string> fns;
|
||||
fns.push_back(string(nm));
|
||||
construct(fns, ro);
|
||||
// Construct out of one name
|
||||
// Construct out of name and list of directories
|
||||
ConfStack(const string& nm, const list<string>& dirs, bool ro = true) {
|
||||
list<string> fns;
|
||||
for (list<string>::const_iterator it = dirs.begin();
|
||||
it != dirs.end(); it++){
|
||||
fns.push_back(path_cat(*it, nm));
|
||||
}
|
||||
ConfStack::construct(fns, ro);
|
||||
}
|
||||
|
||||
~ConfStack() {
|
||||
@@ -249,8 +258,8 @@ template <class T> class ConfStack {
|
||||
return *this;
|
||||
}
|
||||
|
||||
int get(const std::string &name, string &value, const string &sk) {
|
||||
typename std::list<T*>::iterator it;
|
||||
int get(const string &name, string &value, const string &sk) {
|
||||
typename list<T*>::iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||
if ((*it)->get(name, value, sk))
|
||||
return true;
|
||||
@@ -262,25 +271,27 @@ template <class T> class ConfStack {
|
||||
return get(string(name), value, sk ? string(sk) : string(""));
|
||||
}
|
||||
|
||||
std::list<string> getNames(const string &sk) {
|
||||
std::list<string> nms;
|
||||
typename std::list<T*>::iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||
std::list<string> lst;
|
||||
list<string> getNames(const string &sk) {
|
||||
list<string> nms;
|
||||
typename list<T*>::iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end(); it++) {
|
||||
list<string> lst;
|
||||
lst = (*it)->getNames(sk);
|
||||
nms.splice(nms.end(), lst);
|
||||
}
|
||||
nms.sort();
|
||||
nms.unique();
|
||||
return nms;
|
||||
}
|
||||
|
||||
bool ok() {return m_ok;}
|
||||
|
||||
private:
|
||||
private:
|
||||
bool m_ok;
|
||||
std::list<T*> m_confs;
|
||||
list<T*> m_confs;
|
||||
|
||||
void erase() {
|
||||
typename std::list<T*>::iterator it;
|
||||
typename list<T*>::iterator it;
|
||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||
delete (*it);
|
||||
}
|
||||
@@ -290,7 +301,7 @@ template <class T> class ConfStack {
|
||||
/// Common code to initialize from existing object
|
||||
void init_from(const ConfStack &rhs) {
|
||||
if ((m_ok = rhs.m_ok)) {
|
||||
typename std::list<T*>::const_iterator it;
|
||||
typename list<T*>::const_iterator it;
|
||||
for (it = rhs.m_confs.begin();it != rhs.m_confs.end();it++) {
|
||||
m_confs.push_back(new T(**it));
|
||||
}
|
||||
@@ -298,12 +309,12 @@ template <class T> class ConfStack {
|
||||
}
|
||||
|
||||
/// Common constructor code
|
||||
void construct(const std::list<string> &fns, bool ro) {
|
||||
void construct(const list<string> &fns, bool ro) {
|
||||
if (!ro) {
|
||||
m_ok = false;
|
||||
return;
|
||||
}
|
||||
std::list<std::string>::const_iterator it;
|
||||
list<string>::const_iterator it;
|
||||
bool lastok = false;
|
||||
for (it = fns.begin();it != fns.end();it++) {
|
||||
T* p = new T(it->c_str(), true);
|
||||
|
||||
+64
-6
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: execmd.cpp,v 1.20 2006-11-30 13:38:44 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: execmd.cpp,v 1.21 2006-12-14 13:53:43 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -19,6 +19,7 @@ static char rcsid[] = "@(#$Id: execmd.cpp,v 1.20 2006-11-30 13:38:44 dockes Exp
|
||||
*/
|
||||
#ifndef TEST_EXECMD
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/select.h>
|
||||
@@ -30,6 +31,7 @@ static char rcsid[] = "@(#$Id: execmd.cpp,v 1.20 2006-11-30 13:38:44 dockes Exp
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
@@ -37,13 +39,60 @@ static char rcsid[] = "@(#$Id: execmd.cpp,v 1.20 2006-11-30 13:38:44 dockes Exp
|
||||
#include "execmd.h"
|
||||
#include "pathut.h"
|
||||
#include "debuglog.h"
|
||||
|
||||
#include "smallut.h"
|
||||
#ifndef NO_NAMESPACES
|
||||
using namespace std;
|
||||
#endif /* NO_NAMESPACES */
|
||||
|
||||
#define MAX(A,B) ((A) > (B) ? (A) : (B))
|
||||
|
||||
/* From FreeBSD's which command */
|
||||
static bool
|
||||
exec_is_there(const char *candidate)
|
||||
{
|
||||
struct stat fin;
|
||||
|
||||
/* XXX work around access(2) false positives for superuser */
|
||||
if (access(candidate, X_OK) == 0 &&
|
||||
stat(candidate, &fin) == 0 &&
|
||||
S_ISREG(fin.st_mode) &&
|
||||
(getuid() != 0 ||
|
||||
(fin.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExecCmd::which(const string& cmd, string& path)
|
||||
{
|
||||
if (cmd.empty())
|
||||
return false;
|
||||
if (cmd[0] == '/') {
|
||||
if (exec_is_there(cmd.c_str())) {
|
||||
path = cmd;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const char *pp = getenv("PATH");
|
||||
if (pp == 0)
|
||||
return false;
|
||||
list<string> pels;
|
||||
stringToTokens(pp, pels, ":");
|
||||
for (list<string>::iterator it = pels.begin(); it != pels.end(); it++) {
|
||||
if (it->empty())
|
||||
*it = ".";
|
||||
string candidate = (it->empty() ? string(".") : *it) + "/" + cmd;
|
||||
if (exec_is_there(candidate.c_str())) {
|
||||
path = candidate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ExecCmd::putenv(const string &ea)
|
||||
{
|
||||
m_env.push_back(ea);
|
||||
@@ -299,7 +348,8 @@ int ExecCmd::doexec(const string &cmd, const list<string>& args,
|
||||
while (argv[i]) cerr << argv[i++] << endl;}
|
||||
#endif
|
||||
|
||||
for (it = m_env.begin(); it != m_env.end(); it++) {
|
||||
for (vector<string>::const_iterator it = m_env.begin();
|
||||
it != m_env.end(); it++) {
|
||||
#ifdef PUTENV_ARG_NOT_CONST
|
||||
::putenv(strdup(it->c_str()));
|
||||
#else
|
||||
@@ -382,11 +432,10 @@ static int op_flags;
|
||||
#define OPT_MOINS 0x1
|
||||
#define OPT_s 0x2
|
||||
#define OPT_b 0x4
|
||||
|
||||
#define OPT_w 0x8
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int count = 10;
|
||||
|
||||
thisprog = argv[0];
|
||||
argc--; argv++;
|
||||
|
||||
@@ -397,12 +446,13 @@ int main(int argc, char **argv)
|
||||
Usage();
|
||||
while (**argv)
|
||||
switch (*(*argv)++) {
|
||||
case 's': op_flags |= OPT_s; break;
|
||||
case 'b': op_flags |= OPT_b; if (argc < 2) Usage();
|
||||
if ((sscanf(*(++argv), "%d", &count)) != 1)
|
||||
Usage();
|
||||
argc--;
|
||||
goto b1;
|
||||
case 's': op_flags |= OPT_s; break;
|
||||
case 'w': op_flags |= OPT_w; break;
|
||||
default: Usage(); break;
|
||||
}
|
||||
b1: argc--; argv++;
|
||||
@@ -420,6 +470,14 @@ int main(int argc, char **argv)
|
||||
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
||||
DebugLog::setfilename("stderr");
|
||||
|
||||
if (op_flags & OPT_w) {
|
||||
string path;
|
||||
if (ExecCmd::which(cmd, path)) {
|
||||
cout << path << endl;
|
||||
exit(0);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
ExecCmd mexec;
|
||||
MEAdv adv;
|
||||
adv.cmd = &mexec;
|
||||
|
||||
+15
-7
@@ -16,13 +16,15 @@
|
||||
*/
|
||||
#ifndef _EXECMD_H_INCLUDED_
|
||||
#define _EXECMD_H_INCLUDED_
|
||||
/* @(#$Id: execmd.h,v 1.10 2006-10-11 16:09:45 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: execmd.h,v 1.11 2006-12-14 13:53:43 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::list;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
#endif
|
||||
|
||||
/** Callback function object to advise of new data arrival (or just heartbeat) * if cnt is 0 */
|
||||
@@ -117,13 +119,19 @@ class ExecCmd {
|
||||
: m_advise(0), m_provide(0), m_cancelRequest(false), m_timeoutMs(1000)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Utility routine: check if/where a command is found according to the
|
||||
* current PATH
|
||||
*/
|
||||
static bool which(const string& cmd, string& path);
|
||||
|
||||
private:
|
||||
list<string> m_env;
|
||||
ExecCmdAdvise *m_advise;
|
||||
ExecCmdProvide *m_provide;
|
||||
bool m_cancelRequest;
|
||||
int m_timeoutMs;
|
||||
string m_stderrFile;
|
||||
vector<string> m_env;
|
||||
ExecCmdAdvise *m_advise;
|
||||
ExecCmdProvide *m_provide;
|
||||
bool m_cancelRequest;
|
||||
int m_timeoutMs;
|
||||
string m_stderrFile;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+42
-3
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.11 2006-10-23 15:00:31 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.12 2006-12-14 13:53:43 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -26,14 +26,53 @@ static char rcsid[] = "@(#$Id: pathut.cpp,v 1.11 2006-10-23 15:00:31 dockes Exp
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <stack>
|
||||
|
||||
#include "pathut.h"
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
using std::stack;
|
||||
#endif /* NO_NAMESPACES */
|
||||
|
||||
#include "pathut.h"
|
||||
|
||||
bool maketmpdir(string& tdir, string& reason)
|
||||
{
|
||||
const char *tmpdir = getenv("RECOLL_TMPDIR");
|
||||
if (!tmpdir)
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir)
|
||||
tmpdir = "/tmp";
|
||||
tdir = path_cat(tmpdir, "rcltmpXXXXXX");
|
||||
|
||||
{
|
||||
char *cp = strdup(tdir.c_str());
|
||||
if (!cp) {
|
||||
reason = "maketmpdir: out of memory (for file name !)\n";
|
||||
tdir.erase();
|
||||
return false;
|
||||
}
|
||||
#ifdef HAVE_MKDTEMP
|
||||
if (!mkdtemp(cp)) {
|
||||
#else
|
||||
if (!mktemp(cp)) {
|
||||
#endif // HAVE_MKDTEMP
|
||||
free(cp);
|
||||
reason = "maketmpdir: mktemp failed\n";
|
||||
tdir.erase();
|
||||
return false;
|
||||
}
|
||||
tdir = cp;
|
||||
free(cp);
|
||||
}
|
||||
#ifndef HAVE_MKDTEMP
|
||||
if (mkdir(tdir.c_str(), 0700) < 0) {
|
||||
reason = string("maketmpdir: mkdir ) + tdir : " failed";
|
||||
tdir.erase();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void path_catslash(std::string &s) {
|
||||
if (s.empty() || s[s.length() - 1] != '/')
|
||||
s += '/';
|
||||
|
||||
+4
-1
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _PATHUT_H_INCLUDED_
|
||||
#define _PATHUT_H_INCLUDED_
|
||||
/* @(#$Id: pathut.h,v 1.9 2006-10-23 15:00:31 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: pathut.h,v 1.10 2006-12-14 13:53:43 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
@@ -51,4 +51,7 @@ extern string url_encode(const string url,
|
||||
/// Stat parameter and check if it's a directory
|
||||
extern bool path_isdir(const string& path);
|
||||
|
||||
/// Create temporary directory
|
||||
extern bool maketmpdir(string& tdir, string& reason);
|
||||
|
||||
#endif /* _PATHUT_H_INCLUDED_ */
|
||||
|
||||
+1
-43
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.21 2006-12-11 14:50:53 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.22 2006-12-14 13:53:43 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -31,8 +31,6 @@ static char rcsid[] = "@(#$Id: smallut.cpp,v 1.21 2006-12-11 14:50:53 dockes Exp
|
||||
#include <string>
|
||||
|
||||
#include "smallut.h"
|
||||
#include "debuglog.h"
|
||||
#include "pathut.h"
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using namespace std;
|
||||
@@ -40,45 +38,6 @@ using namespace std;
|
||||
|
||||
#define MIN(A,B) ((A)<(B)?(A):(B))
|
||||
|
||||
bool maketmpdir(string& tdir)
|
||||
{
|
||||
const char *tmpdir = getenv("RECOLL_TMPDIR");
|
||||
if (!tmpdir)
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir)
|
||||
tmpdir = "/tmp";
|
||||
tdir = path_cat(tmpdir, "rcltmpXXXXXX");
|
||||
|
||||
{
|
||||
char *cp = strdup(tdir.c_str());
|
||||
if (!cp) {
|
||||
LOGERR(("maketmpdir: out of memory (for file name !)\n"));
|
||||
tdir.erase();
|
||||
return false;
|
||||
}
|
||||
#ifdef HAVE_MKDTEMP
|
||||
if (!mkdtemp(cp)) {
|
||||
#else
|
||||
if (!mktemp(cp)) {
|
||||
#endif // HAVE_MKDTEMP
|
||||
free(cp);
|
||||
LOGERR(("maketmpdir: mktemp failed\n"));
|
||||
tdir.erase();
|
||||
return false;
|
||||
}
|
||||
tdir = cp;
|
||||
free(cp);
|
||||
}
|
||||
#ifndef HAVE_MKDTEMP
|
||||
if (mkdir(tdir.c_str(), 0700) < 0) {
|
||||
LOGERR(("maketmpdir: mkdir %s failed\n", tdir.c_str()));
|
||||
tdir.erase();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
string stringlistdisp(const list<string>& sl)
|
||||
{
|
||||
string s;
|
||||
@@ -88,7 +47,6 @@ string stringlistdisp(const list<string>& sl)
|
||||
s.erase(s.length()-1);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
int stringicmp(const string & s1, const string& s2)
|
||||
{
|
||||
|
||||
+1
-2
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _SMALLUT_H_INCLUDED_
|
||||
#define _SMALLUT_H_INCLUDED_
|
||||
/* @(#$Id: smallut.h,v 1.21 2006-12-11 14:50:53 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: smallut.h,v 1.22 2006-12-14 13:53:43 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
@@ -37,7 +37,6 @@ extern int stringisuffcmp(const string& s1, const string& s2);
|
||||
// Compare charset names, removing the more common spelling variations
|
||||
extern bool samecharset(const string &cs1, const string &cs2);
|
||||
|
||||
extern bool maketmpdir(string& tdir);
|
||||
extern string stringlistdisp(const list<string>& strs);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user