Return-Path: william@bourbon.usc.edu Delivery-Date: Tue Sep 9 11:28:12 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m89ISB18009204 for ; Tue, 9 Sep 2008 11:28:11 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m89IRSxC031019 for ; Tue, 9 Sep 2008 11:27:28 -0700 Message-Id: <200809091827.m89IRSxC031019@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: fseek: Illegal seek Date: Tue, 09 Sep 2008 11:27:28 -0700 From: Bill Cheng Someone wrote: > I am a somewhat confused as to why the following command produces > an error. I have googled the web for a solution but nothing seems > to be coming up that I have not tried. > > I am performing a popen to get the MD5 of a given file You should not do this! Your server should send the file over the socket (starting from the given offset) and your client should calculate MD5 on the fly (without using a file). > so I have written the following > > file_size = fseek(pfp, (long)offset, SEEK_END); > > to get the filesize and return this as the data_length. > > pfp is a file pointer created from popen. (I checked that pfp is > *not* NULL) > > the error I get always is (fseek :illegal seek) > Any suggestions please? I don't think you can do a seek on a pipe. fseek() should be used on a file stream. > By the way I tried using a value of 0L instead of offset but it > still same result. Also, I ran "openssl md5 filename" and got the > md5 result. On your server, you can use fopen() to open the file, use fseek() to skip a given number of bytes. -- Bill Cheng // bill.cheng@usc.edu