Skip to content

Commit b1da85c

Browse files
authored
Merge pull request #5 from iphydf/help
Add --help flag.
2 parents cee5a1c + 45b9e3f commit b1da85c

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
![minitox](https://raw.github.com/hqwrong/minitox/master/minitox.jpeg "minitox")
44

5-
`minitox` is a minimal client written for [toxcore](https://github.com/TokTok/c-toxcore). It's an example of tox client implementation and also a toy which new developers came to tox can play and start with, therefore getting familiar with the project.
5+
`minitox` is a minimal client written for
6+
[toxcore](https://github.com/TokTok/c-toxcore). It's an example of tox client
7+
implementation and also a toy which new developers coming to tox can play and
8+
start with, therefore getting familiar with the project.
69

710
## Features
811

912
1. Single File and Small Codebase;
10-
11-
2. Fully Standalone(No 3rd libary needed, only rely on toxcore and system c lib);
12-
13+
2. Fully Standalone(No 3rd library needed, only rely on toxcore and system c lib);
1314
3. Covered most apis of Friend&Group, and more to go;
14-
15-
4. Fun to play with(Colored text, Async REPL, e.t.c).
15+
4. Fun to play with(Colored text, Async REPL, etc.).
1616

1717
## Build
1818

1919
The only lib required is [toxcore](https://github.com/TokTok/c-toxcore):
2020

21-
> gcc -o minitox -I <TOX_H_DIR> minitox.c -L <TOX_LIB_DIR> -Wl,-rpath <TOX_LIB_DIR> -ltoxcore
22-
21+
```sh
22+
$ gcc -o minitox minitox.c -I $TOX_H_DIR -L $TOX_LIB_DIR -Wl,-rpath $TOX_LIB_DIR -ltoxcore
23+
```

minitox.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <unistd.h>
1414
#include <fcntl.h>
1515

16-
#include <tox.h>
16+
#include <tox/tox.h>
1717

1818
/*******************************************************************************
1919
*
@@ -32,10 +32,10 @@ struct DHT_node {
3232
const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1];
3333
};
3434

35-
struct DHT_node bootstrap_nodes[] = {
35+
struct DHT_node bootstrap_nodes[] = {
3636

3737
// Setup tox bootrap nodes
38-
38+
3939
{"node.tox.biribiri.org", 33445, "F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67"},
4040
{"128.199.199.197", 33445, "B05C8869DBB4EDDD308F43C1A974A20A725A36EACCA123862FDE9945BF9D3E09"},
4141
{"2400:6180:0:d0::17a:a001", 33445, "B05C8869DBB4EDDD308F43C1A974A20A725A36EACCA123862FDE9945BF9D3E09"},
@@ -54,7 +54,7 @@ struct DHT_node bootstrap_nodes[] = {
5454

5555
/// Macros for terminal display
5656

57-
#define CODE_ERASE_LINE "\r\033[2K"
57+
#define CODE_ERASE_LINE "\r\033[2K"
5858

5959
#define RESET_COLOR "\x01b[0m"
6060
#define SELF_TALK_COLOR "\x01b[35m" // magenta
@@ -267,7 +267,7 @@ bool delfriend(uint32_t friend_num) {
267267
*p = f->next;
268268
if (f->name) free(f->name);
269269
if (f->status_message) free(f->status_message);
270-
while (f->hist) {
270+
while (f->hist) {
271271
struct ChatHist *tmp = f->hist;
272272
f->hist = f->hist->next;
273273
free(tmp);
@@ -296,7 +296,7 @@ bool delgroup(uint32_t group_num) {
296296
*p = cf->next;
297297
if (cf->peers) free(cf->peers);
298298
if (cf->title) free(cf->title);
299-
while (cf->hist) {
299+
while (cf->hist) {
300300
struct ChatHist *tmp = cf->hist;
301301
cf->hist = cf->hist->next;
302302
free(tmp);
@@ -387,7 +387,7 @@ void setup_arepl() {
387387
async_repl->prompt = malloc(LINE_MAX_SIZE);
388388

389389
strcpy(async_repl->prompt, CMD_PROMPT);
390-
390+
391391
// stdin and stdout may share the same file obj,
392392
// reopen stdin to avoid accidentally getting stdout modified.
393393

@@ -767,20 +767,20 @@ void bootstrap()
767767

768768
void setup_tox()
769769
{
770-
create_tox();
770+
create_tox();
771771
init_friends();
772772
bootstrap();
773773

774774
////// register callbacks
775-
775+
776776
// self
777777
tox_callback_self_connection_status(tox, self_connection_status_cb);
778778

779779
// friend
780780
tox_callback_friend_request(tox, friend_request_cb);
781781
tox_callback_friend_message(tox, friend_message_cb);
782782
tox_callback_friend_name(tox, friend_name_cb);
783-
tox_callback_friend_status_message(tox, friend_status_message_cb);
783+
tox_callback_friend_status_message(tox, friend_status_message_cb);
784784
tox_callback_friend_connection_status(tox, friend_connection_status_cb);
785785

786786
// group
@@ -804,7 +804,7 @@ void command_guide(int narg, char **args) {
804804
PRINT("As it pursued simplicity at the cost of robustness and efficiency,");
805805
PRINT("It should only be used for learning or playing with, instead of daily use.\n");
806806

807-
PRINT("Commands are any input lines with leading `/`,");
807+
PRINT("Commands are any input lines with leading `/`,");
808808
PRINT("Command args are seprated by blanks,");
809809
PRINT("while some special commands may accept any-character string, like `/setname` and `/setstmsg`.\n");
810810

@@ -1110,7 +1110,7 @@ void command_settitle(int narg, char **args) {
11101110
ERROR("! Invalid group contact index");
11111111
return;
11121112
}
1113-
1113+
11141114
char *title = args[1];
11151115
size_t len = strlen(title);
11161116
TOX_ERR_CONFERENCE_TITLE err;
@@ -1293,7 +1293,7 @@ void repl_iterate(){
12931293
if (cmd) {
12941294
char *tokens[cmd->narg];
12951295
int ntok = 0;
1296-
for (; l != NULL && ntok != cmd->narg; ntok++) {
1296+
for (; l != NULL && ntok != cmd->narg; ntok++) {
12971297
// if it's the last arg, then take the rest line.
12981298
char *tok = (ntok == cmd->narg - 1) ? l : poptok(&l);
12991299
tokens[ntok] = tok;
@@ -1315,7 +1315,14 @@ void repl_iterate(){
13151315
}
13161316

13171317

1318-
int main() {
1318+
int main(int argc, char **argv) {
1319+
if (argc == 2 && strcmp(argv[1], "--help") == 0) {
1320+
fputs("Usage: minitox\n", stdout);
1321+
fputs("\n", stdout);
1322+
fputs("Minitox does not take any arguments.\n", stdout);
1323+
return 0;
1324+
}
1325+
13191326
fputs("Type `/guide` to print the guide.\n", stdout);
13201327
fputs("Type `/help` to print command list.\n\n",stdout);
13211328

0 commit comments

Comments
 (0)