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

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

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

revision 1.2 by mark, Tue Jan 22 22:27:02 2002 UTC revision 1.3 by mark, Mon Dec 2 00:28:09 2002 UTC
# Line 1  Line 1 
1  /* PlainSocketImpl.c - Native methods for PlainSocketImpl class  /* PlainSocketImpl.c - Native methods for PlainSocketImpl class
2     Copyright (C) 1998 Free Software Foundation, Inc.     Copyright (C) 1998, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 36  obligated to do so.  If you do not wish Line 36  obligated to do so.  If you do not wish
36  exception statement from your version. */  exception statement from your version. */
37    
38    
39    #include <errno.h>
40    #include <sys/ioctl.h>
41    #include <asm/ioctls.h>
42    #include <string.h>
43    
44  #include <jni.h>  #include <jni.h>
45    #include <jcl.h>
46    
47  #include "java_net_PlainSocketImpl.h"  #include "java_net_PlainSocketImpl.h"
48    
# Line 123  Java_java_net_PlainSocketImpl_accept(JNI Line 129  Java_java_net_PlainSocketImpl_accept(JNI
129  }  }
130    
131  /*************************************************************************/  /*************************************************************************/
132    
133    JNIEXPORT jint JNICALL
134    Java_java_net_PlainSocketImpl_available(JNIEnv *env, jobject this)
135    {
136      int fd;
137      int count = 0;
138      jclass cls;
139      jfieldID fid;
140      
141      cls = (*env)->GetObjectClass(env, this);
142      if (cls == 0)
143        {
144          JCL_ThrowException(env, IO_EXCEPTION, "internal error");
145          return 0;
146        }
147      
148      fid = (*env)->GetFieldID(env, cls, "native_fd", "I");
149      if (fid == 0)
150        {
151          JCL_ThrowException(env, IO_EXCEPTION, "internal error");
152          return 0;
153        }
154    
155      fd = (*env)->GetIntField(env, this, fid);
156      
157      if (ioctl(fd, FIONREAD, &count) == -1)
158        {
159          JCL_ThrowException(env, IO_EXCEPTION, strerror(errno));
160          return 0;
161        }
162      else
163        return count;
164    }
165    
166    /*************************************************************************/
167    
168  /*  /*
169   * This method sets the specified option for a socket   * This method sets the specified option for a socket

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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