|
|
@ -8,11 +8,10 @@
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
#include "netspool.h"
|
|
|
|
#include "netspool.h"
|
|
|
|
|
|
|
|
|
|
|
|
const char *RHOST = "172.31.251.3";
|
|
|
|
#ifdef NETSPOOL
|
|
|
|
const char *RPORT = "24555";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int readstr(int s, char *buf, int len) {
|
|
|
|
int readstr(int s, char *buf, int len) {
|
|
|
|
char c=0;
|
|
|
|
char c=0;
|
|
|
@ -99,7 +98,7 @@ void netspool_start(s_netspool_state *state, const char *host, const char *port,
|
|
|
|
|
|
|
|
|
|
|
|
if( r ) {
|
|
|
|
if( r ) {
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->error = gai_error(r);
|
|
|
|
state->error = gai_strerror(r);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -118,7 +117,7 @@ void netspool_start(s_netspool_state *state, const char *host, const char *port,
|
|
|
|
|
|
|
|
|
|
|
|
if(r==-1) {
|
|
|
|
if(r==-1) {
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->error = "could not connect\n"
|
|
|
|
state->error = "could not connect";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -139,7 +138,10 @@ void netspool_start(s_netspool_state *state, const char *host, const char *port,
|
|
|
|
|
|
|
|
|
|
|
|
void netspool_query(s_netspool_state *state, const char *what)
|
|
|
|
void netspool_query(s_netspool_state *state, const char *what)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int r = sendstr(state->socket, "GET ALL");
|
|
|
|
char strbuf[STRBUF];
|
|
|
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
snprintf(strbuf, STRBUF, "GET %s", what); /* ALL or comma separated NETMAIL, ECHOMAIL... */
|
|
|
|
|
|
|
|
r = sendstr(state->socket, strbuf);
|
|
|
|
if( r ) {
|
|
|
|
if( r ) {
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->error = "IO error";
|
|
|
|
state->error = "IO error";
|
|
|
@ -153,7 +155,7 @@ void netspool_receive(s_netspool_state *state)
|
|
|
|
char strbuf[STRBUF];
|
|
|
|
char strbuf[STRBUF];
|
|
|
|
int r;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
|
|
r = readstr(s, strbuf, STRBUF);
|
|
|
|
r = readstr(state->socket, strbuf, STRBUF);
|
|
|
|
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
|
|
|
|
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
|
|
|
|
puts(strbuf);
|
|
|
|
puts(strbuf);
|
|
|
|
if(strcmp(strbuf, "QUEUE EMPTY")==0) {
|
|
|
|
if(strcmp(strbuf, "QUEUE EMPTY")==0) {
|
|
|
@ -162,15 +164,15 @@ void netspool_receive(s_netspool_state *state)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(strncmp(strbuf, "FILENAME ", 9)==0) {
|
|
|
|
if(strncmp(strbuf, "FILENAME ", 9)==0) {
|
|
|
|
strcpy(filename, strbuf+9);
|
|
|
|
strcpy(state->filename, strbuf+9);
|
|
|
|
puts(filename);
|
|
|
|
puts(state->filename);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->error = "expected filename or queue empty"
|
|
|
|
state->error = "expected filename or queue empty";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
r = readstr(s, strbuf, STRBUF);
|
|
|
|
r = readstr(state->socket, strbuf, STRBUF);
|
|
|
|
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
|
|
|
|
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
|
|
|
|
if(strncmp(strbuf, "BINARY ", 7)==0) {
|
|
|
|
if(strncmp(strbuf, "BINARY ", 7)==0) {
|
|
|
|
/*if(filename[0]==0) {
|
|
|
|
/*if(filename[0]==0) {
|
|
|
@ -182,7 +184,7 @@ void netspool_receive(s_netspool_state *state)
|
|
|
|
state->state = NS_RECVFILE;
|
|
|
|
state->state = NS_RECVFILE;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->state = NS_ERROR;
|
|
|
|
state->error = "expected binary"
|
|
|
|
state->error = "expected binary";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -265,3 +267,4 @@ void savefile(const char *fn, unsigned long long l, int s)
|
|
|
|
close(f);
|
|
|
|
close(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endif
|
|
|
|