From: <da...@us...> - 2002-09-21 16:14:38
|
Update of /cvsroot/cerber/cerb-ng/kcerb In directory usw-pr-cvs1:/tmp/cvs-serv25677/kcerb Modified Files: cerb_action.c cerb_action.h cerb_globals.h cerb_malloc.c Log Message: - Added operation genstr() and description about it to README.pl file. - We don't allocate memory for fcb_malloc() comments so we shouldn't try to free it. Index: cerb_action.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_action.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** cerb_action.c 21 Sep 2002 14:38:29 -0000 1.19 --- cerb_action.c 21 Sep 2002 16:14:34 -0000 1.20 *************** *** 91,95 **** fcb_op_tmp, /* ECB_CHKARGS_O */ fcb_op_tmp, /* ECB_CHKENVS_O */ ! fcb_op_log /* ECB_LOG_O */ }; --- 91,96 ---- fcb_op_tmp, /* ECB_CHKARGS_O */ fcb_op_tmp, /* ECB_CHKENVS_O */ ! fcb_op_log, /* ECB_LOG_O */ ! fcb_op_genstr /* ECB_GENSTR_O */ }; *************** *** 1080,1091 **** MCB_XDEBUG(EINVAL, "To few arguments."); ! if (v[1]->v_type != CB_STR_T || ! (v[0]->v_type != CB_DEF_T && v[0]->v_type != CB_UDEF_T)) { MCB_XDEBUG(EINVAL, "Invalid type of format string."); - } ! if (v[1]->v_id == ECB_ARG_I && MCB_CHKADDR((char *)v[1]->v_val)) { ! MCB_XDEBUG(EFAULT, "Invalid address of format string."); ! } if ((error = fcb_vprintf(buf, sizeof buf, (char *)v[1]->v_val, v + 2, --- 1081,1089 ---- MCB_XDEBUG(EINVAL, "To few arguments."); ! if (v[1]->v_type != CB_STR_T) MCB_XDEBUG(EINVAL, "Invalid type of format string."); ! if (v[0]->v_type != CB_DEF_T && v[0]->v_type != CB_UDEF_T) ! MCB_XDEBUG(EINVAL, "Invalid type of log level number."); if ((error = fcb_vprintf(buf, sizeof buf, (char *)v[1]->v_val, v + 2, *************** *** 1095,1098 **** --- 1093,1127 ---- log(v[0]->v_val, "CerbNG: %s\n", buf); + + return (0); + } + + int + fcb_op_genstr(CB_OPARGS) + { + char *buf; + int error; + + if (nvals < 1) + MCB_XDEBUG(EINVAL, "To few arguments."); + + if (v[1]->v_type != CB_STR_T) + MCB_XDEBUG(EINVAL, "Invalid type of format string."); + + if ((buf = fcb_malloc("fcb_op_genstr()", CB_GENSTRSIZE_G, + M_NOWAIT)) == NULL) { + MCB_XDEBUG(ENOMEM, "Cannot allocate memory for string."); + } + fcb_mtemp_add(buf); + + if ((error = fcb_vprintf(buf, CB_GENSTRSIZE_G, (char *)v[1]->v_val, + v + 1, nvals - 1)) != 0) { + MCB_XDEBUG(error, "Error while parsing."); + } + + retv->v_id = ECB_CONST_I; + retv->v_val = (register_t)buf; + retv->v_type = CB_STR_T; + retv->v_size = strlen(buf) + 1; return (0); Index: cerb_action.h =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_action.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** cerb_action.h 21 Sep 2002 14:38:29 -0000 1.15 --- cerb_action.h 21 Sep 2002 16:14:34 -0000 1.16 *************** *** 79,82 **** --- 79,83 ---- ECB_CHKENVS_O, /* chkenvs() */ ECB_LOG_O, /* log() */ + ECB_GENSTR_O, /* genstr() */ ECB_MAXFUN_O /* number of functions */ *************** *** 106,109 **** --- 107,111 ---- int fcb_op_tmp(CB_OPARGS); int fcb_op_log(CB_OPARGS); + int fcb_op_genstr(CB_OPARGS); /* Index: cerb_globals.h =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_globals.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** cerb_globals.h 21 Sep 2002 14:38:29 -0000 1.11 --- cerb_globals.h 21 Sep 2002 16:14:34 -0000 1.12 *************** *** 20,23 **** --- 20,25 ---- #define CB_LOGBUFSIZE_G 256 /* Size of buffer for logs */ + #define CB_GENSTRSIZE_G 1024 /* Size of buffer for string generated + by genstr() operation */ /* Index: cerb_malloc.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_malloc.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cerb_malloc.c 21 Sep 2002 14:38:29 -0000 1.6 --- cerb_malloc.c 21 Sep 2002 16:14:34 -0000 1.7 *************** *** 149,153 **** if (tmp->m_addr == addr) { free(addr, M_TEMP); - free(tmp->m_desc, M_TEMP); SLIST_REMOVE(&vcb_malloc_head, tmp, scb_malloc, m_next); free(tmp, M_TEMP); --- 149,152 ---- |