~ubuntu-branches/ubuntu/edgy/curl/edgy

« back to all changes in this revision

Viewing changes to src/urlglob.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-06-29 15:04:24 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060629150424-pn00qumt9sml8p4m
Tags: 7.15.4-1ubuntu1
Synchronize to Debian. Only change left: Removal of stunnel and
libdb4.2-dev build dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: urlglob.c,v 1.41 2005/11/10 22:11:02 bagder Exp $
 
21
 * $Id: urlglob.c,v 1.43 2006-04-07 12:10:34 bagder Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
/* client-local setup.h */
61
61
  /* processes a set expression with the point behind the opening '{'
62
62
     ','-separated elements are collected until the next closing '}'
63
63
  */
 
64
  bool done = FALSE;
64
65
  char* buf = glob->glob_buffer;
65
66
  URLPattern *pat;
66
67
 
72
73
  pat->content.Set.elements = (char**)malloc(0);
73
74
  ++glob->size;
74
75
 
75
 
  while (1) {
 
76
  while (!done) {
76
77
    bool skip;
77
78
 
78
79
    switch (*pattern) {
110
111
          wordamount=1;
111
112
        *amount = pat->content.Set.size * wordamount;
112
113
 
113
 
        return GLOB_OK;
 
114
        done = TRUE;
 
115
        continue;
114
116
      }
115
117
 
116
118
      buf = glob->glob_buffer;
151
153
      ++pos;
152
154
    }
153
155
  }
154
 
  /* we never reach this point */
 
156
  return GLOB_OK;
155
157
}
156
158
 
157
159
static GlobCode glob_range(URLGlob *glob, char *pattern,
397
399
  char *lit;
398
400
  size_t i;
399
401
  size_t j;
 
402
  size_t buflen = glob->urllen+1;
 
403
  size_t len;
400
404
 
401
405
  if (!glob->beenhere)
402
406
    glob->beenhere = 1;
441
445
  for (j = 0; j < glob->size; ++j) {
442
446
    if (!(j&1)) {              /* every other term (j even) is a literal */
443
447
      lit = glob->literal[j/2];
444
 
      strcpy(buf, lit);
445
 
      buf += strlen(lit);
 
448
      len = snprintf(buf, buflen, "%s", lit);
 
449
      buf += len;
 
450
      buflen -= len;
446
451
    }
447
452
    else {                              /* the rest (i odd) are patterns */
448
453
      pat = &glob->pattern[j/2];
449
454
      switch(pat->type) {
450
455
      case UPTSet:
451
 
        strcpy(buf, pat->content.Set.elements[pat->content.Set.ptr_s]);
452
 
        buf += strlen(pat->content.Set.elements[pat->content.Set.ptr_s]);
 
456
        len = strlen(pat->content.Set.elements[pat->content.Set.ptr_s]);
 
457
        snprintf(buf, buflen, "%s",
 
458
                 pat->content.Set.elements[pat->content.Set.ptr_s]);
 
459
        buf += len;
 
460
        buflen -= len;
453
461
        break;
454
462
      case UPTCharRange:
455
463
        *buf++ = pat->content.CharRange.ptr_c;
456
464
        break;
457
465
      case UPTNumRange:
458
 
        sprintf(buf, "%0*d",
459
 
                pat->content.NumRange.padlength, pat->content.NumRange.ptr_n);
460
 
        buf += strlen(buf); /* make no sprint() return code assumptions */
 
466
        len = snprintf(buf, buflen, "%0*d",
 
467
                       pat->content.NumRange.padlength,
 
468
                       pat->content.NumRange.ptr_n);
 
469
        buf += len;
 
470
        buflen -= len;
461
471
        break;
462
472
      default:
463
473
        printf("internal error: invalid pattern type (%d)\n", (int)pat->type);
508
518
          appendlen=1;
509
519
          break;
510
520
        case UPTNumRange:
511
 
          sprintf(numbuf, "%0*d",
512
 
                  pat.content.NumRange.padlength,
513
 
                  pat.content.NumRange.ptr_n);
 
521
          snprintf(numbuf, sizeof(numbuf), "%0*d",
 
522
                   pat.content.NumRange.padlength,
 
523
                   pat.content.NumRange.ptr_n);
514
524
          appendthis = numbuf;
515
525
          appendlen = strlen(numbuf);
516
526
          break;