httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/file_io/win32 readwrite.c
Date Tue, 20 Jun 2000 18:03:19 GMT
stoddard    00/06/20 11:03:18

  Modified:    src/lib/apr/file_io/win32 readwrite.c
  Log:
  Win32: Eliminate bogus ap_ungetc implementation. The question remains, should
  ap_ungetc just decrement the buf pointer (which will accomodate multiple calls
  to ap_ungetc and eliminate the char ch argument) or only allow a single call
  to ap_ungetc (implemented by saving char ch in thefile->ungetchar, like the
  unix implementation today). I'll make Unix and Win32 consistent once this
  decision is made.
  
  Revision  Changes    Path
  1.41      +7 -30     apache-2.0/src/lib/apr/file_io/win32/readwrite.c
  
  Index: readwrite.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/readwrite.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- readwrite.c	2000/06/19 17:45:15	1.40
  +++ readwrite.c	2000/06/20 18:03:15	1.41
  @@ -223,40 +223,17 @@
   
   ap_status_t ap_ungetc(char ch, ap_file_t *thefile)
   {
  -    /* 
  -     * Your application must provide its own serialization (locking) if
  -     * it allows multiple threads to access the same file handle 
  -     * concurrently.
  -     *
  -     * ToDo: This function does not use the char ch argument. Could add 
  -     * gorpy code to read the file after the SetFilePointer() call to 
  -     * make sure the character pushed back on the stream is the same as
  -     * arg ch. Then, need to SetFilePointer() once more to reset the 
  -     * file pointer to the point before the read. Yech... Just assume 
  -     * the caller knows what he is doing.  There may be a nifty Win32 
  -     * call for this I've not discovered....
  -     */
  -
  -    /* SetFilePointer is only valid for a file device ...*/
  -    if (GetFileType(thefile->filehand) != FILE_TYPE_DISK) {
  -        return GetLastError();
  -    }
  -
  +    /* ungetc only makes sense when using buffered i/o */
       if (thefile->buffered) {
  -        ap_off_t offset = -1;
  -        return ap_seek(thefile, APR_CUR, &offset);
  -    }
  -    else {
  -        /* and the file pointer is not pointing to the start of the file. */
  -        if (GetFilePointer(thefile->filehand)) {
  -            if (SetFilePointer(thefile->filehand, -1, NULL, FILE_CURRENT)
  -                == 0xFFFFFFFF) {
  -                return GetLastError();
  -            }
  +        ap_lock(thefile->mutex);        
  +        if (thefile->bufpos > 0){
  +            thefile->bufpos--;
           }
  +        ap_unlock(thefile->mutex);
  +        return APR_SUCCESS;
       }
   
  -    return APR_SUCCESS; 
  +    return APR_ENOTIMPL;
   }
   
   ap_status_t ap_getc(char *ch, ap_file_t *thefile)
  
  
  

Mime
View raw message