Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
c8e47f83db
  1. 3
      iguana/databases/cdb-0.75/auto-str.c
  2. 63
      iguana/databases/cdb-0.75/cdb_make.c
  3. BIN
      iguana/databases/cdb-0.75/cdbdump
  4. 1
      iguana/databases/cdb-0.75/cdbdump.c
  5. BIN
      iguana/databases/cdb-0.75/cdbget
  6. 1
      iguana/databases/cdb-0.75/cdbget.c
  7. BIN
      iguana/databases/cdb-0.75/cdbmake
  8. 4
      iguana/databases/cdb-0.75/cdbmake.c
  9. BIN
      iguana/databases/cdb-0.75/cdbstats
  10. 2
      iguana/databases/cdb-0.75/cdbstats.c
  11. BIN
      iguana/databases/cdb-0.75/cdbtest
  12. 2
      iguana/databases/cdb-0.75/conf-ld
  13. 103
      iguana/databases/cdb-0.75/hier.c
  14. BIN
      iguana/databases/cdb-0.75/install
  15. 94
      iguana/databases/cdb-0.75/install.c
  16. BIN
      iguana/databases/cdb-0.75/instcheck
  17. 1
      iguana/databases/cdb-0.75/instcheck.c
  18. 2
      iguana/databases/cdb-0.75/load
  19. BIN
      iguana/databases/cdb-0.75/testzero
  20. 3
      iguana/databases/cdb-0.75/testzero.c
  21. 4
      iguana/iguana_bundles.c
  22. 4
      iguana/m_unix

3
iguana/databases/cdb-0.75/auto-str.c

@ -29,7 +29,8 @@ char **argv;
puts(name);
puts("[] = \"\\\n");
while (ch = *value++) {
while ( (ch= *value++) != 0 )
{
puts("\\");
octal[3] = 0;
octal[2] = '0' + (ch & 7); ch >>= 3;

63
iguana/databases/cdb-0.75/cdb_make.c

@ -5,6 +5,8 @@
#include "error.h"
#include "alloc.h"
#include "cdb.h"
#include "str.h"
#include "open.h"
#include "cdb_make.h"
int cdb_make_start(struct cdb_make *c,int fd)
@ -151,3 +153,64 @@ int cdb_make_finish(struct cdb_make *c)
if (seek_begin(c->fd) == -1) return -1;
return buffer_putflush(&c->b,c->final,sizeof c->final);
}
#include "../../../includes/cJSON.h"
int32_t cdb_jsonmake(struct cdb_make c,cJSON *array,char *dest,char *tmpname)
{
uint32_t klen,dlen,i,n,h; char *field,*value; int32_t fd; cJSON *item;
if ( (fd= open_trunc(tmpname)) == -1 )
return(-1);
if ( cdb_make_start(&c,fd) == -1 )
{
close(fd);
return(-2);
}
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
if ( (field= jfieldname(item)) != 0 && (klen= str_len(field)) > 0)
{
value = jprint(item,0);
if ( (dlen= str_len(value)) > 0 )
{
if ( klen > 429496720 || dlen > 429496720 || cdb_make_addbegin(&c,klen,dlen) == -1 )
{
close(fd);
free(value);
return(-3);
}
h = CDB_HASHSTART;
for (i=0; i<klen; i++)
{
if ( buffer_PUTC(&c.b,field[i]) == -1)
{
close(fd);
free(value);
return(-3);
}
h = cdb_hashadd(h,field[i]);
}
for (i=0; i<dlen; i++)
{
if ( buffer_PUTC(&c.b,value[i]) == -1 )
break;
}
if ( i != dlen || cdb_make_addend(&c,klen,dlen,h) == -1 )
{
close(fd);
free(value);
return(-4);
}
}
free(value);
}
}
}
if ( cdb_make_finish(&c) == -1 || fsync(fd) == -1 || close(fd) == -1 )
return(-5);
if ( rename(tmpname,dest) == -1 )
return(-6);
return(0);
}

BIN
iguana/databases/cdb-0.75/cdbdump

Binary file not shown.

1
iguana/databases/cdb-0.75/cdbdump.c

@ -1,3 +1,4 @@
#include <unistd.h>
#include "uint32.h"
#include "fmt.h"
#include "buffer.h"

BIN
iguana/databases/cdb-0.75/cdbget

Binary file not shown.

1
iguana/databases/cdb-0.75/cdbget.c

@ -1,3 +1,4 @@
#include <unistd.h>
#include "exit.h"
#include "scan.h"

BIN
iguana/databases/cdb-0.75/cdbmake

Binary file not shown.

4
iguana/databases/cdb-0.75/cdbmake.c

