VirtualBox

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

最後變更 在這個檔案從2243是 2243,由 bird 提交於 16 年 前

*: Updated copyright to 2009 and normalized name & email.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 2.1 KB
 
1/* $Id: solfakes.c 2243 2009-01-10 02:24:02Z bird $ */
2/** @file
3 * Fake Unix stuff for Solaris.
4 */
5
6/*
7 * Copyright (c) 2005-2009 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 "config.h"
30#include <errno.h>
31#include <stdio.h>
32#include <stdarg.h>
33#include <stdlib.h>
34#include <sys/stat.h>
35#include "solfakes.h"
36
37
38int asprintf(char **strp, const char *fmt, ...)
39{
40 int rc;
41 va_list va;
42 va_start(va, fmt);
43 rc = vasprintf(strp, fmt, va);
44 va_end(va);
45 return rc;
46}
47
48
49int vasprintf(char **strp, const char *fmt, va_list va)
50{
51 int rc;
52 char *psz;
53 size_t cb = 1024;
54
55 *strp = NULL;
56 for (;;)
57 {
58 va_list va2;
59
60 psz = malloc(cb);
61 if (!psz)
62 return -1;
63
64#ifdef va_copy
65 va_copy(va2, va);
66 rc = snprintf(psz, cb, fmt, va2);
67 va_end(va2);
68#else
69 va2 = va;
70 rc = snprintf(psz, cb, fmt, va2);
71#endif
72 if (rc < 0 || (size_t)rc < cb)
73 break;
74 cb *= 2;
75 free(psz);
76 }
77
78 *strp = psz;
79 return rc;
80}
81
82
83
84int sol_lchmod(const char *pszPath, mode_t mode)
85{
86 /*
87 * Weed out symbolic links.
88 */
89 struct stat s;
90 if ( !lstat(pszPath, &s)
91 && S_ISLNK(s.st_mode))
92 {
93 errno = -ENOSYS;
94 return -1;
95 }
96
97 return chmod(pszPath, mode);
98}
99
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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