/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Helper functions to skip white spaces, find tokens, find separators and free
* memory.
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "commp_util.h"
/*
* Skip to the next non-whitespace
*/
int
{
return (0);
(*begin)++;
}
return (1);
}
/*
* Finds the token in the char buffer. *current will be pointing to the
* token when function returns. If the char buffer has leading token,
* it returns 1.
*/
int
{
break;
return (1);
(*current)++;
}
/* Checks for leading white space */
return (1);
else
return (0);
}
/*
* atoi function
*/
int
{
*num = 0;
begin++;
} else {
break;
}
}
return (EINVAL);
return (0);
}
/*
* Given a string converts it to unsigned long long int.
*/
int
{
*num = 0;
begin++;
} else {
break;
}
}
return (EINVAL);
return (0);
}
/*
* Given a string converts it to unsigned byte
*/
int
{
*num = 0;
begin++;
} else {
break;
}
}
return (EINVAL);
return (0);
}
/*
* Given a string converts it to unsigned int
*/
int
{
*num = 0;
begin++;
} else {
break;
}
}
return (EINVAL);
return (0);
}
/*
* allocates memory and copies string to new memory
*/
int
{
if (len == 0)
return (EINVAL);
return (ENOMEM);
return (0);
}
/*
* This function converts strings like "5d" to equivalent time in secs.
* For eg. 1h = 3600, 10d = 86400
*/
int
{
switch (*(end - 1)) {
case 'd':
break;
case 'h':
break;
case 'm':
break;
case 's':
factor = 1;
break;
default:
return (EINVAL);
}
--end;
}
return (EINVAL);
if (factor != 0)
return (0);
}