Remove <readparamstring.h>.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-11-03 14:05:23 +01:00
parent 752153d801
commit 59edfdb787
4 changed files with 0 additions and 120 deletions

View File

@ -77,7 +77,6 @@ memcpy.o \
memmove.o \
memset.o \
op-new.o \
readparamstring.o \
rewind.o \
sort.o \
sprint.o \

View File

@ -1,36 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
readparamstring.h
A kinda dirty hack to ease transition to the /dev/video API.
*******************************************************************************/
#ifndef _READPARAMSTRING_H
#define _READPARAMSTRING_H 1
#include <features.h>
__BEGIN_DECLS
bool ReadParamString(const char* str, ...);
__END_DECLS
#endif

View File

@ -1,82 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
readparamstring.cpp
A kinda dirty hack to ease transition to the /dev/video API.
*******************************************************************************/
#include <errno.h>
#include <stdarg.h>
#include <string.h>
#include <readparamstring.h>
static char* Substring(const char* src, size_t offset, size_t length)
{
char* dest = new char[length + 1];
if ( !dest ) { return NULL; }
memcpy(dest, src + offset, length * sizeof(char));
dest[length] = 0;
return dest;
}
extern "C" bool ReadParamString(const char* str, ...)
{
if ( strchr(str, '\n') ) { errno = EINVAL; }
const char* keyname;
va_list args;
while ( *str )
{
size_t varlen = strcspn(str, ",");
if ( !varlen ) { str++; continue; }
size_t namelen = strcspn(str, "=");
if ( !namelen ) { errno = EINVAL; goto cleanup; }
if ( !str[namelen] ) { errno = EINVAL; goto cleanup; }
if ( varlen < namelen ) { errno = EINVAL; goto cleanup; }
size_t valuelen = varlen - 1 /*=*/ - namelen;
char* name = Substring(str, 0, namelen);
if ( !name ) { goto cleanup; }
char* value = Substring(str, namelen+1, valuelen);
if ( !value ) { delete[] name; goto cleanup; }
va_start(args, str);
while ( (keyname = va_arg(args, const char*)) )
{
char** nameptr = va_arg(args, char**);
if ( strcmp(keyname, name) ) { continue; }
*nameptr = value;
break;
}
va_end(args);
if ( !keyname ) { delete[] value; }
delete[] name;
str += varlen;
str += strspn(str, ",");
}
return true;
cleanup:
va_start(args, str);
while ( (keyname = va_arg(args, const char*)) )
{
char** nameptr = va_arg(args, char**);
delete[] *nameptr; *nameptr = NULL;
}
va_end(args);
return false;
}

View File

@ -36,7 +36,6 @@
#include <error.h>
#include <errno.h>
#include <termios.h>
#include <readparamstring.h>
// TODO: Provide this using asprintf or somewhere sane in user-space.
char* Combine(size_t NumParameters, ...)