Mercurial
annotate gara/main.c @ 157:2db6253f355d
[ThirdParty] Added highlight library for better readability on blog.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Tue, 13 Jan 2026 19:18:47 -0800 |
| parents | 19cccf6e866a |
| children |
| rev | line source |
|---|---|
|
45
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
1 #include "seobeo/seobeo.h" |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
2 #include "stdio.h" |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
3 |
| 91 | 4 void HandleClientRequest(Seobeo_Handle *p_cli_handle) |
| 5 { | |
|
45
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
6 char *hello = "Hello good sir"; |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
7 Seobeo_Handle_Queue(p_cli_handle, (uint8_t*)hello, 14); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
8 Seobeo_Handle_Flush(p_cli_handle); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
9 |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
10 while (1) |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
11 { |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
12 int n = Seobeo_Handle_Read(p_cli_handle); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
13 if (n > 0) |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
14 { |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
15 printf(p_cli_handle->read_buffer); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
16 Seobeo_Handle_Consume(p_cli_handle, n); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
17 } |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
18 } |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
19 } |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
20 |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
21 int main() |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
22 { |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
23 |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
24 printf("Server initializing\n"); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
25 const char *PORT = "3322"; |
|
66
a0f0ad5e42eb
[Misc] taking out capital P stuff.
June Park <parkjune1995@gmail.com>
parents:
45
diff
changeset
|
26 Seobeo_Handle *server = Seobeo_Stream_Handle_Server_Create(NULL, PORT); |
|
45
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
27 |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
28 printf("Server running\n"); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
29 while (1) |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
30 { |
|
66
a0f0ad5e42eb
[Misc] taking out capital P stuff.
June Park <parkjune1995@gmail.com>
parents:
45
diff
changeset
|
31 Seobeo_Handle *p_cli_handle = |
|
45
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
32 Seobeo_Stream_Handle_Server_Accept(server); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
33 if (!p_cli_handle) continue; |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
34 |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
35 if (fork() == 0) |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
36 { |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
37 HandleClientRequest(p_cli_handle); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
38 _exit(0); |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
39 } |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
40 } |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
41 |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
42 return 0; |
|
ac8626c7859c
[Gara] Re-writing basic logic in C and hoping that I can import that into Java.
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
43 } |