Skip to content

Commit 877e5f7

Browse files
committed
move usage back to main.c
1 parent b00f0d4 commit 877e5f7

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

h3c

53 Bytes
Binary file not shown.

handler.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,3 @@ void exit_handler(int arg)
6060
h3c_clean();
6161
exit(0);
6262
}
63-
64-
void usage(FILE *stream)
65-
{
66-
fprintf(stream, "Usage: h3c [OPTION]...\n");
67-
fprintf(stream, " -i <interface>\tspecify interface, required\n");
68-
fprintf(stream, " -u <username>\t\tspecify username, required\n");
69-
fprintf(stream, " -p <password>\t\tspecify password, optional\n");
70-
fprintf(stream, " -h\t\t\tshow this message\n");
71-
}

handler.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
*
2222
*/
2323

24+
#ifndef HANDLER_H_
25+
#define HANDLER_H_
26+
2427
#include <stdio.h>
2528

2629
int success_handler();
@@ -30,4 +33,4 @@ int unkown_eap_handler();
3033
int got_response_handler();
3134
void exit_handler(int arg);
3235

33-
void usage(FILE *stream);
36+
#endif /* HANDER_H_ */

main.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "h3c.h"
2626
#include "handler.h"
2727

28-
#define MALLOC_SIZE_FOR_PASSWORD 32
28+
void usage(FILE *stream);
2929

3030
int main(int argc, char **argv)
3131
{
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
8989

9090
if (h3c_init(interface) != SUCCESS)
9191
{
92-
printf("Failed to initialize: %s\n",strerror(errno));
92+
fprintf(stderr, "Failed to initialize: %s\n",strerror(errno));
9393
exit(-1);
9494
}
9595

@@ -98,7 +98,7 @@ int main(int argc, char **argv)
9898

9999
if (h3c_start() != SUCCESS)
100100
{
101-
printf("Failed to start: %s\n", strerror(errno));
101+
fprintf(stderr, "Failed to start: %s\n", strerror(errno));
102102
exit(-1);
103103
}
104104

@@ -108,10 +108,19 @@ int main(int argc, char **argv)
108108
unkown_eapol_handler, unkown_eap_handler, \
109109
got_response_handler) != SUCCESS)
110110
{
111-
printf("Failed to response: %s\n", strerror(errno));
111+
fprintf(stderr, "Failed to response: %s\n", strerror(errno));
112112
exit(-1);
113113
}
114114
}
115115

116116
return 0;
117117
}
118+
119+
void usage(FILE *stream)
120+
{
121+
fprintf(stream, "Usage: h3c [OPTION]...\n");
122+
fprintf(stream, " -i <interface>\tspecify interface, required\n");
123+
fprintf(stream, " -u <username>\t\tspecify username, required\n");
124+
fprintf(stream, " -p <password>\t\tspecify password, optional\n");
125+
fprintf(stream, " -h\t\t\tshow this message\n");
126+
}

0 commit comments

Comments
 (0)