/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2012 Milan Jurik. All rights reserved.
*/
/*
* BSD 3 Clause License
*
* Copyright (c) 2007, The Storage Networking Industry Association.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* - Neither the name of The Storage Networking Industry Association (SNIA)
* nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <cstack.h>
#include <ctype.h>
#include <tlm.h>
#include "tlm_proto.h"
/*
* Implementation of a list based stack class. The stack only holds
* pointers/references to application objects. The objects are not
* copied and the stack never attempts to dereference or access the
* data objects. Applications should treat cstack_t references as
* opaque handles.
*/
/*
* cstack_new
*
* Allocate and initialize a new stack, which is just an empty cstack_t.
* A pointer to the new stack is returned. This should be treated as an
* opaque handle by the caller.
*/
cstack_t *
cstack_new(void)
{
return (NULL);
return (stk);
}
/*
* cstack_delete
*
* Deallocate the stack. This goes through the list freeing all of the
* cstack nodes but not the data because we don't know how the data was
* allocated. A stack really should be empty before it is deleted.
*/
void
{
return;
}
}
}
/*
* cstack_push
*
* Push an element onto the stack. Allocate a new node and assign the
* data and len values. We don't care what about the real values of
* data or len and we never try to access them. The stack head will
* point to the new node.
*
* Returns 0 on success. Otherwise returns -1 to indicate overflow.
*/
int
{
return (-1);
}
return (-1);
return (0);
}
/*
* cstack_pop
*
* Pop an element off the stack. Set up the data and len references for
* the caller, advance the stack head and free the popped stack node.
*
* Returns 0 on success. Otherwise returns -1 to indicate underflow.
*/
int
{
return (-1);
}
return (-1);
}
if (data)
if (len)
return (0);
}
/*
* cstack_top
*
* Returns the top data element on the stack without removing it.
*
* Returns 0 on success. Otherwise returns -1 to indicate underflow.
*/
int
{
return (-1);
}
return (-1);
}
if (data)
if (len)
return (0);
}
/*
* match
*
* Matching rules:
* c Any non-special character matches itslef
* ? Match any character
* ab character 'a' followed by character 'b'
* S Any string of non-special characters
* AB String 'A' followed by string 'B'
* * Any String, including the empty string
*/
{
for (; ; ) {
switch (*patn) {
case 0:
return (*str == 0);
case '?':
if (*str != 0) {
str++;
patn++;
continue;
}
return (FALSE);
case '*':
patn++;
if (*patn == 0)
return (TRUE);
while (*str) {
return (TRUE);
str++;
}
return (FALSE);
default:
return (FALSE);
str++;
patn++;
continue;
}
}
}
/*
* Match recursive call
*/
int
{
/*
* "<" is a special pattern that matches only those names
* that do NOT have an extension. "." and ".." are ok.
*/
return (TRUE);
return (TRUE);
return (FALSE);
}
for (; ; ) {
switch (*patn) {
case 0:
return (*str == 0);
case '?':
if (*str != 0) {
str++;
patn++;
continue;
}
return (FALSE);
case '*':
patn++;
if (*patn == 0)
return (TRUE);
while (*str) {
return (TRUE);
str++;
}
return (FALSE);
default:
return (FALSE);
}
str++;
patn++;
continue;
}
}
/* NOT REACHED */
}
/*
* Linear matching against a list utility function
*/
static boolean_t
{
while (*sep != 0) {
/* compare this char with the seperator list */
return (TRUE);
sep++;
}
return (FALSE);
}
/*
* Returns the next entry of the list after
* each separator
*/
char *
{
while (**line != 0) {
/* hit a terminator, skip trailing terminators */
**line = 0;
}
break;
}
}
return (start);
}
/*
* oct_atoi
*
* Convert an octal string to integer
*/
int
oct_atoi(char *p)
{
int v = 0;
int c;
while (*p == ' ')
p++;
while ('0' <= (c = *p++) && c <= '7') {
v <<= 3;
v += c - '0';
}
return (v);
}
/*
* strupr
*
* Convert a string to uppercase using the appropriate codepage. The
* string is converted in place. A pointer to the string is returned.
* There is an assumption here that uppercase and lowercase values
* always result encode to the same length.
*/
char *
strupr(char *s)
{
char c;
unsigned char *p = (unsigned char *)s;
while (*p) {
c = toupper(*p);
*p++ = c;
}
return (s);
}
/*
* trim_whitespace
*
* Trim leading and trailing whitespace chars(as defined by isspace)
* from a buffer. Example; if the input buffer contained " text ",
* it will contain "text", when we return. We assume that the buffer
* contains a null terminated string. A pointer to the buffer is
* returned.
*/
char *
{
char *p = buf;
char *q = buf;
if (buf == 0)
return (0);
while (*p && isspace(*p))
++p;
while ((*q = *p++) != 0)
++q;
if (q != buf) {
while ((--q, isspace(*q)) != 0)
*q = '\0';
}
return (buf);
}
/*
* trim_name
*
* Trims the slash and dot slash from the beginning of the
* path name.
*/
char *
{
while (*nm) {
if (*nm == '/') {
nm++;
continue;
}
nm += 2;
continue;
}
break;
}
return (nm);
}
/*
* get_volname
*
* Extract the volume name from the path
*/
char *
{
int sp;
if (!path)
return (NULL);
return (NULL);
return (NULL);
}
*cp = '\0';
return (save);
}
/*
* fs_volexist
*
* Check if the volume exists
*/
{
char *p;
return (FALSE);
free(p);
return (FALSE);
}
free(p);
return (TRUE);
}
/*
* tlm_tarhdr_size
*
* Returns the size of the TLM_TAR_HDR structure.
*/
int
tlm_tarhdr_size(void)
{
return (sizeof (tlm_tar_hdr_t));
}
/*
* dup_dir_info
*
* Make and return a copy of the directory info.
*/
struct full_dir_info *
{
if (new_dir_info) {
sizeof (struct full_dir_info));
}
return (new_dir_info);
}
/*
* tlm_new_dir_info
*
* Create a new structure, set fh field to what is specified and the path
* to the concatenation of directory and the component
*/
struct full_dir_info *
{
return (NULL);
return (NULL);
}
return (fdip);
}
/*
* sysattr_rdonly
*
* Check if the attribute file is one of the readonly system
* attributes.
*/
int
{
}
/*
* sysattr_rw
*
* attributes.
*/
int
{
}