aboutsummaryrefslogtreecommitdiff
path: root/src/type.c
diff options
context:
space:
mode:
authoriceyrazor <iceyrazor@mailfence.com>2026-07-03 22:02:56 -0500
committericeyrazor <iceyrazor@mailfence.com>2026-07-03 22:02:56 -0500
commit0ed6c602b14554a02f7782bd5e5635b1e9d9c195 (patch)
tree54142376e4cedd1aeec259f811c04a2420a3213f /src/type.c
init
Diffstat (limited to 'src/type.c')
-rw-r--r--src/type.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/type.c b/src/type.c
new file mode 100644
index 0000000..19548e9
--- /dev/null
+++ b/src/type.c
@@ -0,0 +1,64 @@
+#include <arpa/inet.h>
+#include <sys/select.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#include "tinyosc.h"
+#include "tinyosc.c"
+
+/*
+ type.c. sends text to vrchat using osc from user input.
+ Copyright (C) 2026 iceyrazor
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+
+int main(int argc, char **argv){
+ char wbuffer[2048]; // declare a 2Kb buffer to read packet data into
+ int port=9000;
+ struct sockaddr_in servaddr;
+
+ int socketfd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (socketfd < 0) {
+ perror("ERROR:");
+ return -1;
+ }
+
+ servaddr.sin_family = AF_INET; // IPv4
+ servaddr.sin_port = htons(port); // Server port
+ servaddr.sin_addr.s_addr = inet_addr("127.0.0.1"); // Server IP
+
+ size_t size=0;
+ for (int i=1; i < argc; i++){
+ size+=strlen(argv[i])+1;
+ }
+ char *send_str=(char*)malloc(sizeof(char)*size+1);
+ send_str[0]='\0';
+ for (int i=1; i < argc; i++){
+ strcat(send_str,argv[i]);
+ strcat(send_str," ");
+ }
+
+ int len = tosc_writeMessage(wbuffer, sizeof(wbuffer), "/chatbox/input", "sTF", send_str);
+ sendto(socketfd, wbuffer, len, MSG_CONFIRM, (const struct sockaddr *)&servaddr, sizeof(servaddr));
+
+ free(send_str);
+
+ return 0;
+}