rte_string_fns.h(3)

πŸ’– rte_string_fns.h πŸ’–

okay bestie, so this is rte_string_fns.h β€” a whole header from the <bold>Library Functions Manual</bold> section of the DPDK docs, and it's literally just string stuff that's here to replace your libc faves. no cap, it's giving "I do what strtok does but better and with more ✨boundaries✨". let's get into it 🫢


🌸 SYNOPSIS 🌸

the includes you're gonna want, verbatim, don't @ me:

#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <rte_common.h>
#include <rte_compat.h>

✨ Functions ✨

  • int rte_strsplit (char *string, int stringlen, char **tokens, int maxtokens, char delim)
  • ssize_t rte_strscpy (char *dst, const char *src, size_t dsize)
  • static __rte_experimental const char * rte_str_skip_leading_spaces (const char *src)
  • __rte_experimental size_t rte_basename (const char *path, char *buf, size_t buflen)

πŸ¦‹ Detailed Description πŸ¦‹

String-related functions as replacement for libc equivalents β€” that's it, that's the whole vibe. it's the cool older sibling of the libc string functions you already know.

Definition in file rte_string_fns.h.


πŸ‘‘ Function Documentation πŸ‘‘

πŸ“ int rte_strsplit (char * string, int stringlen, char ** tokens, int maxtokens, char delim)

okay so this one takes your string parameter and splits it at character delim β€” up to maxtokens-1 times, which gives you maxtokens resulting tokens. yes she counts like that, it's math, stay with me πŸ’…

just like strtok or strsep, this modifies its input string, by replacing instances of delim with '\0'. so if you needed that original string intact... bestie. it's gone. gone gone. πŸ™ˆ

all the resultant tokens get handed back in the tokens array, and that array must have enough entries to hold maxtokens. don't be out here passing a tiny array, I'm begging.

Parameters

  • string β€” the input string to be split into tokens
  • stringlen β€” the max length of the input buffer
  • tokens β€” the array to hold the pointers to the tokens in the string
  • maxtokens β€” the number of elements in the tokens array. at most, maxtokens-1 splits of the string will be done.
  • delim β€” the character on which the split of the data will be done

Returns

The number of tokens in the tokens array. slay πŸŽ€


πŸ’œ ssize_t rte_strscpy (char * dst, const char * src, size_t dsize)

Copy string src to buffer dst of size dsize. At most dsize-1 chars will be copied. Always NUL-terminates, unless (dsize == 0) β€” that one edge case is the only exception, periodt.

Parameters

  • dst β€” the destination string.
  • src β€” the input string to be copied.
  • dsize β€” length in bytes of the destination buffer.

Returns

The number of bytes copied (terminating NUL-byte excluded) on success. -E2BIG if the destination buffer is too small. rte_errno is set β€” so like, go check it, she's telling you something 🫢


🧚 __rte_experimental const char * rte_str_skip_leading_spaces (const char * src) [inline], [static]

⚠️ Warning β€” EXPERIMENTAL: this API may change without prior notice. fr fr, don't build your whole personality on it.

Search for the first non whitespace character. that's the whole job. she's just skipping the spaces bestie πŸ’…

Parameters

  • src β€” the input string to be analysed.

Returns

The address of the first non whitespace character. iconic.

Definition at line 142 of file rte_string_fns.h.


🌈 __rte_experimental size_t rte_basename (const char * path, char * buf, size_t buflen)

⚠️ Warning β€” EXPERIMENTAL: this API may change without prior notice. same energy, no cap.

Provides the final component of a path, similar to POSIX basename function. the way that this one just works everywhere?? obsessed. 😭

This API provides the similar behaviour on all platforms, Linux, BSD, Windows, hiding the implementation differences. cross-platform queen πŸ‘‘

  • It does not modify the input path.
  • The output buffer is passed as an argument, and the result is copied into it.
  • Expected output is the last component of the path, or the path itself if it does not contain a directory separator.
  • If the final component is too long to fit in the output buffer, it will be truncated.
  • For empty or NULL input paths, output buffer will contain the string ".".
  • Supports up to PATH_MAX (BSD/Linux) or _MAX_PATH (Windows) characters in the input path.

Parameters

  • path β€” the input path string. not modified by this function. (she would never πŸ₯Ί)
  • buf β€” the buffer to hold the resultant basename. must be large enough to hold the result, otherwise basename will be truncated.
  • buflen β€” the size of the buffer in bytes.

Returns

The number of bytes that were written to buf (excluding the terminating '\0'). If the return value is >= buflen, truncation occurred. Return (size_t)-1 on error (Windows only). yeah the Windows-only error is quirky but she's doing her best πŸ’€


πŸŽ€ Author πŸŽ€

Generated automatically by Doxygen for DPDK from the source code. (not a human, just a robot doing its little thing ✨)


okay that's the whole page bestie, you ate it up πŸ’– this was DPDK, Version 25.11.3, from the rte_string_fns.h(3) manual page β€” go forth and split strings responsibly, ily 🫢🌸

πŸ“¦ where this page comes from