github.com/256dpi/max-go@v0.7.0/lib/max/ext_strings.h (about) 1 #ifndef _EXT_STRINGS_H_ 2 #define _EXT_STRINGS_H_ 3 4 #include <stddef.h> 5 6 #include "ext_prefix.h" 7 8 BEGIN_USING_C_LINKAGE 9 10 #ifndef strncpy_zero 11 /** Copy the contents of one string to another, in a manner safer than the standard strcpy() or strncpy(). 12 This is the prefered function to use for this operation in Max. 13 @ingroup misc 14 @param dst The destination string (already allocated) for the copy. 15 @param src The source string that will be copied. 16 @param size The number of chars allocated to the dst string. 17 */ 18 char *strncpy_zero(char *dst, const char* src, long size); 19 #endif 20 21 22 /** Concatenate the contents of one string onto the end of another, 23 in a manner safer than the standard strcat() or strncat(). 24 This is the prefered function to use for this operation in Max. 25 @ingroup misc 26 @param dst The destination string onto whose end the src string will be appended. 27 @param src The source string that will be copied. 28 @param size The number of chars allocated to the dst string. 29 */ 30 char *strncat_zero(char *dst, const char* src, long size); 31 32 33 /** Copy the contents of a string together with value substitutions, 34 in a manner safer than the standard sprintf() or snprintf(). 35 This is the prefered function to use for this operation in Max. 36 @ingroup misc 37 @param buffer The destination string (already allocated) for the copy. 38 @param count The number of chars allocated to the buffer string. 39 @param format The source string that will be copied, which may include sprintf() formatting codes for substitutions. 40 @param ... An array of arguments to be substituted into the format string. 41 */ 42 int snprintf_zero(char *buffer, size_t count, const char *format, ...); 43 44 45 #if TARGET_API_MAC_CARBON 46 #define CtoPstr(x) CopyCStringToPascal((const char *)(x),(unsigned char *)(x)) 47 #define PtoCstr(x) CopyPascalStringToC((ConstStr255Param)(x),(char *)(x)) 48 #endif // TARGET_API_MAC_CARBON 49 50 #define SPRINTF_MAXLEN 4096 51 52 // Legacy 53 54 void ctopcpy(unsigned char *p1, char *p2); 55 void ptoccpy(char *p1, unsigned char *p2); 56 void pstrcpy(unsigned char *p2, unsigned char *p1); 57 58 59 END_USING_C_LINKAGE 60 61 #endif // _EXT_STRINGS_H_