cake
/
p7utils
Archived
1
0
Fork 0

Corrected, adapted to new libp7 version

This commit is contained in:
Thomas Touhey 2017-02-15 14:22:33 +01:00
parent aa148554fc
commit 4e33cf4e98
4 changed files with 15 additions and 33 deletions

View File

@ -43,7 +43,7 @@ int parse_args(int ac, char **av, args_t *args);
/* Actual things */
/* ************************************************************************** */
/* Main functions */
int prepare_ops(p7_handle_t *handle, FILE *uexe, void (*disp)());
int prepare_ops(p7_handle_t *handle, FILE *uexe, p7_disp_t disp);
int get_os(p7_handle_t *handle, FILE *dest);
#endif /* MAIN_H */

View File

@ -9,13 +9,6 @@
/* ************************************************************************** */
#include "main.h"
/* ************************************************************************** */
/* Error messages */
/* ************************************************************************** */
/* Unable to open the embedded thingy */
static const char error_fmemopen[] =
"Unable to open the embedded update.exe.\n";
/* ************************************************************************** */
/* Embedded update.exe */
/* ************************************************************************** */
@ -36,33 +29,20 @@ extern char _binary_cake_exe_bin_end[];
* @return the error (-1 if not a libp7 error, 0 if ok)
*/
int prepare_ops(p7_handle_t *handle, FILE *uexe, void (*disp)())
int prepare_ops(p7_handle_t *handle, FILE *uexe, p7_disp_t disp)
{
int err; size_t usize;
int err;
/* prepare the update.exe */
if (uexe) {
/* calculate the size */
fseek(uexe, 0, SEEK_END);
usize = ftell(uexe);
fseek(uexe, 0, SEEK_SET);
} else {
/* take the default uexe */
usize = (size_t)&cake_exe_end - (size_t)&cake_exe_str;
uexe = fmemopen(cake_exe_str, usize, "r");
if (!uexe) {
fprintf(stderr, error_fmemopen);
return (-1);
}
}
/* send the thing */
if ((err = p7_sendexe_file(handle, uexe, 0x88030000, 0x88030000, disp))) {
/* send the update.exe */
if (uexe)
err = p7_sendexe_file(handle, uexe, 0x88030000, 0x88030000, disp);
else {
err = p7_sendexe_mem(handle, cake_exe_str,
(size_t)((char*)&cake_exe_end - (char*)&cake_exe_str),
0x88030000, 0x88030000, disp);
fclose(uexe);
return (err);
}
/* no error! */
fclose(uexe);
return (0);
/* done! */
return (err);
}

View File

@ -10,6 +10,7 @@
#include "main.h"
#include <libp7.h>
#include <libp7/packetio.h>
#include <libp7/stream.h>
void run_client(int in, int out)
{

View File

@ -8,8 +8,9 @@
/* */
/* ************************************************************************** */
#include "main.h"
#include <libp7.h>
#include <string.h>
#include <libp7.h>
#include <libp7/stream.h>
/* ************************************************************************** */
/* Server callbacks */