/*
* 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* Copyright (c) 1987, 1988 Microsoft Corporation */
/* All Rights Reserved */
#include "lint.h"
#include "libc.h"
#include <stdio.h>
#include <stdlib.h>
#include <deflt.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "tsd.h"
struct thr_data {
char *buf;
};
static int defopen_common(const char *, struct thr_data *);
static void strip_quotes(char *);
/*
* destructor for per-thread data, registered with tsdalloc()
*/
static void
{
}
}
}
/*
* get the per-thread-data-item for the calling thread
*/
static struct thr_data *
get_thr_data(void)
{
return (thr_data);
}
/*
* defopen() - declare defopen filename
*
* defopen(fn)
* char *fn
*
* If 'fn' is non-null; it is a full pathname of a file
* which becomes the one read by subsequent defread() calls.
* If 'fn' is null the defopen file is closed.
*
* see defread() for more details.
*
* EXIT returns 0 if ok
* returns -1 if error
*/
int
{
}
/*
* defopen_r() - declare defopen filename (reentrant)
*
* defopen_r(const char *fn)
*
* 'fn' is a full pathname of a file which becomes the one read
* by subsequent defread_r() calls. defopen_r returns a pointer
* to the internally allocated buffer containing the file descriptor.
* The pointer should be specified to the following defread_r and
* defcntl_r functions. As the pointer to be returned points to
* the libc lmalloc'd memory, defclose_r must be used to close
* the defopen file and to release the allocated memory. Caller
* must not try to release the memory by free().
*
* see defread_r() for more details.
*
* EXIT returns non-NULL pointer if success
* returns NULL if error
*/
void *
{
/* memory allocated by lmalloc gets initialized to zeros */
return (NULL);
}
return ((void *)thr_data);
}
static int
{
return (-1);
}
return (0);
return (-1);
/*
* We allocate the big buffer only if the fopen() succeeds.
* Notice that we deallocate the buffer only when the thread exits
* for defopen().
* There are misguided applications that assume that data returned
* by defread() continues to exist after defopen(NULL) is called.
*/
return (-1);
}
return (0);
}
/*
* defread() - read an entry from the defopen file
*
* defread(cp)
* char *cp
*
* The defopen data file must have been previously opened by
* defopen(). defread scans the data file looking for a line
* which begins with the string '*cp'. If such a line is found,
* defread returns a pointer to the first character following
* the matched string (*cp). If no line is found or no file
* is open, defread() returns NULL.
*
* Note that there is no way to simultaneously peruse multiple
* defopen files; since there is no way of indicating 'which one'
* to defread(). If you want to peruse a secondary file you must
* recall defopen(). If you need to go back to the first file,
* you must call defopen() again.
*/
char *
{
}
/*
* defread_r() - read an entry from the defopen file
*
* defread_r(const char *cp, void *ptr)
*
* defread_r scans the data file associated with the pointer
* specified by 'ptr' that was returned by defopen_r(), and
* looks for a line which begins with the string '*cp'.
* If such a line is found, defread_r returns a pointer to
* the first character following the matched string (*cp).
* If no line is found or no file is open, defread_r() returns NULL.
*/
char *
{
char *buf_tmp;
int i;
return (NULL);
;
else
break; /* line too long */
/* found it */
/* strip quotes if requested */
}
ret_ptr++;
break;
}
}
break;
}
}
}
return (ret_ptr);
}
/*
* defcntl -- default control
*
* SYNOPSIS
* oldflags = defcntl(cmd, arg);
*
* ENTRY
* cmd Command. One of DC_GET, DC_SET.
* arg Depends on command. If DC_GET, ignored.
* If DC_SET, new flags value, created by ORing
* the DC_* bits.
* RETURN
* oldflags Old value of flags. -1 on error.
* NOTES
* The following commands are implemented:
*
* DC_CASE: respect(on)/ignore(off) case
* DC_NOREWIND: don't(on)/do(off) reqind in defread
* DC_STRIP_QUOTES: strip(on)/leave(off) qoates
*/
int
{
}
/*
* defcntl_r -- default control
*
* SYNOPSIS
* oldflags = defcntl_r(int cmd, int arg, void *defp);
*
* ENTRY
* cmd Command. One of DC_GET, DC_SET.
* arg Depends on command. If DC_GET, ignored.
* If DC_SET, new flags value, created by ORing
* the DC_* bits.
* defp pointer to the defopen'd descriptor
*
* RETURN
* oldflags Old value of flags. -1 on error.
* NOTES
* The following commands are implemented:
*
* DC_CASE: respect(on)/ignore(off) case
* DC_NOREWIND: don't(on)/do(off) reqind in defread
* DC_STRIP_QUOTES: strip(on)/leave(off) qoates
*/
int
{
int oldflags;
return (-1);
switch (cmd) {
case DC_GETFLAGS: /* query */
break;
case DC_SETFLAGS: /* set */
break;
default: /* error */
oldflags = -1;
break;
}
return (oldflags);
}
/*
* defclose_r() - close defopen file
*
* defclose_r(void *defp)
*
* defclose_r closes the defopen file associated with the specified
* pointer and releases the allocated resources.
*/
void
{
}
/*
* strip_quotes -- strip double (") or single (') quotes from a buffer
*
* ENTRY
* ptr initial string
*
* EXIT
* ptr string with quotes (if any) removed
*/
static void
{
while (*ptr != '\0') {
} else {
strip_ptr++;
}
}
ptr++;
}
*strip_ptr = '\0';
}
}