dplasa / FTPClientServer

Simple FTP Server and Client for the esp8266/esp32 with LittleFS and SPIFFS support
GNU Lesser General Public License v2.1
54 stars 29 forks source link

Clean up macro pseudo functions #4

Closed devyte closed 4 years ago

devyte commented 4 years ago

At a glance I saw some macros used like functions. They should be cleaned up to actually be functions. Example: CLIENT_SEND.

dplasa commented 4 years ago

I used those macros to pass variadic arguments to the printf_P() call. Glad to do it in actual functions but I don't see how. Suggestions?

devyte commented 4 years ago

Look up variable arguments in C/C++, i. e. myFunction(int blah, ...) (literally 3 dots as arg). In particular, the well known printf family is implemented with variable number of args. I think this is what you really intended.

dplasa commented 4 years ago

Yes sure. But passing variadic arguments from one function (e.g. from myFunction(const char* fmt, ...) to Print::printf(const char* fmt, ...)) doesn't really work.

That is, unless there would be a Stream::vprintf(const char *fmt, va_list arg) function available. But as far as I see, there is none available that supports stdarg.h's va_list.

devyte commented 4 years ago

I'm not sure about the details here, the last time I looked at propagating va was a long time ago. I guess what is needed is something like Print::vprintf and Print::print_P, and maybe refactor current methods if needed. If that is correct, how about a PR for the core, and then clean up here?

dplasa commented 4 years ago

Not sure if that is all needed, after seeing the implementation of the Print::printf(...) functions, I've changed my code accordingly.

devyte commented 4 years ago

The commit looks good.