dtinfo subdirectory DtMmdb

This commit is contained in:
Ulrich Wilkens
2013-08-28 19:16:37 +02:00
committed by Jon Trulson
parent 0be684281d
commit fbd81ef151
159 changed files with 735 additions and 588 deletions

View File

@@ -66,8 +66,8 @@ void atoi_fast::init(int r, int, pm_random& rdm_generator)
v_tbl = new char[v_entries];
int i;
for ( i = 0; i < v_entries; i++ )
unsigned int i;
for ( unsigned i = 0; i < v_entries; i++ )
v_tbl[i] = i;
for ( i = 0; i < v_entries - 1; i++ ) {
@@ -113,22 +113,22 @@ int atoi_fast::atoi(const char* string, int l, int , int rang ) const
case 0:
break;
case 1:
reg.chars_val.b1 = v_tbl[string[0]] ;
reg.chars_val.b1 = v_tbl[(unsigned int)string[0]] ;
break;
case 2:
reg.chars_val.b1 = v_tbl[string[0]] ;
reg.chars_val.b2 = v_tbl[string[1]] ;
reg.chars_val.b1 = v_tbl[(unsigned int)string[0]] ;
reg.chars_val.b2 = v_tbl[(unsigned int)string[1]] ;
break;
case 3:
reg.chars_val.b1 = v_tbl[string[0]] ;
reg.chars_val.b2 = v_tbl[string[1]] ;
reg.chars_val.b3 = v_tbl[string[2]] ;
reg.chars_val.b1 = v_tbl[(unsigned int)string[0]] ;
reg.chars_val.b2 = v_tbl[(unsigned int)string[1]] ;
reg.chars_val.b3 = v_tbl[(unsigned int)string[2]] ;
break;
default:
reg.chars_val.b1 = v_tbl[string[0]] ;
reg.chars_val.b2 = v_tbl[string[1]] ;
reg.chars_val.b3 = v_tbl[string[2]] ;
reg.chars_val.b4 = v_tbl[string[3]] ;
reg.chars_val.b1 = v_tbl[(unsigned int)string[0]] ;
reg.chars_val.b2 = v_tbl[(unsigned int)string[1]] ;
reg.chars_val.b3 = v_tbl[(unsigned int)string[2]] ;
reg.chars_val.b4 = v_tbl[(unsigned int)string[3]] ;
}
int x = 0;
@@ -187,7 +187,7 @@ int atoi_fast::atoi(const char* str, int offset, int rang ) const
ostream& operator<<(ostream& s, atoi_fast& p)
{
for ( int i = 0; i < p.v_entries ; i++ )
for ( unsigned int i = 0; i < p.v_entries ; i++ )
s << int(p.v_tbl[i]) << " ";
return s;
}

View File

@@ -75,7 +75,7 @@ void atoi_pearson::init(int r, int, pm_random& rdm_generator)
v_tbl = new char[v_entries];
int i;
unsigned int i;
for ( i = 0; i < v_entries; i++ )
v_tbl[i] = i;
@@ -175,7 +175,7 @@ int atoi_pearson::atoi(const char* str, int offset, int rang ) const
ostream& operator<<(ostream& s, atoi_pearson& p)
{
for ( int i = 0; i < p.v_entries ; i++ )
for ( unsigned int i = 0; i < p.v_entries ; i++ )
s << int(p.v_tbl[i]) << " ";
return s;
}

View File

@@ -75,13 +75,13 @@ private:
void init(int _range, int _entries, pm_random&);
protected:
char *v_tbl;
Boolean v_shared;
unsigned v_mask;
unsigned int v_entries;
unsigned int v_range;
unsigned v_mask;
unsigned int v_no_bytes;
char *v_tbl;
Boolean v_shared;
};

View File

@@ -58,7 +58,8 @@ extern int errno;
atomic_lock::atomic_lock(const char* p)
{
strcpy(v_path, p);
int len = MIN(strlen(p), PATHSIZ - 1);
*((char *) memcpy(v_path, p, len) + len) = '\0';
}
atomic_lock::~atomic_lock()

View File

