Code clean-up.

This commit is contained in:
2020-10-24 04:23:01 +01:00
parent ac3b7f19c7
commit 3c6906afe9
22 changed files with 75 additions and 65 deletions

View File

@@ -18,17 +18,12 @@
#ifndef AARUREMOTE__AARUREMOTE_H_
#define AARUREMOTE__AARUREMOTE_H_
#include <stddef.h>
#include <stdint.h>
#ifdef GEKKO
#include <network.h>
#ifndef MSG_PEEK
#define MSG_PEEK 0x02 // TODO: Untested, may not work
#endif
#elif _WIN32
#include <ws2tcpip.h>
#else
#elif !defined(_WIN32)
#include <netinet/in.h>
#include <sys/socket.h>
#endif

View File

@@ -15,10 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linux.h"
#include <string.h>
#include "../aaruremote.h"
#include "linux.h"
int32_t AtaProtocolToScsiDirection(uint8_t protocol)
{
switch(protocol)

View File

@@ -15,8 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linux.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -28,6 +26,9 @@
#include <libudev.h>
#endif
#include "../aaruremote.h"
#include "linux.h"
void* DeviceOpen(const char* device_path)
{
DeviceContext* ctx;
@@ -135,9 +136,7 @@ int32_t GetDeviceType(void* device_ctx)
{
if(strncmp(tmp_string, "cd", 2) == 0 || strncmp(tmp_string, "disk", 4) == 0 ||
strncmp(tmp_string, "optical", 7) == 0)
{
device_type = AARUREMOTE_DEVICE_TYPE_SCSI;
}
free((void*)tmp_string);
}

View File

@@ -15,14 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linux.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../aaruremote.h"
#include "linux.h"
uint8_t GetFireWireData(void* device_ctx,
uint32_t* id_model,
uint32_t* id_vendor,

View File

@@ -18,8 +18,6 @@
#ifndef AARUREMOTE_LINUX_LINUX_H_
#define AARUREMOTE_LINUX_LINUX_H_
#include "../aaruremote.h"
#define PATH_SYS_DEVBLOCK "/sys/block"
typedef struct

View File

@@ -15,8 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include "linux.h"
#ifdef HAS_UDEV
#include <libudev.h>
#endif
#include <ctype.h>
#include <dirent.h>
@@ -27,9 +28,8 @@
#include <string.h>
#include <unistd.h>
#ifdef HAS_UDEV
#include <libudev.h>
#endif
#include "../aaruremote.h"
#include "linux.h"
DeviceInfoList* ListDevices()
{

View File

@@ -7,8 +7,6 @@
#include <linux/major.h>
#include <linux/mmc/ioctl.h>
#else
#include <stdint.h>
#ifndef MMC_BLOCK_MAJOR
#define MMC_BLOCK_MAJOR 179
#endif

View File

@@ -15,8 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linux.h"
#include <dirent.h>
#include <stdint.h>
#include <stdio.h>
@@ -24,6 +22,9 @@
#include <sys/stat.h>
#include <unistd.h>
#include "../aaruremote.h"
#include "linux.h"
uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis)
{
DeviceContext* ctx = device_ctx;
@@ -78,8 +79,7 @@ uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis)
dir = opendir(tmp_path);
if(!dir) continue;
do
{
do {
dent = readdir(dir);
if(!dent) break;

View File

@@ -15,15 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include "linux.h"
#include <malloc.h>
#include <scsi/sg.h>
#include <stdint.h>
#include <string.h>
#include <sys/ioctl.h>
#include "../aaruremote.h"
#include "linux.h"
int32_t SendScsiCommand(void* device_ctx,
char* cdb,
char* buffer,

View File

@@ -15,9 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linux.h"
#include "mmc/ioctl.h"
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
@@ -26,6 +23,10 @@
#include <sys/ioctl.h>
#include <unistd.h>
#include "../aaruremote.h"
#include "linux.h"
#include "mmc/ioctl.h"
int32_t SendSdhciCommand(void* device_ctx,
uint8_t command,
uint8_t write,

View File

@@ -15,14 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linux.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../aaruremote.h"
#include "linux.h"
uint8_t GetUsbData(void* device_ctx,
uint16_t* desc_len,
char* descriptors,

View File

@@ -15,10 +15,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aaruremote.h"
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#include "win32/win32.h"
#else
#include <stdint.h>
#endif
#include "aaruremote.h"
void FreeDeviceInfoList(DeviceInfoList* start)
{
DeviceInfoList* current;

11
main.c
View File

@@ -15,11 +15,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aaruremote.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#include "win32/win32.h"
#endif
#include "aaruremote.h"
int main()
{

View File

@@ -15,12 +15,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include <malloc.h>
#include <string.h>
#include <sys/utsname.h>
#include "../aaruremote.h"
AaruPacketHello* GetHello()
{
struct utsname utsname;

View File

@@ -15,9 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include "../unix/unix.h"
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <stddef.h>
@@ -25,6 +22,9 @@
#include <stdlib.h>
#include <unistd.h>
#include "../aaruremote.h"
#include "unix.h"
int PrintNetworkAddresses()
{
int ret;

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include <unistd.h>
#include "../aaruremote.h"
void Initialize()
{
// Do nothing

View File

@@ -15,14 +15,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include "../endian.h"
#include <gccore.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include "../aaruremote.h"
#include "../endian.h"
AaruPacketHello* GetHello()
{
AaruPacketHello* pkt_server_hello;

View File

@@ -15,9 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include "wii.h"
#include <gccore.h>
#include <stdbool.h>
#include <stddef.h>
@@ -25,6 +22,9 @@
#include <stdlib.h>
#include <string.h>
#include "../aaruremote.h"
#include "wii.h"
DeviceInfoList* ListDevices()
{
DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;

View File

@@ -15,13 +15,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include "wii.h"
#include <network.h>
#include <stdio.h>
#include <stdlib.h>
#include "../aaruremote.h"
#include "wii.h"
int PrintNetworkAddresses()
{
int ret;

View File

@@ -15,13 +15,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../aaruremote.h"
#include <debug.h>
#include <errno.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include "../aaruremote.h"
void Initialize()
{
void* framebuffer;

View File

@@ -18,8 +18,6 @@
#ifndef AARUREMOTE_WII_WII_H_
#define AARUREMOTE_WII_WII_H_
#include "../aaruremote.h"
#define AARUREMOTE_WII_DEVICE_FD_NAND 1
#define AARUREMOTE_WII_DEVICE_FD_DVD 2
#define AARUREMOTE_WII_DEVICE_FD_SD 3

View File

@@ -15,18 +15,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aaruremote.h"
#include "endian.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#ifdef _WIN32
#define ssize_t int
#include <windows.h>
#include "win32/win32.h"
#include <winsock.h>
#endif
#include "aaruremote.h"
#include "endian.h"
void* WorkingLoop(void* arguments)
{
AtaErrorRegistersChs ata_chs_error_regs;
@@ -392,7 +397,7 @@ void* WorkingLoop(void* arguments)
pkt_nop->reason_code = device_ctx == NULL ? AARUREMOTE_PACKET_NOP_REASON_OPEN_ERROR
: AARUREMOTE_PACKET_NOP_REASON_OPEN_OK;
pkt_nop->error_no = errno;
pkt_nop->error_no = errno;
memset(&pkt_nop->reason, 0, 256);
NetWrite(cli_ctx, pkt_nop, sizeof(AaruPacketNop));