Renamed wget() to wget_get() and added server port as argument

This commit is contained in:
nifi 2010-06-14 14:12:43 +00:00
parent f537fac5f0
commit f8078ae277
3 changed files with 11 additions and 7 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: websense-remote.c,v 1.1 2010/06/08 22:39:30 nifi Exp $ * $Id: websense-remote.c,v 1.2 2010/06/14 14:12:43 nifi Exp $
*/ */
/** /**
@ -122,7 +122,7 @@ send_command(const char *server, const char *command)
{ {
int ret; int ret;
printf("Sending to [%s]: %s\n", server, command); printf("Sending to [%s]: %s\n", server, command);
ret = wget(server, command, &callbacks); ret = wget_get(server, 80, command, &callbacks);
if(ret != WGET_OK) { if(ret != WGET_OK) {
if(ret == WGET_ALREADY_RUNNING) { if(ret == WGET_ALREADY_RUNNING) {
printf("Waiting for previous command to finish.\n"); printf("Waiting for previous command to finish.\n");

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: wget.c,v 1.1 2010/06/08 22:39:30 nifi Exp $ * $Id: wget.c,v 1.2 2010/06/14 14:12:43 nifi Exp $
*/ */
/** /**
@ -65,6 +65,7 @@ static unsigned long fetch_counter;
static const char *server; static const char *server;
static const char *file; static const char *file;
static uint16_t port;
static const struct wget_callbacks *callbacks; static const struct wget_callbacks *callbacks;
PROCESS(wget_process, "wget"); PROCESS(wget_process, "wget");
@ -88,7 +89,7 @@ PROCESS_THREAD(wget_process, ev, data)
fetch_started = clock_time(); fetch_started = clock_time();
#endif /* STATS */ #endif /* STATS */
LEDS_ON(LEDS_YELLOW); LEDS_ON(LEDS_YELLOW);
if(webclient_get((char *)server, 80, (char *)file) == 0) { if(webclient_get(server, port, file) == 0) {
PRINTF("wget: failed to connect\n"); PRINTF("wget: failed to connect\n");
LEDS_OFF(LEDS_YELLOW); LEDS_OFF(LEDS_YELLOW);
fetch_running = 0; fetch_running = 0;
@ -186,13 +187,15 @@ wget_init(void)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
wget(const char *s, const char *f, const struct wget_callbacks *c) wget_get(const char *s, uint16_t p, const char *f,
const struct wget_callbacks *c)
{ {
if(fetch_running) { if(fetch_running) {
return WGET_ALREADY_RUNNING; return WGET_ALREADY_RUNNING;
} }
fetch_running = 1; fetch_running = 1;
server = s; server = s;
port = p;
file = f; file = f;
callbacks = c; callbacks = c;
process_start(&wget_process, NULL); process_start(&wget_process, NULL);

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: wget.h,v 1.1 2010/06/08 22:39:30 nifi Exp $ * $Id: wget.h,v 1.2 2010/06/14 14:12:43 nifi Exp $
*/ */
/** /**
@ -48,7 +48,8 @@ struct wget_callbacks {
}; };
void wget_init(void); void wget_init(void);
int wget(const char *server, const char *file, const struct wget_callbacks *c); int wget_get(const char *server, uint16_t port, const char *file,
const struct wget_callbacks *c);
enum { enum {
WGET_OK, WGET_OK,