Skip to content

Commit

Permalink
something to do with c
Browse files Browse the repository at this point in the history
  • Loading branch information
Hri7566 committed Apr 6, 2023
1 parent fb4656b commit bf9f22e
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"${workspaceFolder}/**",
"${workspaceFolder}/**/*",
"${workspaceFolder}/c/include/**",
"${workspaceFolder}/c/include/**/*"
"${workspaceFolder}/c/include/**/*",
"${workspaceFolder}/c/include"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
Expand Down
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
"cmake.configureOnOpen": false,
"dotenv.enableAutocloaking": true,
"cmake.sourceDirectory": "${workspaceFolder}/c",
"C_Cpp.errorSquiggles": "enabled"
"C_Cpp.errorSquiggles": "enabled",
"files.associations": {
"main.h": "c",
"commands.h": "c",
"command.h": "c",
"stdint.h": "c"
}
}
10 changes: 0 additions & 10 deletions c/include/Command.h

This file was deleted.

6 changes: 3 additions & 3 deletions c/include/color_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#define BYTE char

int getStringSize(char* arr, int stopPoint);
char* red(char* txt);
void freeString(char* str);
int getStringSize(char *arr, int stopPoint);
char *red(char *txt);
void freeString(char *str);

#endif
6 changes: 0 additions & 6 deletions c/include/commands.h

This file was deleted.

9 changes: 7 additions & 2 deletions c/include/main.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#ifndef COSMIC_MAIN
#define COSMIC_MAIN

const char* get_test_string(void);
const char* handleMessage(int argc, char** argv);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const char *get_test_string(void);
const char *handleMessage(int argc, char **argv);
void testOutput(void);

#endif
22 changes: 14 additions & 8 deletions c/src/color_log.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
#include "color_log.h"

int getStringSize(BYTE* arr, int max) {
BYTE* currentByte = arr;
int getStringSize(BYTE *arr, int max)
{
BYTE *currentByte = arr;
int size = 0;
do {
do
{
currentByte += 1;
if (size >= max) {
if (size >= max)
{
break;
}
size++;
} while (*currentByte != 0x00);
return size;
}

char* red(char* txt) {
char *red(char *txt)
{
int size = getStringSize(txt, 2048) + 5 + 4;
char* newStr = malloc(size);
char *newStr = malloc(size);

newStr[0] = '\x1b';
newStr[1] = '[';
Expand All @@ -25,7 +29,8 @@ char* red(char* txt) {

int i;

for (i = 1; i < size; i++) {
for (i = 1; i < size; i++)
{
newStr[i] = txt[i - 1];
}

Expand All @@ -37,6 +42,7 @@ char* red(char* txt) {
return newStr;
}

void freeString(char* str) {
void freeString(char *str)
{
free(str);
}
15 changes: 0 additions & 15 deletions c/src/commands.c

This file was deleted.

22 changes: 11 additions & 11 deletions c/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@

#include "main.h"

const char* get_test_string(void) {
const char* hello = "This string of text was generated by C, not NodeJS.";
const char *get_test_string(void)
{
const char *hello = "This string of text was generated by C, not NodeJS.";
return hello;
}

const char* handleMessage(int argc, char** argv) {
const char* output = "";
printf("%s", argv[0]);

if (strcmp(argv[0], "*help")) {
output = "hello";
} else {
output = "nothing";
}
const char *handleMessage(int argc, char **argv)
{
const char *output = "";

return output;
}

void testOutput(void)
{
printf("hello c console\n");
}
4 changes: 2 additions & 2 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
enablestdin: true
enableDiscord: false
enableMPP: true
enableDiscord: true
enableMPP: false
mpp:
userset: false
3 changes: 2 additions & 1 deletion src/foreign/CosmicFFI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class CosmicFFI {
// 'get_test_string': [ref.types.CString, [ref.types.void]],
handleMessage: [
ref.types.CString,
[ref.types.int, ref.types.Object],
[ref.types.int, ref.types.Object]
],
testOutput: [ref.types.void, []]
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/stdin/CosmicClientStdin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export class CosmicClientStdin extends CosmicClient {
_id: "stdin",
name: "stdin",
color: "#ffffff",
id: "stdin",
id: "stdin"
},
timestamp: Date.now(),
timestamp: Date.now()
} as ChatMessage);
});

Expand Down

0 comments on commit bf9f22e

Please sign in to comment.