#define ARRAY_SIZE(a) (sizeof((a))/sizeof(*(a)))
#define ARRAY_END(a) ((a) + ARRAY_SIZE((a)))
-
#define CTYPE(isfoobar,ch) (isfoobar((unsigned char)(ch)))
-
+#define COMMA ,
#endif /*COMMON_H*/
va_end(al);
}
-void do_dvprintf(const char *fmt, va_list al) {
+void ouvprintf_only(const char *fmt, va_list al) {
ovprintf(&cmdi.out, fmt,al);
}
-void do_dprintf(const char *fmt, ...) {
+void ouprintf_only(const char *fmt, ...) {
va_list al;
va_start(al,fmt);
- do_dvprintf(fmt,al);
+ ouvprintf_only(fmt,al);
va_end(al);
}
return EC_BadCmd;
}
-void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v) {
+void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v,
+ void (*qprintf)(const char *fmt, ...)) {
if (!pii->argsbits)
- ouprintf("picio %s %s\n", dirn, pii->name);
+ qprintf("picio %s %s\n", dirn, pii->name);
else if (!pii->vbits)
- ouprintf("picio %s %s %#x\n", dirn, pii->name, obj);
+ qprintf("picio %s %s %#x\n", dirn, pii->name, obj);
else
- ouprintf("picio %s %s %#x %d\n", dirn, pii->name, obj, v);
+ qprintf("picio %s %s %#x %d\n", dirn, pii->name, obj, v);
}
static void obc_error(OutBufferChain *ch, const char *e1, const char *e2) {
exit(-1);
}
+static void qouhex(const char *word, const Byte *command, int length,
+ void (*qprintf)(const char *fmt, ...)) {
+ qprintf("%s", word);
+ while (length--) qprintf(" %02x", *command++);
+ qprintf("\n");
+}
+
void ouhexo(const char *word, const Byte *command, int length) {
- ouprintf("%s", word);
- while (length--) ouprintf(" %02x", *command++);
- ouprintf("\n");
+ qouhex(word,command,length, ouprintf);
}
void ouhexi(const char *word, const Byte *command, int length) {
- ouhexo(word,command,length);
+ qouhex(word,command,length, ouprintf_only);
}
void die_vprintf_hook(const char *fmt, va_list al) {
else if (pii->noiselevel > picio_send_noise)
suppress= 1;
else
- oupicio("out",pii,obj,v);
+ oupicio("out",pii,obj,v,ouprintf);
}
if (!suppress && picio_send_noise >= 2)
/*---------- from/for realtime.c ----------*/
-void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v);
+void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v,
+ void (*qprintf)(const char *fmt, ...));
void ouhexi(const char *word, const Byte *command, int length);
void ouhexo(const char *word, const Byte *command, int length);
void ouvprintf(const char *fmt, va_list al);
void ouprintf(const char *fmt, ...);
-void do_dvprintf(const char *fmt, va_list al);
-void do_dprintf(const char *fmt, ...);
+void ouvprintf_only(const char *fmt, va_list al);
+void ouprintf_only(const char *fmt, ...);
#define DEBUGP(a,k) (dflags_##a & DBIT_##a##_##k)
#define COND_DPRINTF(cond, a,k, fmt, ...) \
- ((cond) ? do_dprintf("debug " #a "/" #k " : " fmt,##__VA_ARGS__) : (void)0)
+ ((cond) ? ouprintf_only("debug " #a "/" #k " : " fmt,##__VA_ARGS__) : (void)0)
#define DPRINTF(a,k,f,...) COND_DPRINTF(DEBUGP(a,k),a,k,f,##__VA_ARGS__)
#define DPRINTF1(a,k,f,...) COND_DPRINTF((DP)=DEBUGP(a,k), a,k,f,##__VA_ARGS__)
-#define DPRINTF2(f,...) ((DP) ? do_dprintf(f,##__VA_ARGS__) : (void)0)
+#define DPRINTF2(f,...) ((DP) ? ouprintf_only(f,##__VA_ARGS__) : (void)0)
/*---------- tbi ----------*/
if (!suppress && picio_send_noise >= 2)
ouhexi("picioh in msg", buf->d, buf->l);
- else
- if (simlog_full || sta_state < Sta_Settling ||
- !((pii->opcode==PICMSG_NMRADONE && obj==1) ||
- (pii->opcode==PICMSG_PONG && obj==pong_seq)))
- simlog_serial(buf->d, buf->l);
+
+ if (simlog_full || sta_state < Sta_Settling ||
+ !((pii->opcode==PICMSG_NMRADONE && obj==1) ||
+ (pii->opcode==PICMSG_PONG && obj==pong_seq)))
+ simlog_serial(buf->d, buf->l);
if (!pii) { ouprintf("picio in unknown\n"); return; }
if (!suppress)
- oupicio("in",pii,obj,v);
+ oupicio("in",pii,obj,v,ouprintf_only);
pii->input_fn(pii,buf,obj);
}
if (!(picio_send_noise <= 1 &&
segments[segn].owner &&
segments[segn].det_ignore))
- ouprintf("picio in-info detect %d %s\n",
- detyn, info_segments[segn].pname);
+ ouprintf_only("picio in-info detect %d %s\n",
+ detyn, info_segments[segn].pname);
return segn;
}