Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 1905 → Rev 1906

/programs/develop/libraries/newlib/argz/buf_findstr.c
0,0 → 1,44
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved.
*/
 
#include <errno.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
 
#include "buf_findstr.h"
 
/* Find string str in buffer buf of length buf_len. Point buf to character after string,
or set it to NULL if end of buffer is reached. Return 1 if found, 0 if not. */
int
_buf_findstr(const char *str, char **buf, size_t *buf_len)
{
int i = 0;
int j = 0;
 
for (i = 0; i < *buf_len; i++)
{
if (str[0] == (*buf)[i])
{
j = i;
while (str[j - i] && (str[j - i] == (*buf)[j])) j++;
if(str[j - i] == '\0')
{
*buf += j;
*buf_len -= j;
return 1;
}
}
}
 
if (i == *buf_len)
{
*buf += *buf_len;
*buf_len = 0;
}
 
return 0;
}
/programs/develop/libraries/newlib/argz/buf_findstr.h
0,0 → 1,12
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved.
*/
 
#include <sys/types.h>
 
/* Find string str in buffer buf of length buf_len. Point buf to
character after string, or set it to NULL if end of buffer is
reached. Return 1 if found, 0 if not. */
int _buf_findstr(const char *str, char **buf, size_t *buf_len);
/programs/develop/libraries/newlib/argz/envz_get.c
0,0 → 1,43
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved.
*/
 
#include <errno.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <envz.h>
 
#include "buf_findstr.h"
 
char *
_DEFUN (envz_get, (envz, envz_len, name),
const char *envz _AND
size_t envz_len _AND
const char *name)
{
char *buf_ptr = (char *)envz;
size_t buf_len = envz_len;
 
while(buf_len)
{
if (_buf_findstr(name, &buf_ptr, &buf_len))
{
if (*buf_ptr == '=')
{
buf_ptr++;
return (char *)buf_ptr;
}
else
{
if (*buf_ptr == '\0')
/* NULL entry. */
return NULL;
}
}
}
/* No matching entries found. */
return NULL;
}
/programs/develop/libraries/newlib/argz/.
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property