mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 05:53:12 -07:00
Basic Session
This commit is contained in:
parent
ad587d5aa2
commit
a81de8f7b5
11 changed files with 445 additions and 3 deletions
|
@ -1,3 +1,5 @@
|
|||
|
||||
add_executable(chiaki-test
|
||||
main.c)
|
||||
main.c)
|
||||
|
||||
target_link_libraries(chiaki-test chiaki-lib)
|
38
test/main.c
38
test/main.c
|
@ -1,8 +1,42 @@
|
|||
|
||||
#include <chiaki/session.h>
|
||||
#include <chiaki/base64.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
printf("Sleepy...\n");
|
||||
if(argc != 6)
|
||||
{
|
||||
printf("Usage: %s <host> <registkey> <ostype> <auth> <morning (base64)>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ChiakiConnectInfo connect_info;
|
||||
connect_info.host = argv[1];
|
||||
connect_info.regist_key = argv[2];
|
||||
connect_info.ostype = argv[3];
|
||||
|
||||
size_t auth_len = strlen(argv[4]);
|
||||
if(auth_len > sizeof(connect_info.auth))
|
||||
auth_len = sizeof(connect_info.auth);
|
||||
memcpy(connect_info.auth, argv[4], auth_len);
|
||||
if(auth_len < sizeof(connect_info.auth))
|
||||
memset(connect_info.auth + auth_len, 0, sizeof(connect_info.auth) - auth_len);
|
||||
|
||||
size_t morning_size = sizeof(connect_info.morning);
|
||||
bool r = chiaki_base64_decode(argv[5], strlen(argv[5]), connect_info.morning, &morning_size);
|
||||
if(!r || morning_size != sizeof(connect_info.morning))
|
||||
{
|
||||
printf("morning invalid.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ChiakiSession session;
|
||||
chiaki_session_init(&session, &connect_info);
|
||||
chiaki_session_start(&session);
|
||||
chiaki_session_join(&session);
|
||||
chiaki_session_fini(&session);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue