2024-01-21 11:30:59 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2024-01-21 12:47:01 +01:00
|
|
|
#include "network.h"
|
2024-01-21 11:30:59 +01:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2024-01-21 12:47:01 +01:00
|
|
|
int xPlaneSocket;
|
2024-01-21 11:30:59 +01:00
|
|
|
|
|
|
|
// check argument
|
|
|
|
if (argc != 2) {
|
|
|
|
fprintf(stderr, "Usage: %s <command>\n", argv[0]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2024-01-21 12:47:01 +01:00
|
|
|
// network
|
|
|
|
xPlaneSocket = connectXPlane(SERVER, PORT);
|
|
|
|
if (xPlaneSocket < 0) {
|
2024-01-21 11:30:59 +01:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2024-01-21 12:47:01 +01:00
|
|
|
// send payload
|
2024-01-21 13:14:47 +01:00
|
|
|
if (sendToXPlane(xPlaneSocket, "CMND", argv[1]) < 0) {
|
2024-01-21 11:30:59 +01:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// bye bye (and no, I don't care about error anymore; I'll exit anyway?!)
|
2024-01-21 12:47:01 +01:00
|
|
|
disconnectXPlane(xPlaneSocket);
|
2024-01-21 11:30:59 +01:00
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|