aboutsummaryrefslogtreecommitdiff
path: root/src/type.c
diff options
context:
space:
mode:
authoriceyrazor <iceyrazor@mailfence.com>2026-10-09 06:32:21 -0500
committericeyrazor <iceyrazor@mailfence.com>2026-10-09 06:32:21 -0500
commit76a7a2c292f8f5ba4ce6bf1cee095940a2eff401 (patch)
treee5ef5568a3554dd6fc53da9180a66e50a9867efa /src/type.c
parent1df6a629cddbdcd9c622ef5c4eefdca8f04c3555 (diff)
several changes:HEADmain
- config.c is now config.h - keepRunning is now sig_atomic_t - execlb now returns error from forked process - execlb now has buffer size - execlb now uses waitpid - buffers are no longer malloced and are 0 initialized - fixed includes - same stuff pretty much to type.c - removed size calculation from type.c
Diffstat (limited to 'src/type.c')
-rw-r--r--src/type.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/type.c b/src/type.c
index 19548e9..b2512d6 100644
--- a/src/type.c
+++ b/src/type.c
@@ -1,14 +1,15 @@
#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/select.h>
#include <sys/wait.h>
+#include <unistd.h>
+#include <string.h>
-#include "tinyosc.h"
-#include "tinyosc.c"
+#include <tinyosc.c>
+#include <tinyosc.h>
/*
type.c. sends text to vrchat using osc from user input.
@@ -28,10 +29,10 @@
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;
+int main(int argc, char** argv)
+{
+ char wbuffer[2048] = { 0 }; // declare a 2Kb buffer to read packet data into
+ int port = 9000;
struct sockaddr_in servaddr;
int socketfd = socket(AF_INET, SOCK_DGRAM, 0);
@@ -40,25 +41,18 @@ int main(int argc, char **argv){
return -1;
}
- servaddr.sin_family = AF_INET; // IPv4
- servaddr.sin_port = htons(port); // Server port
+ 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," ");
+ char send_str[2048] = { 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);
+ sendto(socketfd, wbuffer, len, MSG_CONFIRM, (const struct sockaddr*)&servaddr, sizeof(servaddr));
return 0;
}