~ubuntu-branches/ubuntu/precise/nspr/precise-proposed

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/src/md/windows/w16stdio.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-08-10 11:34:26 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090810113426-3uv4diflrkcbdimm
Tags: 4.8-0ubuntu1
* New upstream release: 4.8 (LP: #387812)
* adjust patches to changed upstreanm codebase
  - update debian/patches/99_configure.patch
* update shlibs symbols to include new API elements
  - update debian/libnspr4-0d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
 
/* ***** BEGIN LICENSE BLOCK *****
3
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 
 *
5
 
 * The contents of this file are subject to the Mozilla Public License Version
6
 
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 
 * the License. You may obtain a copy of the License at
8
 
 * http://www.mozilla.org/MPL/
9
 
 *
10
 
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 
 * for the specific language governing rights and limitations under the
13
 
 * License.
14
 
 *
15
 
 * The Original Code is the Netscape Portable Runtime (NSPR).
16
 
 *
17
 
 * The Initial Developer of the Original Code is
18
 
 * Netscape Communications Corporation.
19
 
 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20
 
 * the Initial Developer. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *
24
 
 * Alternatively, the contents of this file may be used under the terms of
25
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
26
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 
 * of those above. If you wish to allow use of your version of this file only
29
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 
 * use your version of this file under the terms of the MPL, indicate your
31
 
 * decision by deleting the provisions above and replace them with the notice
32
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 
 * the provisions above, a recipient may use your version of this file under
34
 
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 
 *
36
 
 * ***** END LICENSE BLOCK ***** */
37
 
 
38
 
/*
39
 
** w16stdio.c -- Callback functions for Win16 stdio read/write.
40
 
**
41
 
**
42
 
*/
43
 
#include "primpl.h"
44
 
 
45
 
/*
46
 
** _PL_MDStdioWrite() -- Win16 hackery to get console output
47
 
**
48
 
** Returns: number of bytes written.
49
 
**
50
 
*/
51
 
PRInt32
52
 
_PL_W16StdioWrite( void *buf, PRInt32 amount )
53
 
{
54
 
    int   rc;
55
 
    
56
 
    rc = fputs( buf, stdout );
57
 
    if ( rc == EOF )
58
 
    {
59
 
        // something about errno
60
 
        return(PR_FAILURE);
61
 
    }
62
 
    return( strlen(buf));
63
 
} /* end _PL_fputs() */
64
 
 
65
 
/*
66
 
** _PL_W16StdioRead() -- Win16 hackery to get console input
67
 
**
68
 
*/
69
 
PRInt32
70
 
_PL_W16StdioRead( void *buf, PRInt32 amount )
71
 
{
72
 
    char *bp;
73
 
 
74
 
    bp = fgets( buf, (int) amount, stdin );
75
 
    if ( bp == NULL )
76
 
    {
77
 
        // something about errno
78
 
        return(PR_FAILURE);
79
 
    }
80
 
    
81
 
    return( strlen(buf));
82
 
} /* end _PL_fgets() */
83
 
/* --- end w16stdio.c --- */
84
 
 
85
 
/*
86
 
** Wrappers, linked into the client, that call
87
 
** functions in LibC
88
 
**
89
 
*/
90
 
 
91
 
/*
92
 
** _PL_W16CallBackPuts() -- Wrapper for puts()
93
 
**
94
 
*/
95
 
int PR_CALLBACK _PL_W16CallBackPuts( const char *outputString )
96
 
{
97
 
    return( puts( outputString ));
98
 
} /* end _PL_W16CallBackPuts()  */    
99
 
 
100
 
/*
101
 
** _PL_W16CallBackStrftime() -- Wrapper for strftime()
102
 
**
103
 
*/
104
 
size_t PR_CALLBACK _PL_W16CallBackStrftime( 
105
 
    char *s, 
106
 
    size_t len, 
107
 
    const char *fmt,
108
 
    const struct tm *p )
109
 
{
110
 
    return( strftime( s, len, fmt, p ));
111
 
} /* end _PL_W16CallBackStrftime()  */    
112
 
 
113
 
/*
114
 
** _PL_W16CallBackMalloc() -- Wrapper for malloc()
115
 
**
116
 
*/
117
 
void * PR_CALLBACK _PL_W16CallBackMalloc( size_t size )
118
 
{
119
 
    return( malloc( size ));
120
 
} /* end _PL_W16CallBackMalloc()  */    
121
 
 
122
 
/*
123
 
** _PL_W16CallBackCalloc() -- Wrapper for calloc()
124
 
**
125
 
*/
126
 
void * PR_CALLBACK _PL_W16CallBackCalloc( size_t n, size_t size )
127
 
{
128
 
    return( calloc( n, size ));
129
 
} /* end _PL_W16CallBackCalloc()  */    
130
 
 
131
 
/*
132
 
** _PL_W16CallBackRealloc() -- Wrapper for realloc()
133
 
**
134
 
*/
135
 
void * PR_CALLBACK _PL_W16CallBackRealloc( 
136
 
    void *old_blk, 
137
 
    size_t size )
138
 
{
139
 
    return( realloc( old_blk, size ));
140
 
} /* end _PL_W16CallBackRealloc()  */
141
 
 
142
 
/*
143
 
** _PL_W16CallBackFree() -- Wrapper for free()
144
 
**
145
 
*/
146
 
void PR_CALLBACK _PL_W16CallBackFree( void *ptr )
147
 
{
148
 
    free( ptr );
149
 
    return;
150
 
} /* end _PL_W16CallBackFree()  */
151
 
 
152
 
/*
153
 
** _PL_W16CallBackGetenv() -- Wrapper for getenv()
154
 
**
155
 
*/
156
 
void * PR_CALLBACK _PL_W16CallBackGetenv( const char *name )
157
 
{
158
 
    return( getenv( name ));
159
 
} /* end _PL_W16CallBackGetenv  */
160
 
 
161
 
 
162
 
/*
163
 
** _PL_W16CallBackPutenv() -- Wrapper for putenv()
164
 
**
165
 
*/
166
 
int PR_CALLBACK _PL_W16CallBackPutenv( const char *assoc )
167
 
{
168
 
    return( putenv( assoc ));
169
 
} /* end _PL_W16CallBackGetenv  */