| 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| 2 | // | 
|---|
| 3 | // $Id: utils.h,v 1.1 2000-04-12 17:49:54 ansari Exp $ | 
|---|
| 4 | // | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef UTILS_EA | 
|---|
| 7 | #define UTILS_EA | 
|---|
| 8 |  | 
|---|
| 9 | #include "machdefs.h" | 
|---|
| 10 | #include <string.h> | 
|---|
| 11 | #include <string> | 
|---|
| 12 | #include <stdlib.h> | 
|---|
| 13 | #include <stdio.h> | 
|---|
| 14 |  | 
|---|
| 15 |  | 
|---|
| 16 | // MemCpy marche meme en cas de recouvrement. | 
|---|
| 17 | // #define memcpy MemCpy | 
|---|
| 18 |  | 
|---|
| 19 | void* MemCpy(void* dest, const void* source, size_t n); | 
|---|
| 20 |  | 
|---|
| 21 | char const* PeidaWorkPath(); | 
|---|
| 22 | void buildPath(char* dst, const char* dir, const char* file); | 
|---|
| 23 | void buildPath(string& dst, const string& dir, const string& file); | 
|---|
| 24 | void changeSuffix(char* file, const char* suffix); | 
|---|
| 25 | void changeSuffix(string& file, const string& suffix); | 
|---|
| 26 | string itos(int); | 
|---|
| 27 | string ftos(double); | 
|---|
| 28 |  | 
|---|
| 29 | inline void GetIntEnv(char const* s, int& v) | 
|---|
| 30 | { | 
|---|
| 31 | char* pdeb = getenv(s); | 
|---|
| 32 | if (pdeb) v = atoi(pdeb); | 
|---|
| 33 | } | 
|---|
| 34 |  | 
|---|
| 35 | /* if defined(__DECCXX) || defined(__xlC) */ | 
|---|
| 36 | #if defined(__xlC) || defined(__DECCXX) | 
|---|
| 37 | #define STRUCTCOMP(s)                        \ | 
|---|
| 38 | bool operator==(s const& b) const          \ | 
|---|
| 39 | { return memcmp(this, &b, sizeof(s)) == 0; } \ | 
|---|
| 40 | bool operator<(s const& b) const           \ | 
|---|
| 41 | { return memcmp(this, &b, sizeof(s)) < 0; } | 
|---|
| 42 |  | 
|---|
| 43 | #define STRUCTCOMPF(s,f)                        \ | 
|---|
| 44 | bool operator==(s const& b) const          \ | 
|---|
| 45 | { return f == b.f; }                          \ | 
|---|
| 46 | bool operator<(s const& b) const           \ | 
|---|
| 47 | { return f < b.f; } | 
|---|
| 48 | #else | 
|---|
| 49 | #define STRUCTCOMP(s) | 
|---|
| 50 | #define STRUCTCOMPF(s,f) | 
|---|
| 51 | #endif | 
|---|
| 52 |  | 
|---|
| 53 | #endif // UTILS_EA | 
|---|