/* ************************************************************************** */ /* _____ _ */ /* server.c |_ _|__ _ _| |__ ___ _ _ */ /* | Project: p7test | |/ _ \| | | | '_ \ / _ \ | | | */ /* | | (_) | |_| | | | | __/ |_| | */ /* By: thomas |_|\___/ \__,_|_| |_|\___|\__, |.fr */ /* Last updated: 2017/01/13 01:04:05 |___/ */ /* */ /* ************************************************************************** */ #include "main.h" #include #include /* ************************************************************************** */ /* Server callbacks */ /* ************************************************************************** */ /** * directory_exists: * Check if a directory exists. * * @arg dirname the directory. * @arg devname the devname. */ static int directory_exists(const char *dirname) { /* check directory name */ if (!strcmp(dirname, "oui")) return (0); else return (p7_error_notfound); } /* ************************************************************************** */ /* Server configuration */ /* ************************************************************************** */ /* the server information */ static p7_server_t server_information = { /* main calculator information */ .cpuid = "The CPU ID, wow!", .hwid = "TESTSERV", .product_id = "OMGOMGOMGOMGOMGO", /* system configuration */ .username = "Cow", /* preprogrammed ROM information */ .preprog_rom_wiped = 1, /* flash ROM and RAM information */ .flash_rom_capacity = 8 * 1024 * 1024, .ram_capacity = 256 * 1024, /* bootcode information */ .bootcode_wiped = 1, /* OS information */ .os_offset = 0x80000000, .os_size = 0x100000, .os_version = { .major = 2, .minor = 9, .rev = 2201 }, }; /* the server filesystems */ static p7_filesystem_t server_filesystems[] = { { .name = "fls0", .directory_exists = directory_exists }, {NULL} }; /* ************************************************************************** */ /* Server functions */ /* ************************************************************************** */ /** * run_server: * Run the server! * * @arg in the input. * @arg out the output. */ void run_server(int in, int out) { p7_handle_t *handle = NULL; int err; if ((err = p7_fdinit(&handle, 0, "server", in, out))) { fprintf(stderr, "Server encountered an error while initializing: %s\n", p7_strerror(err)); return ; } p7_serve(handle, &server_information, server_filesystems); p7_exit(handle); }