~ubuntu-branches/ubuntu/vivid/edbrowse/vivid

« back to all changes in this revision

Viewing changes to src/url.c

  • Committer: Bazaar Package Importer
  • Author(s): Kapil Hari Paranjape
  • Date: 2009-03-01 16:55:12 UTC
  • mfrom: (1.1.5 upstream) (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090301165512-97yhte20cy3c4q2w
Tags: 3.4.1-1
* New upstream version (3.4.1).
* debian/rules:
  - add "touch build-stamp" to build-stamp target.
  - modify clean target to use clean target in src/makefile.
  - remove debian/edbrowse.1 in clean target.
  - added "-lcurl" to linker flags.
* debian/control:
  - added libcurl4-openssl-dev to Build-Depends
  - Standards Version 3.8.0. No changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
297
297
    return j;
298
298
}                               /* isURL */
299
299
 
 
300
/* non-FTP URLs are always browsable.  FTP URLs are browsable if they end with
 
301
* a slash. */
 
302
bool
 
303
isBrowseableURL(const char *url)
 
304
{
 
305
    if(isURL(url))
 
306
        return (!memEqualCI(url, "ftp://", 6)) || (url[strlen(url) - 1] == '/');
 
307
    else
 
308
        return false;
 
309
}                               /* isBrowseableURL */
 
310
 
300
311
/* Helper functions to return pieces of the URL.
301
312
 * Makes a copy, so you can have your 0 on the end.
302
313
 * Return 0 for an error, and "" if that piece is missing. */
491
502
    return ((url[0] | 0x20) == 'p');
492
503
}
493
504
 
494
 
/* Don't let a web page fetch itself. */
495
 
static char *histURL[MAXFETCH];
496
 
static int histFrom[MAXFETCH];
497
 
static int n_fetch;
498
 
int
499
 
fetchHistory(const char *prev, const char *next)
500
 
{
501
 
    int i;
502
 
    int from = -1;
503
 
/* zero is a reset */
504
 
    debugPrint(4, "fetch hist %s : %s", prev, next);
505
 
    if(prev == 0) {
506
 
        for(i = 0; i < n_fetch; ++i)
507
 
            free(histURL[i]);
508
 
        n_fetch = 0;
509
 
        if(!next)
510
 
            return false;
511
 
    } else {
512
 
        if(memEqualCI(prev, "http://", 7))
513
 
            prev += 7;
514
 
        for(i = 0; i < n_fetch; ++i)
515
 
            if(stringEqual(prev, histURL[i])) {
516
 
                from = i;
517
 
                break;
518
 
            }
519
 
    }
520
 
    if(n_fetch >= MAXFETCH) {
521
 
        setError(MSG_WebFetchMany);
522
 
        return -1;
523
 
    }
524
 
/* Have we seen this one before? */
525
 
    if(memEqualCI(next, "http://", 7))
526
 
        next += 7;
527
 
    for(i = 0; i < n_fetch; ++i)
528
 
        if(stringEqual(next, histURL[i]))
529
 
            break;
530
 
    if(i == n_fetch) {          /* new */
531
 
        histURL[i] = cloneString(next);
532
 
        histFrom[i] = from;
533
 
        ++n_fetch;
534
 
        return true;
535
 
    }
536
 
/* Oops, we've already fetched this page. */
537
 
    while(from >= 0 && from != i)
538
 
        from = histFrom[from];
539
 
    if(from < 0)
540
 
        return false;
541
 
    setError(MSG_WebFetchSelf);
542
 
    return -1;
543
 
}                               /* FetchHistory */
544
 
 
545
 
const char *
546
 
firstURL(void)
547
 
{
548
 
    if(!n_fetch)
549
 
        return 0;
550
 
    return histURL[0];
551
 
}                               /* firstURL */
552
 
 
553
505
static void
554
506
squashDirectories(char *url)
555
507
{