msgba/include/msgba/packet/hello.h

57 lines
1.5 KiB
C

#ifndef MS_PACKET_HELLO
#define MS_PACKET_HELLO
#include <stdio.h>
#include <sys/un.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <msgba/client_connection_data.h>
struct msPacket;
/**
* The first kind of packet that the client should send to the emulator.
*/
struct msPacketHello {
//! The size of the following field.
size_t sizeRom;
//! The ROM containing the game.
unsigned char *rom;
//! The size of the following field.
size_t sizeSavestate;
//! The savestate from where to resume.
unsigned char *savestate;
};
/**
* Destroys the msPacketHello and deallocates the memory.
* @param hello The pointer to the pointer to hello to null it after this operation.
*/
void
msPacketHelloDestroy(struct msPacketHello **hello);
/**
* Handles msPacketHello.
* @param packet The packet containing this object in its raw_data.
* @param hello This object.
* @param data This session.
* @return The success status.
*/
bool
msPacketHelloHandle(const struct msPacket *packet, struct msPacketHello *hello,
struct msClientConnectionData *const data);
/**
* Retrieves the msPacketHello contained in the packet raw_data.
* @param packet The packet containing msPacketHello, should have PACKET_GET_HELLO as its id.
* @param client_fd The source of this packet.
* @param data This session.
* @return The success status.
*/
bool
msPacketHelloGet(const struct msPacket *packet, int client_fd,
struct msClientConnectionData *const data);
#endif