Attempt curl. Will be broken until debugged
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -144,3 +144,11 @@ src/checkfile
|
||||
src/log
|
||||
|
||||
src/foo.zip
|
||||
|
||||
src/cc/rogue/config.h
|
||||
|
||||
src/cc/rogue/config.h
|
||||
|
||||
src/ROGUE.conf
|
||||
|
||||
src/rogue.scr
|
||||
|
||||
@@ -1,270 +0,0 @@
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if scorefile is top scores, not top players */
|
||||
#define ALLSCORES 1
|
||||
|
||||
/* Define if checktime feature should be enabled */
|
||||
/* #undef CHECKTIME */
|
||||
|
||||
/* Define to group owner of setgid executable */
|
||||
/* #undef GROUPOWNER */
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
#define HAVE_ALARM 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if libcurses is requested */
|
||||
#define HAVE_CURSES_H 1
|
||||
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
/* #undef HAVE_DOPRNT */
|
||||
|
||||
/* Define to 1 if you have the `erasechar' function. */
|
||||
#define HAVE_ERASECHAR 1
|
||||
|
||||
/* Define if ncurses has ESCDELAY variable */
|
||||
#define HAVE_ESCDELAY 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#define HAVE_FORK 1
|
||||
|
||||
/* Define to 1 if you have the `getgid' function. */
|
||||
#define HAVE_GETGID 1
|
||||
|
||||
/* Define to 1 if you have the `getloadavg' function. */
|
||||
#define HAVE_GETLOADAVG 1
|
||||
|
||||
/* Define to 1 if you have the `getpass' function. */
|
||||
#define HAVE_GETPASS 1
|
||||
|
||||
/* Define to 1 if you have the `getpwuid' function. */
|
||||
#define HAVE_GETPWUID 1
|
||||
|
||||
/* Define to 1 if you have the `getuid' function. */
|
||||
#define HAVE_GETUID 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `killchar' function. */
|
||||
#define HAVE_KILLCHAR 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the `loadav' function. */
|
||||
/* #undef HAVE_LOADAV */
|
||||
|
||||
/* Define to 1 if `lstat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
/* #undef HAVE_LSTAT_EMPTY_STRING_BUG */
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if libncurses is requested */
|
||||
/* #undef HAVE_NCURSES_H */
|
||||
|
||||
/* Define to 1 if you have the <ncurses/term.h> header file. */
|
||||
/* #undef HAVE_NCURSES_TERM_H */
|
||||
|
||||
/* Define to 1 if you have the `nlist' function. */
|
||||
/* #undef HAVE_NLIST */
|
||||
|
||||
/* Define to 1 if you have the <nlist.h> header file. */
|
||||
#define HAVE_NLIST_H 1
|
||||
|
||||
/* Define to 1 if you have the <process.h> header file. */
|
||||
/* #undef HAVE_PROCESS_H */
|
||||
|
||||
/* Define to 1 if you have the <pwd.h> header file. */
|
||||
#define HAVE_PWD_H 1
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
#define HAVE_SETENV 1
|
||||
|
||||
/* Define to 1 if you have the `setgid' function. */
|
||||
#define HAVE_SETGID 1
|
||||
|
||||
/* Define to 1 if you have the `setregid' function. */
|
||||
#define HAVE_SETREGID 1
|
||||
|
||||
/* Define to 1 if you have the `setresgid' function. */
|
||||
/* #undef HAVE_SETRESGID */
|
||||
|
||||
/* Define to 1 if you have the `setresuid' function. */
|
||||
/* #undef HAVE_SETRESUID */
|
||||
|
||||
/* Define to 1 if you have the `setreuid' function. */
|
||||
#define HAVE_SETREUID 1
|
||||
|
||||
/* Define to 1 if you have the `setuid' function. */
|
||||
#define HAVE_SETUID 1
|
||||
|
||||
/* Define to 1 if you have the `spawnl' function. */
|
||||
/* #undef HAVE_SPAWNL */
|
||||
|
||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
/* #undef HAVE_STAT_EMPTY_STRING_BUG */
|
||||
|
||||
/* Define to 1 if stdbool.h conforms to C99. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/utsname.h> header file. */
|
||||
#define HAVE_SYS_UTSNAME_H 1
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#define HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <term.h> header file. */
|
||||
#define HAVE_TERM_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the <utmp.h> header file. */
|
||||
#define HAVE_UTMP_H 1
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#define HAVE_VFORK 1
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
/* #undef HAVE_VFORK_H */
|
||||
|
||||
/* Define to 1 if you have the `vprintf' function. */
|
||||
#define HAVE_VPRINTF 1
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#define HAVE_WORKING_FORK 1
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#define HAVE_WORKING_VFORK 1
|
||||
|
||||
/* Define to 1 if the system has the type `_Bool'. */
|
||||
#define HAVE__BOOL 1
|
||||
|
||||
/* Define to 1 if you have the `_spawnl' function. */
|
||||
/* #undef HAVE__SPAWNL */
|
||||
|
||||
/* define if we should use program's load average function instead of system
|
||||
*/
|
||||
/* #undef LOADAV */
|
||||
|
||||
/* Define to file to use for scoreboard lockfile */
|
||||
#define LOCKFILE "rogue.lck"
|
||||
|
||||
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
|
||||
slash. */
|
||||
/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
|
||||
|
||||
/* Define to include wizard mode */
|
||||
/* #undef MASTER */
|
||||
|
||||
/* Define if maxusers feature should be enabled */
|
||||
/* #undef MAXLOAD */
|
||||
|
||||
/* Define if maxusers feature should be enabled */
|
||||
/* #undef MAXUSERS */
|
||||
|
||||
/* kernel file to pass to nlist() when reading load average (unlikely to work)
|
||||
*/
|
||||
/* #undef NAMELIST */
|
||||
|
||||
/* word for the number of scores to store in scoreboard */
|
||||
#define NUMNAME "Ten"
|
||||
|
||||
/* number of scores to store in scoreboard */
|
||||
#define NUMSCORES 10
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "yendor@rogueforge.net"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "Rogue"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "Rogue 5.4.4"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "rogue"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "5.4.4"
|
||||
|
||||
/* Define crypt(3) wizard mode password */
|
||||
/* #undef PASSWD */
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to file to use for scoreboard */
|
||||
#define SCOREFILE "rogue.scr"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
/* #undef TM_IN_SYS_TIME */
|
||||
|
||||
/* define if we should use program's user counting function instead of
|
||||
system's */
|
||||
/* #undef UCOUNT */
|
||||
|
||||
/* utmp like file to pass to ucount() when counting online users (unlikely to
|
||||
work) */
|
||||
/* #undef UTMP */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef gid_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef uid_t */
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
/* #undef vfork */
|
||||
@@ -23,14 +23,14 @@
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
char USERPASS[8192];
|
||||
char USERPASS[8192]; uint16_t ROGUE_PORT;
|
||||
char Gametxidstr[67];
|
||||
|
||||
#define SMALLVAL 0.000000000000001
|
||||
#define SATOSHIDEN ((uint64_t)100000000L)
|
||||
#define dstr(x) ((double)(x) / SATOSHIDEN)
|
||||
#define KOMODO_ASSETCHAIN_MAXLEN 65
|
||||
#define ASSETCHAINS_SYMBOL "ROGUE"
|
||||
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
|
||||
#ifndef _BITS256
|
||||
#define _BITS256
|
||||
@@ -583,7 +583,6 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *
|
||||
return(chunk.memory);
|
||||
}
|
||||
|
||||
#ifdef autoextract
|
||||
uint16_t _komodo_userpass(char *username,char *password,FILE *fp)
|
||||
{
|
||||
char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0;
|
||||
@@ -617,7 +616,7 @@ uint16_t _komodo_userpass(char *username,char *password,FILE *fp)
|
||||
return(port);
|
||||
}
|
||||
|
||||
void komodo_statefname(char *fname,char *symbol,char *str)
|
||||
/*void komodo_statefname(char *fname,char *symbol,char *str)
|
||||
{
|
||||
int32_t n,len;
|
||||
sprintf(fname,"%s",getDataDir());
|
||||
@@ -652,7 +651,7 @@ void komodo_statefname(char *fname,char *symbol,char *str)
|
||||
}
|
||||
strcat(fname,str);
|
||||
//printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname);
|
||||
}
|
||||
}*/
|
||||
|
||||
uint16_t komodo_userpass(char *userpass,char *symbol)
|
||||
{
|
||||
@@ -667,8 +666,8 @@ uint16_t komodo_userpass(char *userpass,char *symbol)
|
||||
#endif
|
||||
}
|
||||
else sprintf(confname,"%s.conf",symbol);
|
||||
komodo_statefname(fname,symbol,confname);
|
||||
if ( (fp= fopen(fname,"rb")) != 0 )
|
||||
//komodo_statefname(fname,symbol,confname);
|
||||
if ( (fp= fopen(confname,"rb")) != 0 )
|
||||
{
|
||||
port = _komodo_userpass(username,password,fp);
|
||||
sprintf(userpass,"%s:%s",username,password);
|
||||
@@ -678,7 +677,6 @@ uint16_t komodo_userpass(char *userpass,char *symbol)
|
||||
}
|
||||
return(port);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)
|
||||
|
||||
@@ -703,32 +701,53 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
|
||||
|
||||
void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num)
|
||||
{
|
||||
char cmd[16384],hexstr[16384]; int32_t i;
|
||||
char cmd[16384],hexstr[16384],params[32768]; int32_t i;
|
||||
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
||||
{
|
||||
for (i=0; i<num; i++)
|
||||
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]);
|
||||
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]&0xff);
|
||||
hexstr[i<<1] = 0;
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
if ( 0 )
|
||||
{
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(params,"[\"keystrokes\",17,[\"%s\",\"%s\"]]",Gametxidstr,hexstr);
|
||||
if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 )
|
||||
{
|
||||
fprintf(stderr,"KEYSTROKES.(%s)\n",retstr);
|
||||
free(retstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
{
|
||||
char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item;
|
||||
char cmd[32768]; int32_t i,n,retval=-1; char *filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item;
|
||||
if ( rs->guiflag == 0 )
|
||||
return(-1);
|
||||
if ( gametxidstr == 0 || *gametxidstr == 0 )
|
||||
return(retval);
|
||||
sprintf(fname,"%s.gameinfo",gametxidstr);
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
if ( 0 )
|
||||
{
|
||||
sprintf(fname,"%s.gameinfo",gametxidstr);
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
else filestr = (char *)OS_fileptr(&allocsize,fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
filestr = (char *)OS_fileptr(&allocsize,fname);
|
||||
sprintf(params,"[\"gameinfo\",17,[\"%s\"]]",gametxidstr);
|
||||
filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT);
|
||||
}
|
||||
if ( filestr != 0 )
|
||||
{
|
||||
fprintf(stderr,"gameinfo.(%s)\n",filestr);
|
||||
if ( (retjson= cJSON_Parse(filestr)) != 0 )
|
||||
{
|
||||
if ( (array= jarray(&n,retjson,"players")) != 0 )
|
||||
@@ -762,7 +781,20 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
uint64_t seed; FILE *fp = 0;
|
||||
uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192];
|
||||
for (i=j=0; argv[0][i]!=0&&j<sizeof(ASSETCHAINS_SYMBOL); i++)
|
||||
{
|
||||
c = argv[0][i];
|
||||
if ( c == '\\' || c == '/' )
|
||||
{
|
||||
j = 0;
|
||||
continue;
|
||||
}
|
||||
ASSETCHAINS_SYMBOL[j++] = toupper(c);
|
||||
}
|
||||
ASSETCHAINS_SYMBOL[j++] = 0;
|
||||
ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL);
|
||||
printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s)\n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS); sleep(1);
|
||||
if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 )
|
||||
{
|
||||
seed = atol(argv[1]);
|
||||
@@ -773,6 +805,11 @@ int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
if ( fp != 0 )
|
||||
fclose(fp);
|
||||
if ( ROGUE_PORT == 0 )
|
||||
{
|
||||
printf("you must copy ROGUE.conf from ~/.komodo/ROGUE/ROGUE.conf (or equivalent location) to current dir\n");
|
||||
return(-1);
|
||||
}
|
||||
return(rogue(argc,argv,envp));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user