~ubuntu-branches/ubuntu/saucy/curl/saucy-201307251546

« back to all changes in this revision

Viewing changes to docs/examples/fopen.c

  • Committer: Bazaar Package Importer
  • Author(s): Ramakrishnan Muthukrishnan
  • Date: 2011-02-28 19:35:36 UTC
  • mto: (3.6.1 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 47.
  • Revision ID: james.westby@ubuntu.com-20110228193536-p3a9jawxxofcsz7o
Tags: upstream-7.21.4
ImportĀ upstreamĀ versionĀ 7.21.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
  } handle;                   /* handle */
69
69
 
70
70
  char *buffer;               /* buffer to store cached data*/
71
 
  int buffer_len;             /* currently allocated buffers length */
72
 
  int buffer_pos;             /* end of data in buffer*/
 
71
  size_t buffer_len;          /* currently allocated buffers length */
 
72
  size_t buffer_pos;          /* end of data in buffer*/
73
73
  int still_running;          /* Is background url fetch still in progress */
74
74
};
75
75
 
80
80
int url_fclose(URL_FILE *file);
81
81
int url_feof(URL_FILE *file);
82
82
size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file);
83
 
char * url_fgets(char *ptr, int size, URL_FILE *file);
 
83
char * url_fgets(char *ptr, size_t size, URL_FILE *file);
84
84
void url_rewind(URL_FILE *file);
85
85
 
86
86
/* we use a global one for convenience */
93
93
                             void *userp)
94
94
{
95
95
  char *newbuff;
96
 
  int rembuff;
 
96
  size_t rembuff;
97
97
 
98
98
  URL_FILE *url = (URL_FILE *)userp;
99
99
  size *= nitems;
121
121
}
122
122
 
123
123
/* use to attempt to fill the read buffer up to requested number of bytes */
124
 
static int fill_buffer(URL_FILE *file,int want,int waittime)
 
124
static int fill_buffer(URL_FILE *file, size_t want)
125
125
{
126
126
  fd_set fdread;
127
127
  fd_set fdwrite;
323
323
  case CFTYPE_CURL:
324
324
    want = nmemb * size;
325
325
 
326
 
    fill_buffer(file,want,1);
 
326
    fill_buffer(file,want);
327
327
 
328
328
    /* check if theres data in the buffer - if not fill_buffer()
329
329
     * either errored or EOF */
351
351
  return want;
352
352
}
353
353
 
354
 
char *url_fgets(char *ptr, int size, URL_FILE *file)
 
354
char *url_fgets(char *ptr, size_t size, URL_FILE *file)
355
355
{
356
 
  int want = size - 1;/* always need to leave room for zero termination */
357
 
  int loop;
 
356
  size_t want = size - 1;/* always need to leave room for zero termination */
 
357
  size_t loop;
358
358
 
359
359
  switch(file->type) {
360
360
  case CFTYPE_FILE:
362
362
    break;
363
363
 
364
364
  case CFTYPE_CURL:
365
 
    fill_buffer(file,want,1);
 
365
    fill_buffer(file,want);
366
366
 
367
367
    /* check if theres data in the buffer - if not fill either errored or
368
368
     * EOF */