comparison nnchat.c @ 239:b7e7ed741a18

Add unfinished code for logfile name parsing.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 20 Apr 2011 15:44:34 +0300
parents 6b1c67274f6c
children e85d453e82eb
comparison
equal deleted inserted replaced
235:87f434330547 239:b7e7ed741a18
923 } 923 }
924 924
925 return FALSE; 925 return FALSE;
926 } 926 }
927 927
928 char *logParseFilename(const char *fmt, int id)
929 {
930 size_t tmpLen = strlen(fmt) + 32;
931 char *res = NULL, tmpBuf[32];
932 const char *s = fmt;
933
934 if ((res = th_malloc(len)) == NULL)
935 return NULL;
936
937 while (*s) {
938 if (*s == '%') {
939 s++;
940 switch (*s) {
941 case 'i':
942
943 {
944 snprintf(tmpBuf, sizeof(tmpBuf), "%05d", id);
945 len -= strlen(tmpBuf) + 1;
946 if (len <= 0) {
947 res = th_realloc(res,
948 }
949 VPUTS(tmpBuf);
950 }
951 break;
952
953 case '%':
954 VPUTCH(res, '%');
955 break;
956
957 default:
958 VPUTCH(res, '%');
959 VPUTCH(res, *s);
960 break;
961 }
962 }
963 }
964 }
965
966
967 BOOL logFileOpen(void)
968 {
969 char *filename;
970
971 if (optLogFilename == NULL)
972 return FALSE;
973
974
975
976 if ((optLogFile = fopen(filename, "a")) == NULL) {
977 errMsg("Could not open logfile '%s' for appending!\n", filename);
978 th_free(filename);
979 return FALSE;
980 }
981 return TRUE;
982 }
983
984 BOOL logFileClose(void)
985 {
986 }
987
928 char *promptRequester(const char *info, BOOL allowEmpty) 988 char *promptRequester(const char *info, BOOL allowEmpty)
929 { 989 {
930 char tmpBuf[512], *ptr; 990 char tmpBuf[512], *ptr;
931 ssize_t pos; 991 ssize_t pos;
932 992
988 th_cfg_add_string_list(&tmpcfg, "ignore_list", &nnIgnoreList); 1048 th_cfg_add_string_list(&tmpcfg, "ignore_list", &nnIgnoreList);
989 th_cfg_add_section(&cfg, "general", tmpcfg); 1049 th_cfg_add_section(&cfg, "general", tmpcfg);
990 1050
991 tmpcfg = NULL; 1051 tmpcfg = NULL;
992 th_cfg_add_comment(&tmpcfg, "Chat server hostname or IP address"); 1052 th_cfg_add_comment(&tmpcfg, "Chat server hostname or IP address");
1053 th_cfg_add_string(&tmpcfg, "host", &optServer, optServer);
1054 th_cfg_add_comment(&tmpcfg, "Default port to connect to (8002 = public room, 8003 = passion pit, 8005 = members only)");
1055 th_cfg_add_int(&tmpcfg, "port", &optPort, optPort);
1056 th_cfg_add_section(&cfg, "server", tmpcfg);
1057
1058 tmpcfg = NULL;
1059 th_cfg_add_comment(&tmpcfg, "Enable logging");
993 th_cfg_add_string(&tmpcfg, "host", &optServer, optServer); 1060 th_cfg_add_string(&tmpcfg, "host", &optServer, optServer);
994 th_cfg_add_comment(&tmpcfg, "Default port to connect to (8002 = public room, 8003 = passion pit, 8005 = members only)"); 1061 th_cfg_add_comment(&tmpcfg, "Default port to connect to (8002 = public room, 8003 = passion pit, 8005 = members only)");
995 th_cfg_add_int(&tmpcfg, "port", &optPort, optPort); 1062 th_cfg_add_int(&tmpcfg, "port", &optPort, optPort);
996 th_cfg_add_section(&cfg, "server", tmpcfg); 1063 th_cfg_add_section(&cfg, "server", tmpcfg);
997 1064