Changeset 831 in MondoRescue


Ignore:
Timestamp:
Sep 25, 2006, 1:07:16 PM (18 years ago)
Author:
andree
Message:

Add new header mr_string.h for mr_string.c. Use mr_strtok() from
mr_string.c and delete from libmondo-string.c. Add mr_string.c and
mr_string.h to Makefile.am. (Follow-up to r828.)

Location:
branches/stable/mondo/mondo/common
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/mondo/common/Makefile.am

    r541 r831  
    2424                       libmondo-string-EXT.h libmondo-tools-EXT.h \
    2525                       libmondo-verify-EXT.h  libmondo-stream-EXT.h \
    26                        newt-specific.h
     26                       newt-specific.h \
     27                       mr_string.c mr_string.h
  • branches/stable/mondo/mondo/common/libmondo-filelist.c

    r820 r831  
    117117#include "libmondo-gui-EXT.h"
    118118#include "libmondo-tools-EXT.h"
    119 
     119#include "mr_string.h"
    120120
    121121#include <time.h>
  • branches/stable/mondo/mondo/common/libmondo-raid.c

    r671 r831  
    4848#include "lib-common-externs.h"
    4949#include "libmondo-raid.h"
     50#include "mr_string.h"
    5051
    5152#ifdef __FreeBSD__
  • branches/stable/mondo/mondo/common/libmondo-string-EXT.h

    r565 r831  
    4444extern inline void turn_wildcard_chars_into_literal_chars(char *out,
    4545                                                          char *in);
    46 /* Valid external functions */
    47 extern char *mr_strtok(char *instr, const char *delims, int *lastpos);
  • branches/stable/mondo/mondo/common/libmondo-string.c

    r668 r831  
    11561156    return (type_of_backup);
    11571157}
    1158 
    1159 
    1160 /* New functions safe from a memory manageemnt point of view */
    1161 /* Developped by Andree Leidenfrost */
    1162 
    1163 char *mr_strtok(char *instr, const char *delims, int *lastpos) {
    1164 
    1165 char *token = NULL;
    1166 char *strptr = NULL;
    1167 size_t pos1 = 0;
    1168 size_t pos2 = 0;
    1169 
    1170 if (strlen(instr) <= *lastpos) {
    1171     *lastpos = 0;
    1172     return token;
    1173 }
    1174 
    1175 strptr = instr + *lastpos;
    1176 pos2 = strspn(strptr, delims);
    1177 strptr += pos2;
    1178 pos1 = strcspn(strptr, delims);
    1179 token = malloc(sizeof(*token)*(pos1+1));
    1180 strncpy(token, strptr, pos1);
    1181 token[pos1] = '\0';
    1182 *lastpos = *lastpos + pos1 + pos2 + 1;
    1183 
    1184 return token;
    1185 }
    1186 /* @} - end of stringGroup */
  • branches/stable/mondo/mondo/common/libmondo-string.h

    r565 r831  
    3434char *media_descriptor_string(t_bkptype);
    3535inline void turn_wildcard_chars_into_literal_chars(char *out, char *in);
    36 
    37 /* Valid external functions */
    38 char *mr_strtok(char *instr, const char *delims, int *lastpos);
  • branches/stable/mondo/mondo/common/mr_string.c

    r828 r831  
    1 // New generation of string handling functions
     1/*
     2 * mr_string.c - New generation of string handling functions
     3 */
    24
    3 
    4 // Safe alternative to standard function strok()
     5#include <stdio.h>
     6#include <string.h>
     7 
     8/**
     9 * Safe alternative to standard function strok()
     10 * @param instr
     11 * @param delims
     12 * @param lastpos
     13 * @return @p
     14 * @note this function allocates memory that needs to be freed by caller
     15 **/
    516char *mr_strtok(char *instr, const char *delims, int *lastpos)
    617{
     
    2940
    3041
    31 // Returns the string fed to it 'inptr' with all characters to escape given
    32 // in 'toesc' prepended by escaping character 'escchr'.
    33 // (Prepare strings for use in system() or popen() with this function.)
     42/**
     43 * Returns the string fed to it 'inptr' with all characters to escape given
     44 * in 'toesc' prepended by escaping character 'escchr'.
     45 * (Prepare strings for use in system() or popen() with this function.)
     46 * @param instr
     47 * @param toesc
     48 * @param escchr
     49 * @note this function allocates memory that needs to be freed by caller
     50 **/
    3451char *mr_stresc(char *instr, char *toesc, const char escchr)
    3552{
Note: See TracChangeset for help on using the changeset viewer.