/[classpath]/classpath/native/jni/java-net/gnu_java_net_PlainSocketImpl.c
ViewVC logotype

Diff of /classpath/native/jni/java-net/gnu_java_net_PlainSocketImpl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3.2.2 by gnu_andrew, Sun Jan 16 15:15:14 2005 UTC revision 1.3.2.3 by gnu_andrew, Mon Apr 18 01:37:42 2005 UTC
# Line 42  exception statement from your version. * Line 42  exception statement from your version. *
42  #include <stdio.h>  #include <stdio.h>
43  #include <string.h>  #include <string.h>
44  #include <assert.h>  #include <assert.h>
45    
46  #include <jni.h>  #include <jni.h>
47  #include <jcl.h>  #include <jcl.h>
48    
# Line 50  exception statement from your version. * Line 50  exception statement from your version. *
50    
51  #include "target_native.h"  #include "target_native.h"
52  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
53    #include "target_native_network.h"  #include "target_native_network.h"
54  #endif /* WITHOUT_NETWORK */  #endif /* WITHOUT_NETWORK */
55    
56  #include "gnu_java_net_PlainSocketImpl.h"  #include "gnu_java_net_PlainSocketImpl.h"
# Line 68  exception statement from your version. * Line 68  exception statement from your version. *
68   * Creates a new stream or datagram socket   * Creates a new stream or datagram socket
69   */   */
70  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
71  Java_gnu_java_net_PlainSocketImpl_create(JNIEnv *env, jobject this, jboolean stream)  Java_gnu_java_net_PlainSocketImpl_create (JNIEnv * env, jobject this,
72                                              jboolean stream)
73  {  {
74  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
75    assert(env!=NULL);    assert (env != NULL);
76    assert((*env)!=NULL);    assert ((*env) != NULL);
77    
78    _javanet_create(env, this, stream);    _javanet_create (env, this, stream);
79  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
80  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
81  }  }
# Line 86  Java_gnu_java_net_PlainSocketImpl_create Line 87  Java_gnu_java_net_PlainSocketImpl_create
87   * action as well.   * action as well.
88   */   */
89  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
90  Java_gnu_java_net_PlainSocketImpl_close(JNIEnv *env, jobject this)  Java_gnu_java_net_PlainSocketImpl_close (JNIEnv * env, jobject this)
91  {  {
92  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
93    assert(env!=NULL);    assert (env != NULL);
94    assert((*env)!=NULL);    assert ((*env) != NULL);
95    
96    _javanet_close(env, this, 1);    _javanet_close (env, this, 1);
97  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
98  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
99  }  }
# Line 103  Java_gnu_java_net_PlainSocketImpl_close( Line 104  Java_gnu_java_net_PlainSocketImpl_close(
104   * Connects to the specified destination.   * Connects to the specified destination.
105   */   */
106  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
107  Java_gnu_java_net_PlainSocketImpl_connect(JNIEnv *env, jobject this,  Java_gnu_java_net_PlainSocketImpl_connect (JNIEnv * env, jobject this,
108                                        jobject addr, jint port)                                             jobject addr, jint port)
109  {  {
110  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
111    assert(env!=NULL);    assert (env != NULL);
112    assert((*env)!=NULL);    assert ((*env) != NULL);
113    
114    _javanet_connect(env, this, addr, port);    _javanet_connect (env, this, addr, port);
115  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
116  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
117  }  }
# Line 123  Java_gnu_java_net_PlainSocketImpl_connec Line 124  Java_gnu_java_net_PlainSocketImpl_connec
124   * variables.   * variables.
125   */   */
126  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
127  Java_gnu_java_net_PlainSocketImpl_bind(JNIEnv *env, jobject this, jobject addr,  Java_gnu_java_net_PlainSocketImpl_bind (JNIEnv * env, jobject this,
128                                     jint port)                                          jobject addr, jint port)
129  {  {
130  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
131    assert(env!=NULL);    assert (env != NULL);
132    assert((*env)!=NULL);    assert ((*env) != NULL);
133    
134    _javanet_bind(env, this, addr, port, 1);    _javanet_bind (env, this, addr, port, 1);
135  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
136  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
137  }  }
# Line 142  Java_gnu_java_net_PlainSocketImpl_bind(J Line 143  Java_gnu_java_net_PlainSocketImpl_bind(J
143   * connections allowed.   * connections allowed.
144   */   */
145  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
146  Java_gnu_java_net_PlainSocketImpl_listen(JNIEnv *env, jobject this, jint queuelen)  Java_gnu_java_net_PlainSocketImpl_listen (JNIEnv * env, jobject this,
147                                              jint queuelen)
148  {  {
149  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
150    assert(env!=NULL);    assert (env != NULL);
151    assert((*env)!=NULL);    assert ((*env) != NULL);
152    
153    _javanet_listen(env, this, queuelen);    _javanet_listen (env, this, queuelen);
154  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
155  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
156  }  }
# Line 160  Java_gnu_java_net_PlainSocketImpl_listen Line 162  Java_gnu_java_net_PlainSocketImpl_listen
162   * object. Note that we assume this is a PlainSocketImpl just like us.   * object. Note that we assume this is a PlainSocketImpl just like us.
163   */   */
164  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
165  Java_gnu_java_net_PlainSocketImpl_accept(JNIEnv *env, jobject this, jobject impl)  Java_gnu_java_net_PlainSocketImpl_accept (JNIEnv * env, jobject this,
166                                              jobject impl)
167  {  {
168  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
169    assert(env!=NULL);    assert (env != NULL);
170    assert((*env)!=NULL);    assert ((*env) != NULL);
171    
172    _javanet_accept(env, this, impl);    _javanet_accept (env, this, impl);
173  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
174  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
175  }  }
# Line 174  Java_gnu_java_net_PlainSocketImpl_accept Line 177  Java_gnu_java_net_PlainSocketImpl_accept
177  /*************************************************************************/  /*************************************************************************/
178    
179  JNIEXPORT jint JNICALL  JNIEXPORT jint JNICALL
180  Java_gnu_java_net_PlainSocketImpl_available(JNIEnv *env, jobject this)  Java_gnu_java_net_PlainSocketImpl_available (JNIEnv * env, jobject this)
181  {  {
182  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
183    jclass   cls;    jclass cls;
184    jfieldID fid;    jfieldID fid;
185    int      fd;    int fd;
186    int      bytesAvailable;    int bytesAvailable;
187    int      result;    int result;
     
   assert(env!=NULL);  
   assert((*env)!=NULL);  
188    
189    cls = (*env)->GetObjectClass(env, this);    assert (env != NULL);
190      assert ((*env) != NULL);
191    
192      cls = (*env)->GetObjectClass (env, this);
193    if (cls == 0)    if (cls == 0)
194      {      {
195        JCL_ThrowException(env, IO_EXCEPTION, "internal error");        JCL_ThrowException (env, IO_EXCEPTION, "internal error");
196        return 0;        return 0;
197      }      }
198      
199    fid = (*env)->GetFieldID(env, cls, "native_fd", "I");    fid = (*env)->GetFieldID (env, cls, "native_fd", "I");
200    if (fid == 0)    if (fid == 0)
201      {      {
202        JCL_ThrowException(env, IO_EXCEPTION, "internal error");        JCL_ThrowException (env, IO_EXCEPTION, "internal error");
203        return 0;        return 0;
204      }      }
205    
206    fd = (*env)->GetIntField(env, this, fid);    fd = (*env)->GetIntField (env, this, fid);
207      
208    TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE(fd,bytesAvailable,result);    TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE (fd, bytesAvailable, result);
209    if (result != TARGET_NATIVE_OK)    if (result != TARGET_NATIVE_OK)
210      {      {
211        JCL_ThrowException(env, IO_EXCEPTION, TARGET_NATIVE_LAST_ERROR_STRING());        JCL_ThrowException (env, IO_EXCEPTION,
212                              TARGET_NATIVE_LAST_ERROR_STRING ());
213        return 0;        return 0;
214      }      }
215    
# Line 221  Java_gnu_java_net_PlainSocketImpl_availa Line 225  Java_gnu_java_net_PlainSocketImpl_availa
225   * This method sets the specified option for a socket   * This method sets the specified option for a socket
226   */   */
227  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
228  Java_gnu_java_net_PlainSocketImpl_setOption(JNIEnv *env, jobject this,  Java_gnu_java_net_PlainSocketImpl_setOption (JNIEnv * env, jobject this,
229                                          jint option_id, jobject val)                                               jint option_id, jobject val)
230  {  {
231  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
232    assert(env!=NULL);    assert (env != NULL);
233    assert((*env)!=NULL);    assert ((*env) != NULL);
234    
235    _javanet_set_option(env, this, option_id, val);    _javanet_set_option (env, this, option_id, val);
236  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
237  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
238  }  }
# Line 239  Java_gnu_java_net_PlainSocketImpl_setOpt Line 243  Java_gnu_java_net_PlainSocketImpl_setOpt
243   * This method sets the specified option for a socket   * This method sets the specified option for a socket
244   */   */
245  JNIEXPORT jobject JNICALL  JNIEXPORT jobject JNICALL
246  Java_gnu_java_net_PlainSocketImpl_getOption(JNIEnv *env, jobject this,  Java_gnu_java_net_PlainSocketImpl_getOption (JNIEnv * env, jobject this,
247                                          jint option_id)                                               jint option_id)
248  {  {
249  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
250    assert(env!=NULL);    assert (env != NULL);
251    assert((*env)!=NULL);    assert ((*env) != NULL);
252    
253    return(_javanet_get_option(env, this, option_id));    return (_javanet_get_option (env, this, option_id));
254  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
255    return NULL;    return NULL;
256  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
# Line 258  Java_gnu_java_net_PlainSocketImpl_getOpt Line 262  Java_gnu_java_net_PlainSocketImpl_getOpt
262   * Reads a buffer from a remote host   * Reads a buffer from a remote host
263   */   */
264  JNIEXPORT jint JNICALL  JNIEXPORT jint JNICALL
265  Java_gnu_java_net_PlainSocketImpl_read(JNIEnv *env, jobject this, jarray buf,  Java_gnu_java_net_PlainSocketImpl_read (JNIEnv * env, jobject this,
266                                     jint offset, jint len)                                          jarray buf, jint offset, jint len)
267  {  {
268  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
269    assert(env!=NULL);    assert (env != NULL);
270    assert((*env)!=NULL);    assert ((*env) != NULL);
271    
272    return(_javanet_recvfrom(env, this, buf, offset, len, 0, 0));    return (_javanet_recvfrom (env, this, buf, offset, len, 0, 0));
273  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
274    return 0;    return 0;
275  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
# Line 277  Java_gnu_java_net_PlainSocketImpl_read(J Line 281  Java_gnu_java_net_PlainSocketImpl_read(J
281   * Writes a buffer to the remote host   * Writes a buffer to the remote host
282   */   */
283  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
284  Java_gnu_java_net_PlainSocketImpl_write(JNIEnv *env, jobject this, jarray buf,  Java_gnu_java_net_PlainSocketImpl_write (JNIEnv * env, jobject this,
285                                      jint offset, jint len)                                           jarray buf, jint offset, jint len)
286  {  {
287  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
288    assert(env!=NULL);    assert (env != NULL);
289    assert((*env)!=NULL);    assert ((*env) != NULL);
290    
291    _javanet_sendto(env, this, buf, offset, len, 0, 0);    _javanet_sendto (env, this, buf, offset, len, 0, 0);
292  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
293  #endif /* not WITHOUT_NETWORK */  #endif /* not WITHOUT_NETWORK */
294  }  }
295    
296  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
297  Java_gnu_java_net_PlainSocketImpl_shutdownInput (JNIEnv *env, jobject this)  Java_gnu_java_net_PlainSocketImpl_shutdownInput (JNIEnv * env, jobject this)
298  {  {
299  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
300    assert (env != NULL);    assert (env != NULL);
301  assert ((*env) != NULL);    assert ((*env) != NULL);
302    
303    _javanet_shutdownInput (env, this);    _javanet_shutdownInput (env, this);
304  #else /* not WITHOUT_NETWORK */  #else /* not WITHOUT_NETWORK */
# Line 302  assert ((*env) != NULL); Line 306  assert ((*env) != NULL);
306  }  }
307    
308  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
309  Java_gnu_java_net_PlainSocketImpl_shutdownOutput (JNIEnv *env, jobject this)  Java_gnu_java_net_PlainSocketImpl_shutdownOutput (JNIEnv * env, jobject this)
310  {  {
311  #ifndef WITHOUT_NETWORK  #ifndef WITHOUT_NETWORK
312    assert (env != NULL);    assert (env != NULL);

Legend:
Removed from v.1.3.2.2  
changed lines
  Added in v.1.3.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26