dtinfo subtree DtMmdb
This commit is contained in:
committed by
Jon Trulson
parent
b92cf08899
commit
8c8363f4a5
@@ -23,7 +23,7 @@ XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
|
||||
#define LargePICTable YES
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES) $(DEPENDDEFINES)
|
||||
|
||||
XCOMM In DtMmdb we compile as C_API sources.
|
||||
DEFINES = -DC_API -DPORTABLE_DB
|
||||
@@ -36,8 +36,9 @@ BASE_SRCS = \
|
||||
randomize.C
|
||||
|
||||
C_API_SRCS = \
|
||||
streambuf.C charbuf.C filebuf.C strstream.C \
|
||||
iostream.C fstream.C stream.C ios.C
|
||||
streambuf.C charbuf.C filebuf.C string.C \
|
||||
stringstream.C iostream.C fstream.C stream.C \
|
||||
ios.C
|
||||
|
||||
SRCS = $(BASE_SRCS) $(C_API_SRCS)
|
||||
OBJS = $(BASE_SRCS:.C=.o) $(C_API_SRCS:.C=.o)
|
||||
|
||||
@@ -66,7 +66,8 @@ void atoi_fast::init(int r, int, pm_random& rdm_generator)
|
||||
|
||||
v_tbl = new char[v_entries];
|
||||
|
||||
for ( int i = 0; i < v_entries; i++ )
|
||||
int i;
|
||||
for ( i = 0; i < v_entries; i++ )
|
||||
v_tbl[i] = i;
|
||||
|
||||
for ( i = 0; i < v_entries - 1; i++ ) {
|
||||
|
||||
@@ -46,7 +46,12 @@
|
||||
#ifndef _atoi_larson_h
|
||||
#define _atoi_larson_h 1
|
||||
|
||||
#include <limits.h>
|
||||
#if defined(CSRG_BASED)
|
||||
#define MAXINT INT_MAX
|
||||
#else
|
||||
#include <values.h>
|
||||
#endif
|
||||
#include "key.h"
|
||||
|
||||
// Based on Larson's algorithm presented in CACM ???.
|
||||
|
||||
@@ -75,7 +75,8 @@ void atoi_pearson::init(int r, int, pm_random& rdm_generator)
|
||||
|
||||
v_tbl = new char[v_entries];
|
||||
|
||||
for ( int i = 0; i < v_entries; i++ )
|
||||
int i;
|
||||
for ( i = 0; i < v_entries; i++ )
|
||||
v_tbl[i] = i;
|
||||
|
||||
/*
|
||||
|
||||
@@ -162,11 +162,7 @@ int buffer::expand_chunk(const int newsz)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(linux)
|
||||
#define CASTBNDEXCEPT (boundaryException*)
|
||||
#else
|
||||
#define CASTBNDEXCEPT
|
||||
#endif
|
||||
|
||||
/***********************************************************/
|
||||
// Get sz chars to the array x. x is supposed allocated
|
||||
@@ -433,10 +429,6 @@ Boolean operator ==(buffer&x, buffer& y)
|
||||
debug(cerr, i);
|
||||
debug(cerr, x_buf[i]);
|
||||
debug(cerr, y_buf[i]);
|
||||
#ifndef __osf__
|
||||
debug(cerr, hex(x_buf[i]));
|
||||
debug(cerr, hex(y_buf[i]));
|
||||
#endif
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
@@ -459,8 +451,8 @@ ostream& operator<<(ostream& s, buffer& b)
|
||||
|
||||
int x = b.v_eptr - b.v_base ;
|
||||
|
||||
|
||||
for ( int i = 0; i < x; i++ ) {
|
||||
int i;
|
||||
for ( i = 0; i < x; i++ ) {
|
||||
s << b.v_base[i];
|
||||
|
||||
/*
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#define _buffer_h 1
|
||||
|
||||
#include <ctype.h>
|
||||
#include <iomanip>
|
||||
#include "utility/funcs.h"
|
||||
|
||||
class buffer
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef _ios_h
|
||||
#define _ios_h
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "utility/macro.h"
|
||||
#include "utility/c_streambuf.h"
|
||||
|
||||
@@ -57,7 +58,7 @@ public:
|
||||
void clear() { f_state = OK; };
|
||||
|
||||
int operator!() { return fail(); };
|
||||
operator void*() { return (void*)good(); };
|
||||
operator void*() { return (void*)(size_t)good(); };
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
|
||||
#include "utility/c_streambuf.h"
|
||||
|
||||
extern char* form(const char* ...);
|
||||
extern char* sform(const char* ...);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,32 +20,27 @@
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_strstream.h /main/5 1996/08/21 15:55:22 drk $ */
|
||||
/* $XConsortium: c_string.h /main/5 2012/09/18 22:54:47 xxx $ */
|
||||
|
||||
#ifndef _strstream_h
|
||||
#define _strstream_h
|
||||
#ifndef _string_h
|
||||
#define _string_h
|
||||
|
||||
#include <string.h>
|
||||
#include "utility/c_iostream.h"
|
||||
#include "utility/c_charbuf.h"
|
||||
|
||||
class istrstream : public istream
|
||||
class string
|
||||
{
|
||||
public:
|
||||
istrstream(char* str, int size) ;
|
||||
istrstream(char* str);
|
||||
~istrstream() ;
|
||||
string(char* str);
|
||||
string(char* str, int size);
|
||||
~string() ;
|
||||
|
||||
char* c_str();
|
||||
int size();
|
||||
|
||||
protected:
|
||||
streambuf* sbuf; // buffer that provides char sequence read/write
|
||||
};
|
||||
|
||||
class ostrstream : public ostream
|
||||
{
|
||||
public:
|
||||
ostrstream(char* str, int size, int=ios::out);
|
||||
~ostrstream() ;
|
||||
|
||||
int pcount() ;
|
||||
|
||||
char* str();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
61
cde/programs/dtinfo/DtMmdb/utility/c_stringstream.h
Normal file
61
cde/programs/dtinfo/DtMmdb/utility/c_stringstream.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these librararies and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_stringstream.h /main/5 1996/08/21 15:55:22 drk $ */
|
||||
|
||||
#ifndef _strstream_h
|
||||
#define _strstream_h
|
||||
|
||||
#include <string.h>
|
||||
#include "utility/c_iostream.h"
|
||||
#include "utility/c_string.h"
|
||||
|
||||
#define BUF_INITSZ 4096
|
||||
|
||||
class istringstream : public istream
|
||||
{
|
||||
public:
|
||||
istringstream();
|
||||
istringstream(char* str);
|
||||
~istringstream() ;
|
||||
};
|
||||
|
||||
class ostringstream : public ostream
|
||||
{
|
||||
public:
|
||||
ostringstream();
|
||||
ostringstream(char* str, int=ios::out);
|
||||
~ostringstream() ;
|
||||
|
||||
string str();
|
||||
};
|
||||
|
||||
class stringstream : public istringstream, public ostringstream
|
||||
{
|
||||
public:
|
||||
stringstream();
|
||||
stringstream(char* str);
|
||||
virtual ~stringstream() {};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !defined(hpux) && !defined(__osf__) && !defined(USL)
|
||||
#if !defined(hpux) && !defined(__osf__) && !defined(USL) && !defined(linux) && !defined(CSRG_BASED)
|
||||
#include <sysent.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@
|
||||
#define _filter_h 1
|
||||
|
||||
#ifdef C_API
|
||||
#include "utility/c_strstream.h"
|
||||
#include "utility/c_stringstream.h"
|
||||
#else
|
||||
#include <strstream.h>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include "utility/funcs.h"
|
||||
|
||||
@@ -61,12 +61,15 @@
|
||||
|
||||
#if defined(linux)
|
||||
#include <sys/vfs.h>
|
||||
#include <stdarg.h>
|
||||
#elif defined(_AIX)
|
||||
#include <sys/vfs.h>
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/statvfs.h>
|
||||
#else
|
||||
#include <sys/statvfs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
#ifdef __osf__
|
||||
extern "C"
|
||||
@@ -138,24 +141,24 @@ int gethostname(char* name, int namelen)
|
||||
}
|
||||
#endif
|
||||
|
||||
int compare_stream(ostrstream& x, ostrstream& y)
|
||||
int compare_stream(ostringstream& x, ostringstream& y)
|
||||
{
|
||||
if ( x.pcount() != y.pcount() ) {
|
||||
cerr << x.pcount() << "---" << y.pcount() << endl;
|
||||
//debug(cerr, x.str());
|
||||
//debug(cerr, y.str());
|
||||
if ( x.str().size() != y.str().size() ) {
|
||||
cerr << x.str().size() << "---" << y.str().size() << endl;
|
||||
//debug(cerr, x.str().c_str());
|
||||
//debug(cerr, y.str().c_str());
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
char* u = x.str();
|
||||
char* v = y.str();
|
||||
char* u = (char *)x.str().c_str();
|
||||
char* v = (char *)y.str().c_str();
|
||||
|
||||
//debug(cerr, u);
|
||||
//debug(cerr, v);
|
||||
//fprintf(stderr, "u=%s, pcount() = %d\n", u, x.pcount());
|
||||
//fprintf(stderr, "v=%s, pcount() = %d\n", v, y.pcount());
|
||||
|
||||
if ( memcmp(u, v, x.pcount()) != 0 ) {
|
||||
if ( memcmp(u, v, x.str().size()) != 0 ) {
|
||||
STDERR_MESSAGE("two streams do not match.");
|
||||
debug(cerr, u);
|
||||
debug(cerr, v);
|
||||
@@ -208,6 +211,7 @@ 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++ ) {
|
||||
if ( ( 0x000000ff & x) == 0 )
|
||||
x >>= 8;
|
||||
@@ -217,7 +221,8 @@ int pos_of_LSB(const unsigned int y)
|
||||
|
||||
//debug(cerr, i);
|
||||
|
||||
for ( int j =1; j<=8; j++ )
|
||||
int j;
|
||||
for ( j =1; j<=8; j++ )
|
||||
if ( (0x00000001 & x) == 0 )
|
||||
x >>= 1;
|
||||
else
|
||||
@@ -441,7 +446,7 @@ Boolean check_and_create_dir(const char* path)
|
||||
|
||||
// create the subdirecties
|
||||
while ( path_tail[0] != 0 &&
|
||||
( slash_ptr = strchr(path_tail, '/') ) ) {
|
||||
( slash_ptr = (char *)strchr(path_tail, '/') ) ) {
|
||||
|
||||
path_tail = slash_ptr + 1; // set for the next check
|
||||
slash_ptr[0] = 0; // temp. set the slash to 0.
|
||||
@@ -632,6 +637,7 @@ char* time_stamp(_Xctimeparams *ctime_buf)
|
||||
return _XCtime(&x, *ctime_buf);
|
||||
}
|
||||
|
||||
#ifdef C_API
|
||||
int bytes(fstream& fs)
|
||||
{
|
||||
struct stat file_info;
|
||||
@@ -651,6 +657,49 @@ int bytes(int fd)
|
||||
else
|
||||
return int(file_info.st_size);
|
||||
}
|
||||
#else
|
||||
int bytes(fstream* fs)
|
||||
{
|
||||
streampos begin, current, end;
|
||||
int total_bytes;
|
||||
|
||||
current = fs->tellg();
|
||||
fs->seekg(ios::beg);
|
||||
begin = fs->tellg();
|
||||
fs->seekg(ios::end);
|
||||
end = fs->tellg();
|
||||
fs->seekg(current);
|
||||
total_bytes = end - begin;
|
||||
return int(total_bytes);
|
||||
}
|
||||
#endif
|
||||
|
||||
int bytes(char * file_name)
|
||||
{
|
||||
struct stat file_info;
|
||||
|
||||
if ( stat( file_name, &file_info) != 0 )
|
||||
return 0;
|
||||
else
|
||||
return int(file_info.st_size);
|
||||
}
|
||||
|
||||
char* form(const char* fmt, ...)
|
||||
{
|
||||
static char formbuf[BUFSIZ];
|
||||
char tempbuf[BUFSIZ];
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
strcpy(tempbuf, formbuf);
|
||||
(void) vsprintf(tempbuf, fmt, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
strcpy(formbuf, tempbuf);
|
||||
return formbuf;
|
||||
}
|
||||
|
||||
static char info_buf[BUFSIZ];
|
||||
|
||||
@@ -685,9 +734,8 @@ char* access_info( char* request )
|
||||
char userid[L_cuserid];
|
||||
|
||||
#ifndef SVR4
|
||||
sprintf(info_buf, "%s-%s-%s-%ld-%s-%s",
|
||||
sprintf(info_buf, "%s-%s-%ld-%s-%s",
|
||||
host_name, dm_name,
|
||||
( cuserid(userid)[0] == 0 ) ? "???" : userid,
|
||||
/* getenv("USER"), */
|
||||
(long)getpid(), x, request
|
||||
);
|
||||
@@ -725,7 +773,7 @@ Boolean cc_is_digit(istream& in)
|
||||
|
||||
unsigned long disk_space(const char* path)
|
||||
{
|
||||
#if defined(__osf__) || defined (hpux) || defined (SVR4)
|
||||
#if defined(__osf__) || defined (hpux) || defined (SVR4) || defined(CSRG_BASED)
|
||||
struct statvfs statfs_buf;
|
||||
#else
|
||||
struct statfs statfs_buf;
|
||||
@@ -733,7 +781,7 @@ unsigned long disk_space(const char* path)
|
||||
|
||||
long free_bytes;
|
||||
|
||||
#if defined(__osf__) || defined (hpux) || defined (SVR4)
|
||||
#if defined(__osf__) || defined (hpux) || defined (SVR4) || defined(CSRG_BASED)
|
||||
if ( statvfs(path, &statfs_buf) == 0 ) {
|
||||
free_bytes = statfs_buf.f_bavail * statfs_buf.f_frsize ;
|
||||
#else
|
||||
@@ -754,8 +802,8 @@ Boolean writeToTmpFile(char* unique_nm, char* str, int size)
|
||||
fstream *out = 0;
|
||||
char* tmp_dir_tbl[4];
|
||||
tmp_dir_tbl[0] = getenv("TMPDIR");
|
||||
tmp_dir_tbl[1] = "/tmp";
|
||||
tmp_dir_tbl[2] = "/usr/tmp";
|
||||
tmp_dir_tbl[1] = (char*)"/tmp";
|
||||
tmp_dir_tbl[2] = (char*)"/usr/tmp";
|
||||
tmp_dir_tbl[3] = getenv("HOME");
|
||||
|
||||
int tmp_dir_tbl_size = 4;
|
||||
@@ -769,7 +817,7 @@ Boolean writeToTmpFile(char* unique_nm, char* str, int size)
|
||||
|
||||
strcpy(unique_nm, form("%s/tmp.%s", tmp_dir_tbl[i], uid));
|
||||
|
||||
try {
|
||||
mtry {
|
||||
//debug(cerr, tmp_dir_tbl[i]);
|
||||
//debug(cerr, disk_space(tmp_dir_tbl[i]));
|
||||
if ( disk_space(tmp_dir_tbl[i]) <= size )
|
||||
@@ -795,7 +843,7 @@ Boolean writeToTmpFile(char* unique_nm, char* str, int size)
|
||||
}
|
||||
|
||||
}
|
||||
catch_any()
|
||||
mcatch_any()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -52,10 +52,12 @@
|
||||
#ifndef _funcs_h
|
||||
#define _funcs_h 1
|
||||
|
||||
#if !defined(USL) && !defined(__osf__)
|
||||
#if !defined(USL) && !defined(__osf__) && !defined(linux) && \
|
||||
!defined(CSRG_BASED)
|
||||
#include <libc.h>
|
||||
#endif
|
||||
#if defined(hpux) || defined(sgi) || defined(USL) ||defined(__osf__)
|
||||
#if defined(hpux) || defined(sgi) || defined(USL) ||defined(__osf__) || \
|
||||
defined(linux) || defined(CSRG_BASED)
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <sysent.h>
|
||||
@@ -69,12 +71,13 @@
|
||||
#ifdef C_API
|
||||
#include "utility/c_stream.h"
|
||||
#include "utility/c_fstream.h"
|
||||
#include "utility/c_strstream.h"
|
||||
#include "utility/c_stringstream.h"
|
||||
#else
|
||||
#include <assert.h>
|
||||
#include <stream.h>
|
||||
#include <fstream.h>
|
||||
#include <strstream.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
@@ -109,7 +112,9 @@ extern int strncasecmp(const char *, const char *, size_t);
|
||||
int gethostname(char* name, int namelen);
|
||||
#endif
|
||||
|
||||
int compare_stream(ostrstream& x, ostrstream& y);
|
||||
int compare_stream(ostringstream& x, ostringstream& y);
|
||||
|
||||
char * cuserid(char *s);
|
||||
|
||||
|
||||
inline float flog2(unsigned int x) {
|
||||
@@ -195,8 +200,8 @@ int open_dir_prot();
|
||||
|
||||
Boolean cc_is_digit(istream&); // "cc" stands for current char
|
||||
|
||||
int bytes(fstream&);
|
||||
unsigned long disk_space(const char* path);
|
||||
char* access_info( char* request );
|
||||
|
||||
Boolean int_eq(void*, void*);
|
||||
Boolean int_ls(void*, void*);
|
||||
@@ -217,8 +222,15 @@ Boolean timed_unlock( int fd, int seconds = 5);
|
||||
void onalarm(int);
|
||||
*/
|
||||
|
||||
#ifdef C_API
|
||||
int bytes(int fd);
|
||||
char* access_info( char* request );
|
||||
int bytes(fstream&);
|
||||
#else
|
||||
int bytes(fstream*);
|
||||
#endif
|
||||
int bytes(char* file_name);
|
||||
|
||||
char* form(const char* ...);
|
||||
|
||||
// lsb is considered as the 0th bit
|
||||
void lsb_putbits(unsigned& target, unsigned position_from_lsb,
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
*/
|
||||
// $XConsortium: ios.C /main/4 1996/08/21 15:54:46 drk $
|
||||
|
||||
#include "utility/c_ios.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include "utility/c_ios.h"
|
||||
|
||||
ios::ios(streambuf* sb) : sbuf(sb), f_state(OK)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,8 @@ istream& istream::_getline(char* b, int lim, int delim, int fill_zero)
|
||||
|
||||
int i;
|
||||
|
||||
for ( int count = 0 ; count < lim-1; count++ ) {
|
||||
int count;
|
||||
for ( count = 0 ; count < lim-1; count++ ) {
|
||||
|
||||
i = sbuf -> get();
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ ostream& boundaryException::asciiOut(ostream& out)
|
||||
{
|
||||
cerr << low << "\t";
|
||||
cerr << high << "\t";
|
||||
cerr << index << "\n";
|
||||
cerr << mindex << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,9 @@
|
||||
#ifdef C_API
|
||||
#include "utility/c_fstream.h"
|
||||
#else
|
||||
#include <fstream.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
#define END_TRY end_try
|
||||
@@ -90,7 +92,7 @@ protected:
|
||||
public:
|
||||
DECLARE_EXCEPTION(stringException, mmdbException);
|
||||
|
||||
stringException(char* m) : msg(m) {};
|
||||
stringException(char const* m) : msg((char*)m) {};
|
||||
~stringException() {};
|
||||
|
||||
virtual ostream& asciiOut(ostream&);
|
||||
@@ -104,7 +106,7 @@ protected:
|
||||
public:
|
||||
DECLARE_EXCEPTION(formatException, stringException);
|
||||
|
||||
formatException(char* m) : stringException(m) {};
|
||||
formatException(char const* m) : stringException(m) {};
|
||||
~formatException() {};
|
||||
};
|
||||
|
||||
@@ -155,13 +157,13 @@ class boundaryException : public mmdbException
|
||||
protected:
|
||||
long low;
|
||||
long high;
|
||||
long index;
|
||||
long mindex;
|
||||
|
||||
public:
|
||||
DECLARE_EXCEPTION(boundaryException, mmdbException);
|
||||
|
||||
boundaryException(long l, long h, long i) :
|
||||
low(l), high(h), index(i) {};
|
||||
low(l), high(h), mindex(i) {};
|
||||
~boundaryException() {};
|
||||
|
||||
virtual ostream& asciiOut(ostream&);
|
||||
|
||||
@@ -203,7 +203,8 @@ ostring& ostring::operator +(ostring& s)
|
||||
|
||||
ostring *new_ostring = new ostring(l1+l2);
|
||||
|
||||
for ( int i = 0; i<l1; (*new_ostring).v_p[i] = s.v_p[i] ) i++;
|
||||
int i;
|
||||
for ( i = 0; i<l1; (*new_ostring).v_p[i] = s.v_p[i] ) i++;
|
||||
for ( i = 0; i<l2; (*new_ostring).v_p[l1 + i] = s.v_p[i] ) i++;
|
||||
|
||||
return *new_ostring;
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <iostream.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#define BUFSIZ 1000
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ void randomize::restore(buffer& scrambled)
|
||||
|
||||
int *pos = new int[bytes-1];
|
||||
|
||||
for ( int i=0; i<bytes-1; i++ ) {
|
||||
int i;
|
||||
for ( i=0; i<bytes-1; i++ ) {
|
||||
pos[i] = rdn.rand() % ( bytes - i ) + i;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,11 @@ Boolean read_lock(char* lock_file_path,
|
||||
throw(streamException(x.rdstate()));
|
||||
}
|
||||
|
||||
#ifdef C_API
|
||||
offset = bytes(x.rdbuf() -> fd());
|
||||
#else
|
||||
offset = bytes(ai_info);
|
||||
#endif
|
||||
x << "A-" << reader_info << "\n";
|
||||
|
||||
x.close();
|
||||
@@ -89,7 +93,11 @@ Boolean read_lock(char* lock_file_path,
|
||||
throw(streamException(x.rdstate()));
|
||||
}
|
||||
|
||||
#ifdef C_API
|
||||
int sz = bytes(x.rdbuf() -> fd());
|
||||
#else
|
||||
int sz = bytes(ai_info);
|
||||
#endif
|
||||
|
||||
ai_info = new char[sz+1];
|
||||
ai_info[0] = 0;
|
||||
@@ -134,7 +142,11 @@ Boolean read_unlock(char* lock_file_path, char* ai_path, int offset)
|
||||
// and the file size is over 1k
|
||||
///////////////////////////////////////////////
|
||||
|
||||
#ifdef C_API
|
||||
if ( bytes(x.rdbuf() -> fd()) > 1024 ) {
|
||||
#else
|
||||
if ( bytes(ai_path) > 1024 ) {
|
||||
#endif
|
||||
|
||||
ok = false;
|
||||
char buf[BUFSIZ];
|
||||
@@ -172,6 +184,7 @@ Boolean write_lock(char* lock_file_path,
|
||||
char*& ai_info
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
atomic_lock l(lock_file_path);
|
||||
|
||||
if ( l.lock() == false ) {
|
||||
@@ -190,7 +203,11 @@ Boolean write_lock(char* lock_file_path,
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
#ifdef C_API
|
||||
int sz = bytes(x.rdbuf() -> fd());
|
||||
#else
|
||||
int sz = bytes(ai_path);
|
||||
#endif
|
||||
ai_info = new char[sz+1];
|
||||
ai_info[0] = 0;
|
||||
|
||||
@@ -215,7 +232,7 @@ Boolean write_lock(char* lock_file_path,
|
||||
/////////////////////////////////////////
|
||||
// create the access info file
|
||||
/////////////////////////////////////////
|
||||
truncate(ai_path, 0);
|
||||
ret = truncate(ai_path, 0);
|
||||
fstream x(ai_path, ios::out);
|
||||
x << "A-" << writer_info << "\n";
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "utility/c_stream.h"
|
||||
|
||||
char* form(const char* fmt ...)
|
||||
char* sform(const char* fmt ...)
|
||||
{
|
||||
static char buf[1024];
|
||||
|
||||
|
||||
@@ -23,12 +23,10 @@
|
||||
/* $XConsortium: streambuf.C /main/8 1996/08/21 15:55:14 drk $ */
|
||||
#include "utility/c_streambuf.h"
|
||||
|
||||
#if !defined(USL) && !defined(__osf__)
|
||||
#include <libc.h>
|
||||
#endif
|
||||
|
||||
#if defined(USL) || defined(__osf__)
|
||||
#if defined(USL) || defined(__osf__) || defined(linux) || defined(CSRG_BASED)
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <libc.h>
|
||||
#endif
|
||||
|
||||
#define DEF_BUF_SIZ 4096
|
||||
|
||||
@@ -20,51 +20,35 @@
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: strstream.C /main/5 1996/08/21 15:55:17 drk $
|
||||
// $XConsortium: string.C /main/5 2012/09/18 22:56:32 xxx $
|
||||
|
||||
#include "utility/c_strstream.h"
|
||||
#include "utility/c_string.h"
|
||||
#include "utility/c_charbuf.h"
|
||||
#include <string.h>
|
||||
|
||||
istrstream::istrstream(char* str) :
|
||||
//ios(new charbuf(str, strlen(str))), istream(0)
|
||||
istream(0)
|
||||
string::string(char* str)
|
||||
{
|
||||
sbuf = new charbuf(str, strlen(str), 1);
|
||||
}
|
||||
|
||||
istrstream::istrstream(char* str, int size ) :
|
||||
//istream(new charbuf(str, size))
|
||||
istream(0)
|
||||
{
|
||||
sbuf = new charbuf(str, size, 1);
|
||||
}
|
||||
|
||||
istrstream::~istrstream()
|
||||
{
|
||||
}
|
||||
|
||||
ostrstream::ostrstream(char* str, int size, int) :
|
||||
//ios(new charbuf(str, size)), ostream(0)
|
||||
ostream(0)
|
||||
string::string(char* str, int size)
|
||||
{
|
||||
sbuf = new charbuf(str, size);
|
||||
}
|
||||
|
||||
ostrstream::~ostrstream()
|
||||
string::~string()
|
||||
{
|
||||
}
|
||||
|
||||
char* ostrstream::str()
|
||||
char* string::c_str()
|
||||
{
|
||||
char* x = sbuf -> get_buf();
|
||||
x[pcount()] = 0;
|
||||
// x[pcount()] = 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
int ostrstream::pcount()
|
||||
int string::size()
|
||||
{
|
||||
int x = sbuf -> pcount();
|
||||
return x;
|
||||
char* x = sbuf -> get_buf();
|
||||
return(strlen(x));
|
||||
}
|
||||
|
||||
77
cde/programs/dtinfo/DtMmdb/utility/stringstream.C
Normal file
77
cde/programs/dtinfo/DtMmdb/utility/stringstream.C
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these librararies and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: stringstream.C /main/5 1996/08/21 15:55:17 drk $
|
||||
|
||||
#include "utility/c_stringstream.h"
|
||||
#include "utility/c_charbuf.h"
|
||||
#include <string.h>
|
||||
|
||||
istringstream::istringstream() : istream(0)
|
||||
{
|
||||
char str[BUF_INITSZ];
|
||||
sbuf = new charbuf(str, strlen(str), 1);
|
||||
}
|
||||
|
||||
istringstream::istringstream(char* str) :
|
||||
//ios(new charbuf(str, strlen(str))), istream(0)
|
||||
istream(0)
|
||||
{
|
||||
sbuf = new charbuf(str, strlen(str), 1);
|
||||
}
|
||||
|
||||
istringstream::~istringstream()
|
||||
{
|
||||
}
|
||||
|
||||
ostringstream::ostringstream() : ostream(0)
|
||||
{
|
||||
char str[BUF_INITSZ];
|
||||
sbuf = new charbuf(str, strlen(str));
|
||||
}
|
||||
|
||||
ostringstream::ostringstream(char* str, int) :
|
||||
//ios(new charbuf(str, size)), ostream(0)
|
||||
ostream(0)
|
||||
{
|
||||
sbuf = new charbuf(str, strlen(str));
|
||||
}
|
||||
|
||||
ostringstream::~ostringstream()
|
||||
{
|
||||
}
|
||||
|
||||
string ostringstream::str()
|
||||
{
|
||||
string x = sbuf -> get_buf();
|
||||
// x[pcount()] = 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
stringstream::stringstream() : istringstream(), ostringstream()
|
||||
{
|
||||
}
|
||||
|
||||
stringstream::stringstream(char* str) : istringstream(str), ostringstream(str)
|
||||
{
|
||||
sbuf = new charbuf(str, strlen(str));
|
||||
}
|
||||
@@ -22,7 +22,8 @@
|
||||
*/
|
||||
// $XConsortium: tst_filebuf.C /main/4 1996/08/21 15:55:25 drk $
|
||||
|
||||
#include <iostream.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#include "utility/debug.h"
|
||||
#include "utility/c_fstream.h"
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
*/
|
||||
// $XConsortium: tst_streambuf.C /main/4 1996/08/21 15:55:40 drk $
|
||||
|
||||
#include <iostream.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#include "utility/debug.h"
|
||||
#include "utility/c_charbuf.h"
|
||||
|
||||
@@ -24,20 +24,20 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "utility/c_strstream.h"
|
||||
#include "utility/c_stringstream.h"
|
||||
|
||||
tst_ostrstream()
|
||||
tst_ostringstream()
|
||||
{
|
||||
char buf[1024];
|
||||
ostrstream os(buf, 1024);
|
||||
ostringstream os(buf, 1024);
|
||||
os << "istream : virtual public ios.";
|
||||
fprintf(stderr, "buf=%s\n", buf);
|
||||
}
|
||||
|
||||
tst_istrstream()
|
||||
tst_istringstream()
|
||||
{
|
||||
char* buf = "303.0";
|
||||
istrstream is(buf, strlen(buf));
|
||||
istringstream is(buf, strlen(buf));
|
||||
|
||||
int c = is.get() ;
|
||||
fprintf(stderr, "c=%c\n", c);
|
||||
@@ -51,6 +51,6 @@ tst_istrstream()
|
||||
|
||||
main()
|
||||
{
|
||||
tst_ostrstream();
|
||||
tst_istrstream();
|
||||
tst_ostringstream();
|
||||
tst_istringstream();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@
|
||||
#ifdef C_API
|
||||
#include "utility/c_iostream.h"
|
||||
#else
|
||||
#include <iostream.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
#define true 1
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#ifdef C_API
|
||||
#include "utility/c_stream.h"
|
||||
#else
|
||||
#include <stream.h>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include "utility/funcs.h"
|
||||
|
||||
@@ -56,7 +56,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
#include "funcs.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user