Motr  M0
string.h File Reference
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lib/types.h"
Include dependency graph for string.h:

Go to the source code of this file.

Macros

#define __MOTR_LIB_STRING_H__
 
#define m0_streq(a, b)   (strcmp((a), (b)) == 0)
 
#define m0_strcaseeq(a, b)   (strcasecmp((a), (b)) == 0)
 
#define m0_strdup(s)   strdup((s))
 
#define m0_asprintf(s, fmt, ...)
 

Functions

const char * m0_bcount_with_suffix (char *buf, size_t size, m0_bcount_t c)
 
M0_INTERNAL void m0_strings_free (const char **arr)
 
M0_INTERNAL const char ** m0_strings_dup (const char **src)
 
M0_INTERNAL char * m0_vsnprintf (char *buf, size_t buflen, const char *format,...) __attribute__((format(printf
 
M0_INTERNAL char M0_INTERNAL bool m0_startswith (const char *prefix, const char *str)
 

Macro Definition Documentation

◆ __MOTR_LIB_STRING_H__

#define __MOTR_LIB_STRING_H__

Definition at line 26 of file string.h.

◆ m0_asprintf

#define m0_asprintf (   s,
  fmt,
  ... 
)
Value:
({ \
int __nr; \
char **__s = (s); \
__nr = asprintf(__s, (fmt), __VA_ARGS__); \
if (__nr <= 0) \
*__s = NULL; \
})
#define NULL
Definition: misc.h:38
char * fmt(const char *format,...) __attribute__((format(printf
static struct m0_addb2_source * s
Definition: consumer.c:39

Definition at line 44 of file string.h.

◆ m0_strcaseeq

#define m0_strcaseeq (   a,
 
)    (strcasecmp((a), (b)) == 0)

Definition at line 35 of file string.h.

◆ m0_strdup

#define m0_strdup (   s)    strdup((s))

Definition at line 43 of file string.h.

◆ m0_streq

#define m0_streq (   a,
 
)    (strcmp((a), (b)) == 0)

Definition at line 34 of file string.h.

Function Documentation

◆ m0_bcount_with_suffix()

const char* m0_bcount_with_suffix ( char *  buf,
size_t  size,
m0_bcount_t  c 
)

Converts m0_bcount_t number into a reduced string representation, calculating a magnitude and representing it as standard suffix like "Ki", "Mi", "Gi" etc. So, for example, 87654321 becomes "83 Mi".

Definition at line 32 of file string.c.

Here is the caller graph for this function:

◆ m0_startswith()

M0_INTERNAL char M0_INTERNAL bool m0_startswith ( const char *  prefix,
const char *  str 
)

Returns true iff ‘str’ starts with the specified ‘prefix’.

Definition at line 98 of file string.c.

Here is the caller graph for this function:

◆ m0_strings_dup()

M0_INTERNAL const char** m0_strings_dup ( const char **  src)

Definition at line 55 of file string.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_strings_free()

M0_INTERNAL void m0_strings_free ( const char **  arr)

Definition at line 45 of file string.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_vsnprintf()

M0_INTERNAL char* m0_vsnprintf ( char *  buf,
size_t  buflen,
const char *  format,
  ... 
)