generated from ps2homebrew/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helloworld.c
70 lines (59 loc) · 1.78 KB
/
helloworld.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
// #include <tamtypes.h>
// #include <sifrpc.h>
#include <debug.h>
#include <unistd.h>
#include <kernel.h>
#include <string.h>
#include <stdlib.h>
#include <tap.h>
#include "ps2log.h"
// demo of strings
// from https://stackoverflow.com/a/4681415
char *join_strings(char *strings[], char *seperator, int count)
{
char *str = NULL; /* Pointer to the joined strings */
size_t total_length = 0; /* Total length of joined strings */
int i = 0; /* Loop counter */
/* Find total length of joined strings */
for (i = 0; i < count; i++)
total_length += strlen(strings[i]);
total_length++; /* For joined string terminator */
total_length += strlen(seperator) * (count - 1); // for seperators
str = (char *)malloc(total_length); /* Allocate memory for joined strings */
str[0] = '\0'; /* Empty string we can append to */
/* Append all the strings */
for (i = 0; i < count; i++) {
strcat(str, strings[i]);
if (i < (count - 1))
strcat(str, seperator);
}
return str;
}
static void printWelcomeInfo(int argc, char **argv)
{
char *cmdline;
LOG("version: %s\n", APP_VERSION);
cmdline = join_strings(argv, " ", argc);
LOG("cmdline: %s\n", cmdline);
free(cmdline);
}
int main(int argc, char *argv[])
{
// SifInitRpc(0);
LOG_INIT();
printWelcomeInfo(argc, argv);
plan(5);
is(argv[0], "host:helloworld.elf", "running from ps2link");
init_scr();
uint64_t index;
index = 0;
while (index < 99999999)
{
index++;
// LOG("Hello, World fr00000m %s v.%s !\n", APP_NAME, APP_VERSION);
printf("Hello world %i\n", index);
}
SleepThread();
return 0;
}