SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Is possible to implement stdarg output into SDL_RWops (vfprintf-like output) natively without middle buffers?

Open SDLBugzilla opened this issue 5 years ago • 7 comments

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.1 Reported for operating system, platform: All, All

Comments on the original bug report:

On 2017-02-02 08:55:21 +0000, Vitaly Novichkov wrote:

I had my own logger based on usage of vfprintf function which prints output log into the file with arguments sending into it without having extra buffer until I will send it into the stream. I trying to use SDL_RWops because of native UTF8 support in file paths (however, manual getting the FILE* descriptor from utf8 path is easy, but requires extra function calls on Windows to convert into UTF16 until I'll be able to call _wfopen()).

Would be cool if we can have SDL_RWprintV()-like function which receives format string with va_list thing which also would be useful to send formatted string DIRECTLY into real file stream without any middle buffers. The implementation I made over existing API uses vsnprintf with a middle buffer which is not a good solution (especially in a case when is needed to send buffer data directly into file stream).

Note: I know about SDL_Log, but because of 4096 buffer size limit in some cases may be not good. I also using logger to store crash dumps (which are may have any size)

On 2017-08-11 17:56:55 +0000, Sam Lantinga wrote:

Yes, this is a good idea for SDL 2.1

SDLBugzilla avatar Feb 11 '21 00:02 SDLBugzilla

removed the bug label

It's a suggestion to add a new API function I made a while ago. Gonna subscribe to it to get all news.

Wohlstand avatar May 29 '22 03:05 Wohlstand

Is there an associated PR for this?

slouken avatar May 30 '22 14:05 slouken

Not yet, but I could get a shot to craft it.

Wohlstand avatar May 30 '22 16:05 Wohlstand

Sure, go for it.

slouken avatar May 30 '22 17:05 slouken

It looks like this isn't going to make this milestone, so go ahead and add it to whichever milestone makes sense for you.

slouken avatar Jul 25 '22 22:07 slouken

Hello! Thanks for reminding me, I think I do try to make this as soon as possible, these weeks I was overloaded and hadn't any time to work on projects. However, dumb question: could you quickly explain how to properly add public functions into SDL2? I saw that among with function itself, there is also the so-called "dynapi" that lists the entire API of SDL2, and defines various macros to rename functions for some reason... And I may guess, there is something also.

Wohlstand avatar Jul 25 '22 23:07 Wohlstand

Don't worry about it, go ahead and implement it and add it to SDL_rwops.h, and we can include it for the 2.26.0 milestone with the appropriate dynamic API glue.

slouken avatar Jul 26 '22 00:07 slouken