+/**
+ * \brief Add a substitution variable (local to this session)
+ * \param keyname the replacementstring to substitute
+ * \param keytype the kind of the key
+ * \param format the format string ala printf
+ * \param ... the arguments to substitute in the formatstring
+ */
+void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...)
+{
+ va_list arg_ptr;
+ char wbuf[SIZ];
+ void *vPtr;
+ wcsubst *ptr = NULL;
+ struct wcsession *WCC = WC;
+ size_t len;
+
+ /**
+ * First look if we're doing a replacement of
+ * an existing key
+ */
+ /*PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
+ if (GetHash(WCC->vars, keyname, keylen, &vPtr)) {
+ ptr = (wcsubst*)vPtr;
+ if (ptr->wcs_value != NULL)
+ free(ptr->wcs_value);
+ }
+ else /** Otherwise allocate a new one */
+ {
+ ptr = (wcsubst *) malloc(sizeof(wcsubst));
+ safestrncpy(ptr->wcs_key, keyname, sizeof ptr->wcs_key);
+ Put(WCC->vars, keyname, keylen, ptr, deletevar);
+ }
+
+ /** Format the string and save it */
+
+ va_start(arg_ptr, format);
+ len = vsnprintf(wbuf, sizeof wbuf, format, arg_ptr);
+ va_end(arg_ptr);
+
+ ptr->wcs_value = (char*) malloc(len + 1);
+ memcpy(ptr->wcs_value, wbuf, len + 1);
+ ptr->wcs_function = NULL;
+ ptr->wcs_type = keytype;
+}
+
+/**
+ * \brief Add a substitution variable (local to this session)
+ * \param keyname the replacementstring to substitute
+ * \param keytype the kind of the key
+ * \param format the format string ala printf
+ * \param ... the arguments to substitute in the formatstring
+ */
+void SVPut(char *keyname, size_t keylen, int keytype, char *Data)
+{
+ void *vPtr;
+ wcsubst *ptr = NULL;
+ struct wcsession *WCC = WC;
+
+
+ /**
+ * First look if we're doing a replacement of
+ * an existing key
+ */
+ /*PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
+ if (GetHash(WCC->vars, keyname, keylen, &vPtr)) {
+ ptr = (wcsubst*)vPtr;
+ if (ptr->wcs_value != NULL)
+ free(ptr->wcs_value);
+ }
+ else /** Otherwise allocate a new one */
+ {
+ ptr = (wcsubst *) malloc(sizeof(wcsubst));
+ safestrncpy(ptr->wcs_key, keyname, sizeof ptr->wcs_key);
+ Put(WCC->vars, keyname, keylen, ptr, deletevar);
+ }
+
+ ptr->wcs_function = NULL;
+ ptr->wcs_type = keytype;
+ ptr->wcs_value = strdup(Data);
+}
+