/[hydra]/hydra/src/util.c
ViewVC logotype

Diff of /hydra/src/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by nmav, Sat Sep 28 17:49:13 2002 UTC revision 1.9 by nmav, Sun Sep 29 08:02:56 2002 UTC
# Line 4  Line 4 
4   *  Some changes Copyright (C) 1996,97 Larry Doolittle <ldoolitt@boa.org>   *  Some changes Copyright (C) 1996,97 Larry Doolittle <ldoolitt@boa.org>
5   *  Some changes Copyright (C) 1996 Charles F. Randall <crandall@goldsys.com>   *  Some changes Copyright (C) 1996 Charles F. Randall <crandall@goldsys.com>
6   *  Some changes Copyright (C) 1996-99 Jon Nelson <jnelson@boa.org>   *  Some changes Copyright (C) 1996-99 Jon Nelson <jnelson@boa.org>
7     *  Portions Copyright (C) 2002 Nikos Mavroyanopoulos <nmav@gnutls.org>
8   *   *
9   *  This program is free software; you can redistribute it and/or modify   *  This program is free software; you can redistribute it and/or modify
10   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# Line 588  int real_set_nonblock_fd(int fd) Line 589  int real_set_nonblock_fd(int fd)
589      flags = fcntl(fd, F_SETFL, flags);      flags = fcntl(fd, F_SETFL, flags);
590      return flags;      return flags;
591  }  }
592    
593    void create_url( char * buffer, int buffer_size, int secure,
594       const char* hostname, int port, const char* request_uri)
595    {
596    char * proto;
597    char str_port[23];
598    int do_port = 0;
599    
600       buffer[0] = 0; /* in case we fail */
601    
602       if (secure) {
603          proto = "https";
604          if (port != 443)
605             do_port = 1;
606       } else {
607          proto = "http";
608          if (port!=80)
609             do_port = 1;
610       }
611    
612       if (do_port) {
613          str_port[0] = ':';
614          simple_itoa( port, &str_port[1]);
615       }
616    
617       if ((strlen(proto) + strlen(str_port) + strlen(hostname) +
618           strlen(request_uri) + 5) > buffer_size) {
619           /* This is more than impossible. The buffer is long enough */
620           log_error_time();
621           fprintf(stderr, "Could not create URL. Buffer was not enough.\n");
622           return;
623       }
624    
625       sprintf( buffer, "%s://%s%s%s/", proto, hostname, str_port, request_uri);
626    
627       return;
628    }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26