naev 0.12.6
nstring.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
11
12#include "attributes.h"
13
14#ifdef __MINGW_PRINTF_FORMAT
15#define BUILTIN_PRINTF_FORMAT __MINGW_PRINTF_FORMAT
16#else
17#define BUILTIN_PRINTF_FORMAT printf
18#endif
19
25#define PRINTF_FORMAT( i, j ) FORMAT( BUILTIN_PRINTF_FORMAT, i, j )
26
27/*const*/ char *strnstr( const char *haystack, const char *needle,
28 size_t size );
29char *strndup( const char *s, size_t n );
30
31PRINTF_FORMAT( 3, 4 )
32int scnprintf( char *text, size_t maxlen, const char *fmt, ... );
33
34int strsort( const void *p1, const void *p2 );
35int strsort_reverse( const void *p1, const void *p2 );
36
37#define NUM2STRLEN 16
38int num2str( char dest[NUM2STRLEN], double n, int decimals );
39const char *num2strU( double n, int decimals );
40
41void print_with_line_numbers( const char *str );
void print_with_line_numbers(const char *str)
Prints to stderr with line numbers.
Definition nstring.c:175
int num2str(char dest[NUM2STRLEN], double n, int decimals)
Converts a numeric value to a string.
Definition nstring.c:123
char * strnstr(const char *haystack, const char *needle, size_t size)
A bounded version of strstr. Conforms to BSD semantics.
Definition nstring.c:26
int strsort(const void *p1, const void *p2)
Sort function for sorting strings with qsort().
Definition nstring.c:83
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
Definition nstring.c:102
int strsort_reverse(const void *p1, const void *p2)
Order-reversed version of strsort().
Definition nstring.c:91
char * strndup(const char *s, size_t n)
Return a pointer to a new string, which is a duplicate of the string s (or, if necessary,...
Definition nstring.c:69
const char * num2strU(double n, int decimals)
Unsafe version of num2str that uses an internal buffer. Every call overwrites the return value.
Definition nstring.c:163