@@ -308,7 +308,7 @@ buffer& buffer::put(const char content, Boolean exp_buf)
{
//return put((char*)&content, sizeof(content));
if ( v_bufsz == content_sz() )
if ( (int) v_bufsz == content_sz() )
{
if ( exp_buf == true )
expand_chunk(v_bufsz + 10);
@@ -391,7 +391,7 @@ buffer& buffer::put(const float content, Boolean exp_buf)
/***********************************************************/
buffer& buffer::put(const char* content, int sz, Boolean exp_buf)
{
if ( sz > v_bufsz - content_sz() ) {
if ( sz > (int)(v_bufsz - content_sz()) ) {
if ( exp_buf == true )
expand_chunk(v_bufsz + sz);
else {

View File

@@ -32,8 +32,8 @@
class ios
{
protected:
int f_state;
streambuf* sbuf; // buffer that provides char sequence read/write
int f_state;
public:

View File

@@ -57,16 +57,16 @@ class streambuf
protected:
char* base;
char* end;
char* get_ptr;
char* put_ptr;
char* get_ptr;
int _gcount;
int _pcount;
int _capacity;
int _size;
int _capacity;
int _alloc;
int _pcount;
int _gcount;
protected:
enum notify_action_t { GET, PUT };
virtual void notify(int) {};

View File

@@ -48,8 +48,8 @@ filebuf::~filebuf()
/////////////////////////////////////////////
filebuf::filebuf(int __fd) :
new_pos(0), default_new_pos(0), _fd(__fd), current_pos(0),
_prev_action(-1), _name(0)
_fd(__fd), _prev_action(-1), _name(0),
current_pos(0), new_pos(0), default_new_pos(0)
{
_mode = 0;
@@ -66,8 +66,8 @@ filebuf::filebuf(int __fd) :
}
filebuf::filebuf(const char* name, int mode, int protect) :
new_pos(0), default_new_pos(0), current_pos(0),
_fd(-1), _prev_action(-1), _name(strdup(name))
_fd(-1), _prev_action(-1), _name(strdup(name)),
current_pos(0), new_pos(0), default_new_pos(0)
{
open(name, mode, protect);
}

View File

@@ -80,6 +80,8 @@ int getdomainname(char *, int);
#endif /* __osf__ */
#include <sys/stat.h>
#define BUFLEN 512
#ifdef USL
int _DtMmdbStrcasecmp(register const char* s1, register const char* s2)
@@ -201,8 +203,8 @@ int pos_of_LSB(const unsigned int y)
{
switch (y) {
case 8192: return 14;
case 1024: return 11;
case 8192: return 13;
case 1024: return 10;
default:
{
@@ -211,8 +213,8 @@ int pos_of_LSB(const unsigned int y)
//debug(cerr, x);
//debug(cerr, hex(x));
int i;
for ( int i =0; i<sizeof(x); i++ ) {
unsigned int i;
for ( i =0; i<sizeof(x); i++ ) {
if ( ( 0x000000ff & x) == 0 )
x >>= 8;
else
@@ -275,7 +277,8 @@ unsigned getbits(unsigned x, unsigned p, unsigned n)
int del_file(const char* filename, const char* pathname)
{
static char buf[512];
unsigned int len, slen;
static char buf[BUFLEN];
int ok;
@@ -283,13 +286,19 @@ int del_file(const char* filename, const char* pathname)
ok = unlink(filename);
else {
if ( strlen(filename) + strlen(pathname) > 511 )
throw(boundaryException(1, 512, strlen(filename) + strlen(pathname)));
if ( strlen(filename) + strlen(pathname) > (BUFLEN - 1) )
throw(boundaryException(1, BUFLEN,
strlen(filename) + strlen(pathname)));
buf[0] = 0;
strcpy(buf, pathname);
strcat(buf, "/");
strcat(buf, filename);
len = MIN(strlen(pathname), BUFLEN - 1);
*((char *) memcpy(buf, pathname, len) + len) = '\0';
slen = len;
len = MIN(1, BUFLEN - 1 - slen);
*((char *) memcpy(buf + slen, "/", len) + len) = '\0';
slen += len;
len = MIN(strlen(filename), BUFLEN - 1 - slen);
*((char *) memcpy(buf + slen, filename, len) + len) = '\0';
ok = unlink(buf);
}
@@ -331,8 +340,8 @@ copy_file(const char* path, const char* file,
char source[PATHSIZ];
char target[PATHSIZ];
sprintf(source, "%s/%s.%s", path, file, source_ext);
sprintf(target, "%s/%s.%s", path, file, target_ext);
snprintf(source, sizeof(source), "%s/%s.%s", path, file, source_ext);
snprintf(target, sizeof(target), "%s/%s.%s", path, file, target_ext);
return copy_file(source, target) ;
}
@@ -689,15 +698,18 @@ char* form(const char* fmt, ...)
static char formbuf[BUFSIZ];
char tempbuf[BUFSIZ];
va_list args;
int len;
va_start(args, fmt);
strcpy(tempbuf, formbuf);
(void) vsprintf(tempbuf, fmt, args);
len = MIN(strlen(formbuf), BUFSIZ - 1);
*((char *) memcpy(tempbuf, formbuf, len) + len) = '\0';
(void) vsnprintf(tempbuf, sizeof(tempbuf), fmt, args);
va_end(args);
strcpy(formbuf, tempbuf);
len = MIN(strlen(tempbuf), BUFSIZ - 1);
*((char *) memcpy(formbuf, tempbuf, len) + len) = '\0';
return formbuf;
}
@@ -731,16 +743,15 @@ char* access_info( char* request )
char* x = time_stamp(&ctime_buf);
x[strlen(x)-1] = 0;
char userid[L_cuserid];
#ifndef SVR4
sprintf(info_buf, "%s-%s-%ld-%s-%s",
snprintf(info_buf, sizeof(info_buf), "%s-%s-%ld-%s-%s",
host_name, dm_name,
/* getenv("USER"), */
(long)getpid(), x, request
);
#else
sprintf(info_buf, "%s-%s-%ld-%s-%s",
char userid[L_cuserid];
snprintf(info_buf, sizeof(info_buf), "%s-%s-%ld-%s-%s",
name.nodename,
( cuserid(userid)[0] == 0 ) ? "???" : userid,
/* getenv("USER"), */
@@ -801,6 +812,7 @@ Boolean writeToTmpFile(char* unique_nm, char* str, int size)
Boolean ok = false;
fstream *out = 0;
char* tmp_dir_tbl[4];
int len;
tmp_dir_tbl[0] = getenv("TMPDIR");
tmp_dir_tbl[1] = (char*)"/tmp";
tmp_dir_tbl[2] = (char*)"/usr/tmp";
@@ -815,12 +827,15 @@ Boolean writeToTmpFile(char* unique_nm, char* str, int size)
if ( tmp_dir_tbl[i] == 0 )
continue;
strcpy(unique_nm, form("%s/tmp.%s", tmp_dir_tbl[i], uid));
len = MIN(strlen(tmp_dir_tbl[i]) + strlen(uid) + 5, PATHSIZ - 1);
*((char *) memcpy(unique_nm,
form("%s/tmp.%s", tmp_dir_tbl[i], uid),
len) + len) = '\0';
mtry {
//debug(cerr, tmp_dir_tbl[i]);
//debug(cerr, disk_space(tmp_dir_tbl[i]));
if ( disk_space(tmp_dir_tbl[i]) <= size )
if ( disk_space(tmp_dir_tbl[i]) <= (unsigned long) size )
continue;
out = new fstream(unique_nm, ios::out);

View File

@@ -70,6 +70,11 @@
#define TOBOOLEAN(x) ( ((x) == 1 ) ? true : false )
#define TOBIT(x) ( ((x) == true ) ? 1 : 0 )
/* secure XtNewString macro */
#define XtsNewString(str) \
((str) != NULL ? (char *)(memcpy(XtMalloc((unsigned)strlen(str) + 1), \
str, (unsigned)strlen(str) + 1)) : NULL)
/* little endian to/from big endian swap macros. */
#ifndef __osf__

View File

@@ -184,7 +184,7 @@ Boolean write_lock(char* lock_file_path,
char*& ai_info
)
{
int ret;
unsigned int len, slen;
atomic_lock l(lock_file_path);
if ( l.lock() == false ) {
@@ -217,8 +217,14 @@ Boolean write_lock(char* lock_file_path,
while ( x.getline(buf, BUFSIZ) ) {
if ( buf[0] == 'A' ) {
ok = false;
strcat(ai_info, buf+1);
strcat(ai_info, "\n");
slen = strlen(ai_info);
len = MIN(strlen(buf+1), BUFSIZ - 1 - slen);
*((char *) memcpy(ai_info + slen, buf+1, len) + len) = '\0';
slen = strlen(ai_info);
len = MIN(1, BUFSIZ - 1 - slen);
*((char *) memcpy(ai_info + slen, "\n", len) + len) = '\0';
}
}
@@ -232,7 +238,9 @@ Boolean write_lock(char* lock_file_path,
/////////////////////////////////////////
// create the access info file
/////////////////////////////////////////
ret = truncate(ai_path, 0);
if(truncate(ai_path, 0) != 0 ) {
throw(systemException(errno));
}
fstream x(ai_path, ios::out);
x << "A-" << writer_info << "\n";

View File

@@ -35,7 +35,7 @@ char* sform(const char* fmt ...)
va_start(args, fmt);
(void) vsprintf(buf, fmt, args);
(void) vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);

View File

@@ -79,7 +79,7 @@ typedef void (*print_func_ptr_t)(ostream&, const void*);
//enum Boolean { true, false };
#ifndef __osf__
#if !defined(__osf__) && !defined(linux) && !defined(CSRG_BASED)
typedef long mmdb_pos_t;
#else
typedef int mmdb_pos_t;