VirtualBox

source: kBuild/trunk/src/kmk/kmkbuiltin/solfakes.c@ 2101

Last change on this file since 2101 was 2019, checked in by bird, 16 years ago

GPLv2 -> GPLv3. See Ticket #44 for clarifications. Fixes #44.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/* $Id: solfakes.c 2019 2008-11-02 00:21:05Z bird $ */
2/** @file
3 * Fake Unix stuff for Solaris.
4 */
5
6/*
7 * Copyright (c) 2005-2008 knut st. osmundsen <[email protected]>
8 *
9 * This file is part of kBuild.
10 *
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild. If not, see <http://www.gnu.org/licenses/>
23 *
24 */
25
26/*******************************************************************************
27* Header Files *
28*******************************************************************************/
29#include <errno.h>
30#include <stdio.h>
31#include <stdarg.h>
32#include <stdlib.h>
33#include <sys/stat.h>
34#include "solfakes.h"
35
36
37int asprintf(char **strp, const char *fmt, ...)
38{
39 int rc;
40 va_list va;
41 va_start(va, fmt);
42 rc = vasprintf(strp, fmt, va);
43 va_end(va);
44 return rc;
45}
46
47
48int vasprintf(char **strp, const char *fmt, va_list va)
49{
50 int rc;
51 char *psz;
52 size_t cb = 1024;
53
54 *strp = NULL;
55 for (;;)
56 {
57 va_list va2;
58
59 psz = malloc(cb);
60 if (!psz)
61 return -1;
62
63#ifdef va_copy
64 va_copy(va2, va);
65 rc = snprintf(psz, cb, fmt, va2);
66 va_end(va2);
67#else
68 va2 = va;
69 rc = snprintf(psz, cb, fmt, va2);
70#endif
71 if (rc < 0 || (size_t)rc < cb)
72 break;
73 cb *= 2;
74 free(psz);
75 }
76
77 *strp = psz;
78 return rc;
79}
80
81
82
83int sol_lchmod(const char *pszPath, mode_t mode)
84{
85 /*
86 * Weed out symbolic links.
87 */
88 struct stat s;
89 if ( !lstat(pszPath, &s)
90 && S_ISLNK(s.st_mode))
91 {
92 errno = -ENOSYS;
93 return -1;
94 }
95
96 return chmod(pszPath, mode);
97}
98
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette