1999-10-02 16:21:10 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
1999-11-15 10:54:16 +00:00
|
|
|
* ======================================================
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Matthias Ettrich
|
|
|
|
* Copyright (C) 1995-1999 The LyX Team.
|
|
|
|
*
|
1999-11-15 10:54:16 +00:00
|
|
|
* ====================================================== */
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
|
|
#ifndef LYX_LIB_H
|
|
|
|
#define LYX_LIB_H
|
|
|
|
|
|
|
|
#include <ctime>
|
1999-11-01 04:22:28 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "LString.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
|
|
|
/// generates an checksum
|
|
|
|
unsigned long lyxsum(char const * file);
|
|
|
|
|
|
|
|
/// returns a date string
|
|
|
|
inline char * date()
|
|
|
|
{
|
|
|
|
time_t tid;
|
1999-12-13 00:05:34 +00:00
|
|
|
if ((tid= time(0)) == static_cast<time_t>(-1))
|
|
|
|
return 0;
|
1999-10-02 16:21:10 +00:00
|
|
|
else
|
1999-12-13 00:05:34 +00:00
|
|
|
return ctime(&tid);
|
1999-10-02 16:21:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Where can I put this? I found the occurence of the same code
|
|
|
|
// three/four times. Don't you think it better to use a macro definition
|
|
|
|
// (an inlined member of some class)?
|
|
|
|
///
|
|
|
|
inline string getUserName()
|
|
|
|
{
|
|
|
|
string userName(GetEnv("LOGNAME"));
|
|
|
|
if (userName.empty())
|
|
|
|
userName = GetEnv("USER");
|
|
|
|
if (userName.empty())
|
|
|
|
userName = _("unknown");
|
|
|
|
return userName;
|
|
|
|
}
|
1999-11-01 04:22:28 +00:00
|
|
|
|
|
|
|
// This should have been a namespace
|
|
|
|
struct lyx {
|
|
|
|
static char * getcwd(char * buffer, size_t size) {
|
|
|
|
#ifndef __EMX__
|
|
|
|
return ::getcwd(buffer, size);
|
|
|
|
#else
|
|
|
|
return ::_getcwd2(buffer, size);
|
|
|
|
#endif
|
|
|
|
};
|
1999-11-15 10:54:16 +00:00
|
|
|
static int chdir(char const * name) {
|
1999-11-01 04:22:28 +00:00
|
|
|
#ifndef __EMX__
|
|
|
|
return ::chdir(name);
|
|
|
|
#else
|
|
|
|
return ::_chdir2(name);
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
};
|
1999-10-02 16:21:10 +00:00
|
|
|
#endif
|