cURL / Mailing Lists / curl-library / Single Mail


help with this

From: Miguel Monzon <>
Date: Sun, 12 Sep 2004 16:10:35 -0500

I have a problem with this code, it does the following:

Download the file archdone.lst by ftp and after it finished it opens the file and read it line by line.
The problem is that after finished downloading, i can't read the file. The ftp works fine but when i try to read the file is like it was and empty file, but in reality the transfer was ok.

Help with this please!!!

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

struct FtpFile
 char *filename;
 FILE *stream;

int my_fwrite(void *buffer,size_t size,size_t nmemb,void *stream)
 struct FtpFile *out=(struct FtpFile *)stream;
 if (out && !out->stream)
  if (!out->stream)
     return -1;

 return fwrite(buffer,size,nmemb,out->stream);

char *terminate(string,chars)
char *string;
char *chars;
 char *ptr;
 if (!string||!chars)
    return "";

 while (*chars)
  if (ptr=strrchr(string,*chars))
 return string;

int freadln(stream,lin)
FILE *stream;
char *lin;
 char *p;
 while (p && (*lin=='#'));
 if (!p)
    return 1;
 return 0;

int main(void)
 FILE *flst;
 CURL *curl;
 CURLcode res;
 struct FtpFile ftpfile={"archdone.lst",NULL};
 char buffer[35];
 int num_partes;

 if (curl)

  if (CURLE_OK ==res)
    if (!flst)
     printf("error: No se pudo abrir archdone.lst");

    while (!freadln(flst,buffer))
     if (strncmp(buffer,"cdrdone",26)==0)
 if (
Received on 2004-09-12