@ -1,3 +1,5 @@
#include <unistd.h>
#include <stdio.h>
#include "error.h"
#include "open.h"
#include "strerr.h"
@ -36,7 +38,7 @@ inline void get(char *ch)
static struct cdb_make c;
main(int argc,char **argv)
int main(int argc,char **argv)
{
unsigned int klen;
unsigned int dlen;

BIN
iguana/databases/cdb-0.75/cdbstats

Binary file not shown.

2
iguana/databases/cdb-0.75/cdbstats.c

@ -1,9 +1,11 @@
#include <unistd.h>
#include "uint32.h"
#include "fmt.h"
#include "buffer.h"
#include "strerr.h"
#include "seek.h"
#include "cdb.h"
#include "str.h"
#define FATAL "cdbstats: fatal: "

BIN
iguana/databases/cdb-0.75/cdbtest

Binary file not shown.

2
iguana/databases/cdb-0.75/conf-ld

@ -1,3 +1,3 @@
gcc -s
gcc
This will be used to link .o files into an executable.

103
iguana/databases/cdb-0.75/hier.c

@ -1,15 +1,98 @@
#include <unistd.h>
#include <sys/stat.h>
#include "auto_home.h"
#include "strerr.h"
#include "error.h"
#include "open.h"
#include "readwrite.h"
#include "exit.h"
#include "buffer.h"
#define FATAL "install: fatal: "
void hier()
static void h(char *home,int uid,int gid,int mode)
{
if (mkdir(home,0700) == -1)
if (errno != error_exist)
strerr_die4sys(111,FATAL,"unable to mkdir ",home,": ");
if (chown(home,uid,gid) == -1)
strerr_die4sys(111,FATAL,"unable to chown ",home,": ");
if (chmod(home,mode) == -1)
strerr_die4sys(111,FATAL,"unable to chmod ",home,": ");
}
static void d(char *home,char *subdir,int uid,int gid,int mode)
{
h(auto_home,-1,-1,02755);
d(auto_home,"bin",-1,-1,02755);
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
if (mkdir(subdir,0700) == -1)
if (errno != error_exist)
strerr_die6sys(111,FATAL,"unable to mkdir ",home,"/",subdir,": ");
if (chown(subdir,uid,gid) == -1)
strerr_die6sys(111,FATAL,"unable to chown ",home,"/",subdir,": ");
if (chmod(subdir,mode) == -1)
strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",subdir,": ");
}
static char inbuf[BUFFER_INSIZE];
static char outbuf[BUFFER_OUTSIZE];
static buffer ssin;
static buffer ssout;
int fdsourcedir = -1;
c(auto_home,"bin","cdbget",-1,-1,0755);
c(auto_home,"bin","cdbmake",-1,-1,0755);
c(auto_home,"bin","cdbdump",-1,-1,0755);
c(auto_home,"bin","cdbstats",-1,-1,0755);
c(auto_home,"bin","cdbtest",-1,-1,0755);
c(auto_home,"bin","cdbmake-12",-1,-1,0755);
c(auto_home,"bin","cdbmake-sv",-1,-1,0755);
static void c(char *home,char *subdir,char *file,int uid,int gid,int mode)
{
int fdin;
int fdout;
if (fchdir(fdsourcedir) == -1)
strerr_die2sys(111,FATAL,"unable to switch back to source directory: ");
fdin = open_read(file);
if (fdin == -1)
strerr_die4sys(111,FATAL,"unable to read ",file,": ");
buffer_init(&ssin,read,fdin,inbuf,sizeof inbuf);
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
if (chdir(subdir) == -1)
strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
fdout = open_trunc(file);
if (fdout == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
buffer_init(&ssout,write,fdout,outbuf,sizeof outbuf);
switch(buffer_copy(&ssout,&ssin)) {
case -2:
strerr_die4sys(111,FATAL,"unable to read ",file,": ");
case -3:
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
}
close(fdin);
if (buffer_flush(&ssout) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (fsync(fdout) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (close(fdout) == -1) /* NFS silliness */
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (chown(file,uid,gid) == -1)
strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": ");
if (chmod(file,mode) == -1)
strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": ");
}
void hier()
{
h(auto_home,-1,-1,02755);
d(auto_home,"bin",-1,-1,02755);
c(auto_home,"bin","cdbget",-1,-1,0755);
c(auto_home,"bin","cdbmake",-1,-1,0755);
c(auto_home,"bin","cdbdump",-1,-1,0755);
c(auto_home,"bin","cdbstats",-1,-1,0755);
c(auto_home,"bin","cdbtest",-1,-1,0755);
c(auto_home,"bin","cdbmake-12",-1,-1,0755);
c(auto_home,"bin","cdbmake-sv",-1,-1,0755);
}

BIN
iguana/databases/cdb-0.75/install

Binary file not shown.

94
iguana/databases/cdb-0.75/install.c

@ -1,3 +1,5 @@
#include <unistd.h>
#include <sys/stat.h>
#include "buffer.h"
#include "strerr.h"
#include "error.h"
@ -9,95 +11,9 @@ extern void hier();
#define FATAL "install: fatal: "
int fdsourcedir = -1;
void h(home,uid,gid,mode)
char *home;
int uid;
int gid;
int mode;
{
if (mkdir(home,0700) == -1)
if (errno != error_exist)
strerr_die4sys(111,FATAL,"unable to mkdir ",home,": ");
if (chown(home,uid,gid) == -1)
strerr_die4sys(111,FATAL,"unable to chown ",home,": ");
if (chmod(home,mode) == -1)
strerr_die4sys(111,FATAL,"unable to chmod ",home,": ");
}
void d(home,subdir,uid,gid,mode)
char *home;
char *subdir;
int uid;
int gid;
int mode;
{
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
if (mkdir(subdir,0700) == -1)
if (errno != error_exist)
strerr_die6sys(111,FATAL,"unable to mkdir ",home,"/",subdir,": ");
if (chown(subdir,uid,gid) == -1)
strerr_die6sys(111,FATAL,"unable to chown ",home,"/",subdir,": ");
if (chmod(subdir,mode) == -1)
strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",subdir,": ");
}
char inbuf[BUFFER_INSIZE];
char outbuf[BUFFER_OUTSIZE];
buffer ssin;
buffer ssout;
void c(home,subdir,file,uid,gid,mode)
char *home;
char *subdir;
char *file;
int uid;
int gid;
int mode;
{
int fdin;
int fdout;
if (fchdir(fdsourcedir) == -1)
strerr_die2sys(111,FATAL,"unable to switch back to source directory: ");
fdin = open_read(file);
if (fdin == -1)
strerr_die4sys(111,FATAL,"unable to read ",file,": ");
buffer_init(&ssin,read,fdin,inbuf,sizeof inbuf);
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
if (chdir(subdir) == -1)
strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
fdout = open_trunc(file);
if (fdout == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
buffer_init(&ssout,write,fdout,outbuf,sizeof outbuf);
switch(buffer_copy(&ssout,&ssin)) {
case -2:
strerr_die4sys(111,FATAL,"unable to read ",file,": ");
case -3:
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
}
close(fdin);
if (buffer_flush(&ssout) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (fsync(fdout) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (close(fdout) == -1) /* NFS silliness */
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (chown(file,uid,gid) == -1)
strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": ");
if (chmod(file,mode) == -1)
strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": ");
}
extern int fdsourcedir;
static buffer ssout;
static char outbuf[BUFFER_OUTSIZE];
void z(home,subdir,file,len,uid,gid,mode)
char *home;

BIN
iguana/databases/cdb-0.75/instcheck

Binary file not shown.

1
iguana/databases/cdb-0.75/instcheck.c

@ -1,3 +1,4 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "strerr.h"

2
iguana/databases/cdb-0.75/load

@ -1,4 +1,4 @@
#!/bin/sh
# WARNING: This file was auto-generated. Do not edit!
main="$1"; shift
exec gcc -s -o "$main" "$main".o ${1+"$@"}
exec gcc -o "$main" "$main".o ${1+"$@"}

BIN
iguana/databases/cdb-0.75/testzero

Binary file not shown.

3
iguana/databases/cdb-0.75/testzero.c

@ -1,3 +1,4 @@
#include <unistd.h>
#include "uint32.h"
#include "scan.h"
#include "strerr.h"
@ -14,7 +15,7 @@ static char key[4];
static char data[65536];
struct cdb_make c;
main(int argc,char **argv)
int main(int argc,char **argv)
{
int fd;
unsigned long loop;

4
iguana/iguana_bundles.c

@ -419,7 +419,7 @@ struct iguana_txid *iguana_bundletx(struct iguana_info *coin,struct iguana_bundl
void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp)
{
static const bits256 zero;
char fname[1024],dirname[1024]; FILE *fp; int32_t hdrsi,m,j; uint32_t ipbits;
char fname[1024]; FILE *fp; int32_t hdrsi,m,j; uint32_t ipbits;
if ( bp->purgetime == 0 && time(NULL) > bp->emitfinish+30 )
{
//printf("purged hdrsi.[%d] lag.%ld\n",bp->hdrsi,time(NULL) - bp->emitfinish);
@ -440,7 +440,7 @@ void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp)
else printf("error removing.(%s)\n",fname);
}
}
sprintf(dirname,"%s/%s/%d",GLOBAL_TMPDIR,coin->symbol,bp->bundleheight), OS_remove_directory(dirname);
//sprintf(dirname,"%s/%s/%d",GLOBAL_TMPDIR,coin->symbol,bp->bundleheight), OS_remove_directory(dirname);
bp->purgetime = (uint32_t)time(NULL);
}
}

4
iguana/m_unix

@ -1,6 +1,8 @@
#./configure --enable-endomorphism --enable-module-ecdh --enable-module-schnorr --enable-module-rangeproof --enable-experimental
include iguana.sources
rm ../agents/iguana
git pull
gcc -g -Wno-deprecated -c -O2 *.c
gcc -g -Wno-deprecated -c -O2 $SOURCES
gcc -g -Wno-deprecated -c main.c iguana777.c iguana_bundles.c
gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lcurl -lssl -lcrypto -lpthread -lm ../includes/libsecp256k1.a -lgmp

Loading…
Cancel
Save