transport.c 1.98 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
 * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
 * PLEASE READ THESE TERMS BEFORE DISTRIBUTING.                     *
 *                                                                  *
 * THE Ogg123 SOURCE CODE IS (C) COPYRIGHT 2000-2001                *
 * by Stan Seibert <volsung@xiph.org> AND OTHER CONTRIBUTORS        *
 * http://www.xiph.org/                                             *
 *                                                                  *
 ********************************************************************

14
 last mod: $Id: transport.c,v 1.4 2002/05/05 03:45:04 segher Exp $
15 16 17 18 19 20

 ********************************************************************/

#include <stdio.h>
#include <string.h>

21 22 23
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
24
#include "transport.h"
25
#include "i18n.h"
26 27

extern transport_t file_transport;
28
#ifdef HAVE_CURL
29
extern transport_t http_transport;
30 31 32 33 34 35 36 37 38
#endif

transport_t *transports[] = {
#ifdef HAVE_CURL
  &http_transport,
#endif
  &file_transport,
  NULL
};
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69


transport_t *get_transport_by_name (char *name)
{
  int i = 0;

  while (transports[i] != NULL && strcmp(name, transports[i]->name) != 0)
    i++;

  return transports[i];
}


transport_t *select_transport (char *source)
{
  int i = 0;

  while (transports[i] != NULL && !transports[i]->can_transport(source))
    i++;

  return transports[i];
}


data_source_stats_t *malloc_data_source_stats (data_source_stats_t *to_copy)
{
  data_source_stats_t *new_stats;

  new_stats = malloc(sizeof(data_source_stats_t));

  if (new_stats == NULL) {
70
    fprintf(stderr, _("Error: Could not allocate memory in malloc_data_source_stats()\n"));
71 72 73 74 75 76 77
    exit(1);
  }

  *new_stats = *to_copy;  /* Copy the data */

  return new_stats;
}