summaryrefslogtreecommitdiff
path: root/src/input/vcd/xine-extra.c
blob: 27c89da2283dab32392b4e1dce1de8d6f3567421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* 
  $Id: xine-extra.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $
 
  Copyright (C) 2002 Rocky Bernstein <rocky@panix.com>
  
  Program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
 
  These are routines that probably should be in xine, but for whatever
  reason aren't - yet. 
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef HAVE_VCDNAV
#include <cdio/types.h>
#else
#include "cdio/types.h"
#endif

#include "xine-extra.h"

static xine_t *my_xine = NULL;

/* This is modified from xine_log() and should really reside inside
   xine-lib/src/xine-engine/xine.c. It logs a message to "buf" and also
   prints it to stream.
*/

static void 
xine_vflog(xine_t *this, FILE *stream, int buf, const char *format, 
           va_list args)
{
  this->log_buffers[buf]->scratch_printf(this->log_buffers[buf], format, args);
  vfprintf(stream, format, args);
}

/*!
  This routine is like xine_log, except it takes a va_list instead of
  a variable number of arguments. It might be useful as a function
  pointer where one wants a specific prototype.

  In short this writes a message to buffer 'buf' and to stdout.
*/

void 
xine_vlog_msg(xine_t *this, int buf, const char *format, va_list args)
{
  xine_vflog(this, stdout, buf, format, args);
}

/*! This routine is like xine_log, except it takes a va_list instead
  of a variable number of arguments and writes to stderr rather than
  stdout. It might be useful as a function pointer where one wants a
  specific prototype.

  In short this writes a message to buffer 'buf' and to stderr.
*/
void 
xine_vlog_err(xine_t *this, int buf, const char *format, va_list args)
{
  xine_vflog(this, stderr, buf, format, args);
}

/*! Call this before calling any of the xine_log_msg or xine_log_err
  routines. It sets up the xine buffer that will be used in error
  logging.  

  \return true if everything went okay; false is returned if
  logging was already initialized, in which case nothing is done.

 */
bool
xine_log_init(xine_t *this)
{
  if (NULL == this) return false;
  my_xine = this;
  return true;
}

/*! This routine is like xine_log without any xine-specific paramenters.
  Before calling this routine you should have set up a xine log buffer via
  xine_log_init(). 

  In short this writes a message to buffer 'buf' and to stdout.

  \return true if everything went okay; false is there was 
  an error, such as logging wasn't initialized. On error, nothing is 
  logged.
*/
bool
xine_log_msg(const char *format, ...)
{
  va_list args;

  if (NULL == my_xine) return false;
  va_start(args, format);
  xine_vlog_msg(my_xine, XINE_LOG_MSG, format, args);
  va_end(args);
  return true;
}

/*! This routine is like xine_log without any xine-specific paramenters.
  Before calling this routine you should have set up a xine log buffer via
  xine_log_init(). 

  In short this writes a message to buffer 'buf' and to stdout.

  \return true if everything went okay; false is there was 
  an error, such as logging wasn't initialized. On error, nothing is 
  logged.
*/
bool
xine_log_err(const char *format, ...)
{
  va_list args;

  va_start(args, format);
  if (NULL == my_xine) return false;
  xine_vlog_err(my_xine, XINE_LOG_MSG, format, args);
  va_end(args);
  return true;
}

void
xine_free_mrls(int *num_mrls, xine_mrl_t **mrls) 
{
  (*num_mrls)--;
  for ( ; *num_mrls >= 0; (*num_mrls)-- ) {
    MRL_ZERO(mrls[*num_mrls]);
    free(mrls[*num_mrls]);
  }
  mrls=NULL;
  *num_mrls=0;
}