Commit 4716881b authored by Richard Gobeille's avatar Richard Gobeille

engine: return length from printf-style functions

parent a359877b
......@@ -77,7 +77,7 @@ int FX_PlayLoopedRaw(char *ptr, uint32_t ptrlength, char *loopstart, char *loope
int FX_StartDemandFeedPlayback(void (*function)(const char** ptr, uint32_t* length, void* userdata), int bitdepth, int channels, int rate, int pitchoffset,
int vol, int left, int right, int priority, fix16_t volume, intptr_t callbackval, void* userdata);
int FX_SetPrintf(void(*function)(const char *, ...));
int FX_SetPrintf(int(*function)(const char *, ...));
extern int FX_ErrorCode;
extern int FX_MixRate;
......
......@@ -65,7 +65,7 @@ enum MV_Errors
MV_InvalidFile,
};
extern void (*MV_Printf)(const char *fmt, ...);
extern int (*MV_Printf)(const char *fmt, ...);
const char *MV_ErrorString(int ErrorNumber);
......@@ -152,7 +152,7 @@ struct MV_MusicRoutineBuffer
};
struct MV_MusicRoutineBuffer MV_GetMusicRoutineBuffer(void);
static inline void MV_SetPrintf(void (*function)(const char *, ...)) { if (function) MV_Printf = function; }
static inline void MV_SetPrintf(int (*function)(const char *, ...)) { if (function) MV_Printf = function; }
#ifdef __cplusplus
}
......
......@@ -319,7 +319,7 @@ int FX_StartDemandFeedPlayback(void (*function)(const char** ptr, uint32_t* leng
return handle;
}
int FX_SetPrintf(void (*function)(const char *, ...))
int FX_SetPrintf(int (*function)(const char *, ...))
{
MV_SetPrintf(function);
......
......@@ -88,7 +88,7 @@ VoiceNode VoicePool;
static int MV_MixPage;
void (*MV_Printf)(const char *fmt, ...) = initprintf;
int (*MV_Printf)(const char *fmt, ...) = initprintf;
static void (*MV_CallBackFunc)(intptr_t);
char *MV_MixDestination;
......
......@@ -227,9 +227,9 @@ void system_getcvars(void);
extern int32_t g_logFlushWindow;
void initputs(const char *);
#define buildputs initputs
void initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2)));
int initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2)));
#define buildprintf initprintf
void debugprintf(const char *,...) ATTRIBUTE((format(printf,1,2)));
int debugprintf(const char *,...) ATTRIBUTE((format(printf,1,2)));
int32_t handleevents(void);
int32_t handleevents_peekkeys(void);
......
......@@ -274,7 +274,7 @@ void OSD_ShowDisplay(int onf);
void OSD_Draw(void);
// just like printf
void OSD_Printf(const char *fmt, ...) ATTRIBUTE((format(printf,1,2)));
int OSD_Printf(const char *fmt, ...) ATTRIBUTE((format(printf,1,2)));
// just like puts
void OSD_Puts(const char *putstr, int const nolog = false);
......
......@@ -1597,17 +1597,19 @@ void OSD_Draw(void)
// and write it to the log file
//
void OSD_Printf(const char *fmt, ...)
int OSD_Printf(const char *fmt, ...)
{
static char tmpstr[8192];
va_list va;
va_start(va, fmt);
Bvsnprintf(tmpstr, sizeof(tmpstr), fmt, va);
int len = Bvsnprintf(tmpstr, sizeof(tmpstr), fmt, va);
va_end(va);
osdstrings.append(Xstrdup(tmpstr));
OSD_Puts(tmpstr);
return len;
}
......
......@@ -773,17 +773,19 @@ void system_getcvars(void)
//
// initprintf() -- prints a formatted string to the initialization window
//
void initprintf(const char *f, ...)
int initprintf(const char *f, ...)
{
va_list va;
char buf[2048];
va_start(va, f);
Bvsnprintf(buf, sizeof(buf), f, va);
int len = Bvsnprintf(buf, sizeof(buf), f, va);
va_end(va);
osdstrings.append(Xstrdup(buf));
initputs(buf);
return len;
}
......@@ -826,16 +828,18 @@ void initputs(const char *buf)
//
// debugprintf() -- prints a formatted debug string to stderr
//
void debugprintf(const char *f, ...)
int debugprintf(const char *f, ...)
{
#if defined DEBUGGINGAIDS && !(defined __APPLE__ && defined __BIG_ENDIAN__)
va_list va;
va_start(va,f);
Bvfprintf(stderr, f, va);
int len = Bvfprintf(stderr, f, va);
va_end(va);
return len;
#else
UNREFERENCED_PARAMETER(f);
return 0;
#endif
}
......
......@@ -556,17 +556,19 @@ void system_getcvars(void)
//
// initprintf() -- prints a formatted string to the initialization window
//
void initprintf(const char *f, ...)
int initprintf(const char *f, ...)
{
va_list va;
char buf[2048];
va_start(va, f);
Bvsnprintf(buf, sizeof(buf), f, va);
int len = Bvsnprintf(buf, sizeof(buf), f, va);
va_end(va);
osdstrings.append(Xstrdup(buf));
initputs(buf);
return len;
}
......@@ -601,7 +603,7 @@ void initputs(const char *buf)
//
// debugprintf() -- sends a formatted debug string to the debugger
//
void debugprintf(const char *f, ...)
int debugprintf(const char *f, ...)
{
#if 0 // def DEBUGGINGAIDS
va_list va;
......@@ -610,12 +612,14 @@ void debugprintf(const char *f, ...)
if (!IsDebuggerPresent()) return;
va_start(va,f);
Bvsnprintf(buf, 1024, f, va);
int len = Bvsnprintf(buf, 1024, f, va);
va_end(va);
OutputDebugString(buf);
return len;
#else
UNREFERENCED_PARAMETER(f);
return 0;
#endif
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment