~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to winpr/libwinpr/environment/environment.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.1.9) (9.1.17 sid)
  • Revision ID: package-import@ubuntu.com-20141111122050-wyr8hrnwco9fcmum
Tags: 1.1.0~git20140921.1.440916e+dfsg1-2ubuntu1
* Merge with Debian unstable, remaining changes
  - Disable ffmpeg support
* Disable gstreamer support, this relies on gstreamer 0.10 and we don't want
  to add any more deps on that.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * WinPR: Windows Portable Runtime
 
3
 * Process Environment Functions
 
4
 *
 
5
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * Unless required by applicable law or agreed to in writing, software
 
14
 * distributed under the License is distributed on an "AS IS" BASIS,
 
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
 * See the License for the specific language governing permissions and
 
17
 * limitations under the License.
 
18
 */
 
19
 
 
20
#ifdef HAVE_CONFIG_H
 
21
#include "config.h"
 
22
#endif
 
23
 
 
24
#include <winpr/environment.h>
 
25
 
 
26
#ifndef _WIN32
 
27
 
 
28
#include <winpr/crt.h>
 
29
 
 
30
#ifdef HAVE_UNISTD_H
 
31
#include <unistd.h>
 
32
#endif
 
33
 
 
34
DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
 
35
{
 
36
        char* cwd;
 
37
        int length;
 
38
 
 
39
        cwd = getcwd(NULL, 0);
 
40
 
 
41
        if (!cwd)
 
42
                return 0;
 
43
 
 
44
        length = strlen(cwd);
 
45
 
 
46
        if ((nBufferLength == 0) && (lpBuffer == NULL))
 
47
        {
 
48
                free(cwd);
 
49
 
 
50
                return (DWORD) length;
 
51
        }
 
52
        else
 
53
        {
 
54
                if (lpBuffer == NULL)
 
55
                {
 
56
                        free(cwd);
 
57
                        return 0;
 
58
                }
 
59
 
 
60
                if ((length + 1) > nBufferLength)
 
61
                {
 
62
                        free(cwd);
 
63
                        return (DWORD) (length + 1);
 
64
                }
 
65
 
 
66
                memcpy(lpBuffer, cwd, length + 1);
 
67
                return length;
 
68
        }
 
69
 
 
70
        return 0;
 
71
}
 
72
 
 
73
DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer)
 
74
{
 
75
        return 0;
 
76
}
 
77
 
 
78
BOOL SetCurrentDirectoryA(LPCSTR lpPathName)
 
79
{
 
80
        return TRUE;
 
81
}
 
82
 
 
83
BOOL SetCurrentDirectoryW(LPCWSTR lpPathName)
 
84
{
 
85
        return TRUE;
 
86
}
 
87
 
 
88
DWORD SearchPathA(LPCSTR lpPath, LPCSTR lpFileName, LPCSTR lpExtension, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart)
 
89
{
 
90
        return 0;
 
91
}
 
92
 
 
93
DWORD SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart)
 
94
{
 
95
        return 0;
 
96
}
 
97
 
 
98
HANDLE GetStdHandle(DWORD nStdHandle)
 
99
{
 
100
        return NULL;
 
101
}
 
102
 
 
103
BOOL SetStdHandle(DWORD nStdHandle, HANDLE hHandle)
 
104
{
 
105
        return TRUE;
 
106
}
 
107
 
 
108
BOOL SetStdHandleEx(DWORD dwStdHandle, HANDLE hNewHandle, HANDLE* phOldHandle)
 
109
{
 
110
        return TRUE;
 
111
}
 
112
 
 
113
LPSTR GetCommandLineA(VOID)
 
114
{
 
115
        return NULL;
 
116
}
 
117
 
 
118
LPWSTR GetCommandLineW(VOID)
 
119
{
 
120
        return NULL;
 
121
}
 
122
 
 
123
BOOL NeedCurrentDirectoryForExePathA(LPCSTR ExeName)
 
124
{
 
125
        return TRUE;
 
126
}
 
127
 
 
128
BOOL NeedCurrentDirectoryForExePathW(LPCWSTR ExeName)
 
129
{
 
130
        return TRUE;
 
131
}
 
132
 
 
133
DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize)
 
134
{
 
135
        int length;
 
136
        char* env = NULL;
 
137
 
 
138
        env = getenv(lpName);
 
139
 
 
140
        if (!env)
 
141
                return 0;
 
142
 
 
143
        length = strlen(env);
 
144
 
 
145
        if ((length + 1 > nSize) || (!lpBuffer))
 
146
                return length + 1;
 
147
 
 
148
        CopyMemory(lpBuffer, env, length + 1);
 
149
 
 
150
        return length;
 
151
}
 
152
 
 
153
DWORD GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize)
 
154
{
 
155
        return 0;
 
156
}
 
157
 
 
158
BOOL SetEnvironmentVariableA(LPCSTR lpName, LPCSTR lpValue)
 
159
{
 
160
        return TRUE;
 
161
}
 
162
 
 
163
BOOL SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue)
 
164
{
 
165
        return TRUE;
 
166
}
 
167
 
 
168
LPCH GetEnvironmentStrings(VOID)
 
169
{
 
170
        return NULL;
 
171
}
 
172
 
 
173
LPWCH GetEnvironmentStringsW(VOID)
 
174
{
 
175
        return NULL;
 
176
}
 
177
 
 
178
BOOL SetEnvironmentStringsA(LPCH NewEnvironment)
 
179
{
 
180
        return TRUE;
 
181
}
 
182
 
 
183
BOOL SetEnvironmentStringsW(LPWCH NewEnvironment)
 
184
{
 
185
        return TRUE;
 
186
}
 
187
 
 
188
DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, LPSTR lpDst, DWORD nSize)
 
189
{
 
190
        return 0;
 
191
}
 
192
 
 
193
DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
 
194
{
 
195
        return 0;
 
196
}
 
197
 
 
198
BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock)
 
199
{
 
200
        return TRUE;
 
201
}
 
202
 
 
203
BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock)
 
204
{
 
205
        return TRUE;
 
206
}
 
207
 
 
208
#endif
 
209