Back to index

tetex-bin  3.0
Functions
strings.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Functions

 _nc_strstr (const char *haystack, const char *needle)
 _nc_str_init (string_desc *dst, char *src, size_t len)
 _nc_str_null (string_desc *dst, size_t len)
 _nc_str_copy (string_desc *dst, string_desc *src)
 _nc_safe_strcat (string_desc *dst, const char *src)
 _nc_safe_strcpy (string_desc *dst, const char *src)

Function Documentation

_nc_safe_strcat ( string_desc dst,
const char *  src 
)

Definition at line 106 of file strings.c.

{
    if (src != 0) {
       size_t len = strlen(src);

       if (len < dst->s_size) {
           if (dst->s_tail != 0) {
              strcpy(dst->s_tail, src);
              dst->s_tail += len;
           }
           dst->s_size -= len;
           return TRUE;
       }
    }
    return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

_nc_safe_strcpy ( string_desc dst,
const char *  src 
)

Definition at line 127 of file strings.c.

{
    if (src != 0) {
       size_t len = strlen(src);

       if (len < dst->s_size) {
           if (dst->s_head != 0) {
              strcpy(dst->s_head, src);
              dst->s_tail = dst->s_head + len;
           }
           dst->s_size = dst->s_init - len;
           return TRUE;
       }
    }
    return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

_nc_str_copy ( string_desc dst,
string_desc src 
)

Definition at line 96 of file strings.c.

{
    *dst = *src;
    return dst;
}

Here is the caller graph for this function:

_nc_str_init ( string_desc dst,
char *  src,
size_t  len 
)

Definition at line 70 of file strings.c.

{
    if (dst != 0) {
       dst->s_head = src;
       dst->s_tail = src;
       dst->s_size = len - 1;
       dst->s_init = dst->s_size;
       if (src != 0)
           *src = 0;
    }
    return dst;
}

Here is the caller graph for this function:

_nc_str_null ( string_desc dst,
size_t  len 
)

Definition at line 87 of file strings.c.

{
    return _nc_str_init(dst, 0, len);
}

Here is the call graph for this function:

_nc_strstr ( const char *  haystack,
const char *  needle 
)

Definition at line 47 of file strings.c.

{
    size_t len1 = strlen(haystack);
    size_t len2 = strlen(needle);
    char *result = 0;

    while ((len1 != 0) && (len1-- >= len2)) {
       if (!strncmp(haystack, needle, len2)) {
           result = haystack;
           break;
       }
       haystack++;
    }
    return result;
}

Here is the call graph for this function: