#include <setjmp.h>
#include <sys/socket.h>
#include <stddef.h>
+#ifdef HAVE_PTHREAD
#include <pthread.h>
+#endif
-#include "common.h"
-#include "dataserv.h"
+#include "vblib.h"
const int safesigs[]={SIGQUIT,SIGINT,SIGTERM,SIGIOT,SIGALRM,-1}; //SIGCHLD->childsignal anyway
char vbnexact;
-const char *upsc_sshpath="/usr/bin/ssh"; /* upsetupconn()... */
-const char *upsc_dstport=DS_PORT;
void chk(const void *p)
{
vbsanity();
if (p) return;
- FATAL(CRIT,"NULL-check failure, memory exhausted? FATAL: %m");
+ VB_FATAL(CRIT,"NULL-check failure, memory exhausted? FATAL: %m");
}
#ifndef NDEBUG
#else
#define vbcheckno (0)
#endif
-pthread_mutex_t vbcheckmx=PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+#ifdef HAVE_PTHREAD
+static pthread_mutex_t vbcheckmx=PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static void vbchecklock (void)
-{ if (pthread_mutex_lock (&vbcheckmx)) FATAL(CRIT,"Mutex ""lock on vbcheck mx"); }
+{ if (pthread_mutex_lock (&vbcheckmx)) VB_FATAL(CRIT,"Mutex ""lock on vbcheck mx"); }
static void vbcheckunlock(void)
-{ if (pthread_mutex_unlock(&vbcheckmx)) FATAL(CRIT,"Mutex unlock on vbcheck mx"); }
+{ if (pthread_mutex_unlock(&vbcheckmx)) VB_FATAL(CRIT,"Mutex unlock on vbcheck mx"); }
+#else
+#define vbchecklock()
+#define vbcheckunlock()
+#endif
static char vbchecklist(struct varbuf *vb)
{
char *d;
for (d=s;(d=memchr(d,'\0',s+len-d));) { *d++=' '; tot++; }
- if (tot) logmsg((quiet_null?MYLOG_DEBUG:MYLOG_ERR),
- "%s() replaced %u '\\0's by ' ' in: %.*s",fname,tot,(int)len,s);
+ if (!tot) return;
+#define ARG "%s() replaced %u '\\0's by ' ' in: %.*s",fname,tot,(int)len,s
+#define VB_LOG1(a,b) VB_LOG(a,b)
+ if (quiet_null)
+ VB_LOG1(DEBUG,ARG);
+ else
+ VB_LOG1(ERR,ARG);
+#undef VB_LOG1
+#undef ARG
}
char *vbgetline(struct varbuf *vb,char term)
{
size_t len=strlen(s);
if (len>PSTR_MAX) {
- LOG(CRIT,"String longer (%u) than PSTRing max (%u)",len,PSTR_MAX);
+ VB_LOG(CRIT,"String longer (%u) than PSTRing max (%u)",len,PSTR_MAX);
len=PSTR_MAX;
dbg("vbpstrputstring-longer than MAX: \"%s\"\n",s);
}
else if ((size=vbsize(vbs,len))<len) len=size;
was=len;
if (len>PSTR_MAX) {
- LOG(CRIT,"String longer (%u) than PSTRing max (%u)",len,PSTR_MAX);
+ VB_LOG(CRIT,"String longer (%u) than PSTRing max (%u)",len,PSTR_MAX);
len=PSTR_MAX;
vbdebug(vbs,"vbpstrputstring-longer than MAX");
}
i=vsnprintf(buf,sizeof(buf),fmt,ap);
va_end(ap);
if (i==-1) {
- LOG(CRIT,"Buffer overflow (max=%u) during PSTR printf",PSTR_MAX);
+ VB_LOG(CRIT,"Buffer overflow (max=%u) during PSTR printf",PSTR_MAX);
i=PSTR_MAX;
}
assert(i>=0 && i<=PSTR_MAX && !buf[i]);
chgd++;
}
if (chgd)
- LOG(CRIT,"'\\0's found (%u total) in read PSTR \"%s\", changed to '?'",chgd,buf);
+ VB_LOG(CRIT,"'\\0's found (%u total) in read PSTR \"%s\", changed to '?'",chgd,buf);
return(buf);
}
if (!fgets(buf,sizeof(buf),f)) {
dbg("vbgetlinef: fgets=NULL\n");
if (feof(f)) return;
- FATAL(ERR,"linereading fail: %m");
+ VB_FATAL(ERR,"linereading fail: %m");
}
dbg("vbgetlinef: fgets: %s\n",buf);
if ((s=strchr(buf,'\n'))) break;
static const struct chat_cmdtab chat_cmdint[]={
{"help" ,0,chatfn_help ,"This help"},
+#if 0
{"quit" ,0,chatfn_quit ,"Close connection"},
{"exit" ,0,chatfn_quit ,"Close connection"},
+#endif
};
static void chatfn_help(void)
vbprintf(chat_vbout,"205 %d parameter%s found, %d expected!\n",chat_cmdpar,(chat_cmdpar==1?"":"s"),cmd->npars);
else {
vbprintf(chat_vbout,"001 Running command: %s\n",cmds);
- LOG(DEBUG,"%s is executing user command \"%s\"",who,cmds);
+ VB_LOG(DEBUG,"%s is executing user command \"%s\"",who,cmds);
(*cmd->fnc)();
}
}