Mercurial > hg > nnchat
comparison main.c @ 564:6e5789cbb4d4
Change network layer error/info message passing API to pass direct strings
instead of fmt+ap varargs in the connection context callback functions. Also
rename the callback functions in the main program.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 15 Nov 2012 20:27:44 +0200 |
parents | c3e4e8f3c658 |
children | de1af9652fef |
comparison
equal
deleted
inserted
replaced
563:c3e4e8f3c658 | 564:6e5789cbb4d4 |
---|---|
381 va_end(ap); | 381 va_end(ap); |
382 } | 382 } |
383 } | 383 } |
384 | 384 |
385 | 385 |
386 void errorFunc(struct _nn_conn_t *conn, const char *fmt, va_list ap) | 386 void nn_network_errfunc(struct _nn_conn_t *conn, const char *msg) |
387 { | 387 { |
388 (void) conn; | 388 (void) conn; |
389 errorMsgV(fmt, ap); | 389 errorMsg("%s", msg); |
390 } | 390 } |
391 | 391 |
392 | 392 |
393 void messageFunc(struct _nn_conn_t *conn, const char *fmt, va_list ap) | 393 void nn_network_msgfunc(struct _nn_conn_t *conn, const char *msg) |
394 { | 394 { |
395 (void) conn; | 395 (void) conn; |
396 printMsgV(NULL, LOG_STAMP | LOG_WINDOW | LOG_FILE, fmt, ap); | 396 printMsgConst(NULL, LOG_STAMP | LOG_WINDOW | LOG_FILE, msg); |
397 } | 397 } |
398 | 398 |
399 | 399 |
400 BOOL checkNameList(qlist_t *list, const char *name) | 400 BOOL checkNameList(qlist_t *list, const char *name) |
401 { | 401 { |
1980 errorMsg("Username and/or password not specified.\n"); | 1980 errorMsg("Username and/or password not specified.\n"); |
1981 goto err_exit; | 1981 goto err_exit; |
1982 } | 1982 } |
1983 | 1983 |
1984 // Create a connection | 1984 // Create a connection |
1985 conn = nn_conn_new(errorFunc, messageFunc); | 1985 conn = nn_conn_new(nn_network_errfunc, nn_network_msgfunc); |
1986 if (conn == NULL) | 1986 if (conn == NULL) |
1987 { | 1987 { |
1988 errorMsg("Could not create connection structure.\n"); | 1988 errorMsg("Could not create connection structure.\n"); |
1989 goto err_exit; | 1989 goto err_exit; |
1990 } | 1990 } |