4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
36 * generate a vector of pointers (arps) to the
37 * substrings in string "s".
38 * Each substring is separated by blanks and/or tabs.
39 * s -> string to analyze -- s GETS MODIFIED
40 * arps -> array of pointers -- count + 1 pointers
41 * count -> max number of fields
48 getargs(s
, arps
, count
)
49 register char *s
, *arps
[];
55 prev
= _uu_setlocale(LC_ALL
, "C");
56 for (i
= 0; i
< count
; i
++) {
57 while (*s
== ' ' || *s
== '\t')
64 while (*s
!= '\0' && *s
!= ' '
65 && *s
!= '\t' && *s
!= '\n')
69 (void) _uu_resetlocale(LC_ALL
, prev
);
74 * bsfix(args) - remove backslashes from args
76 * \123 style strings are collapsed into a single character
77 * \000 gets mapped into \N for further processing downline.
78 * \ at end of string is removed
79 * \t gets replaced by a tab
80 * \n gets replaced by a newline
81 * \r gets replaced by a carriage return
82 * \b gets replaced by a backspace
83 * \s gets replaced by a blank
84 * any other unknown \ sequence is left intact for further processing
92 register char *str
, *to
, *cp
;
96 prev
= _uu_setlocale(LC_ALL
, "C");
97 for (; *args
; args
++) {
99 for (to
= str
; *str
; str
++) {
112 for ( num
= 0, cp
= str
116 if ('0' <= *cp
&& *cp
<= '7') {
162 (void) _uu_resetlocale(LC_ALL
, prev
);
167 ** This routine is used so that the current
168 ** locale can be saved and then restored.
171 _uu_setlocale(int category
, char *locale
)
176 /* get current locale */
177 if ((tmp
= setlocale(category
, NULL
)) == NULL
)
180 /* allocate space for the current locale and copy it */
181 len
= strlen(tmp
) + 1;
183 if ((ret
= malloc(len
)) == NULL
)
186 strncpy(ret
, tmp
, len
);
188 /* now set the new locale */
189 if (setlocale(category
, locale
) == NULL
) {
197 ** Reset the previous locale, free memory
200 _uu_resetlocale(int category
, char *locale
)
204 (void) setlocale(category
, locale
);