File: plurlsrc.h

package info (click to toggle)
paintlib 2.6.2-14
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 7,920 kB
  • ctags: 3,874
  • sloc: cpp: 25,209; sh: 10,605; ansic: 1,891; makefile: 120
file content (109 lines) | stat: -rw-r--r-- 2,233 bytes parent folder | download | duplicates (2)
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
/*
/--------------------------------------------------------------------
|
|      $Id: plurlsrc.h,v 1.4 2004/08/20 14:39:38 uzadow Exp $
|
|      Copyright (c) 1996-2002 Ulrich von Zadow
|
\--------------------------------------------------------------------
*/

#ifndef INCL_PLURLSRC
#define INCL_PLURLSRC

#ifndef INCL_PLDATASRC
#include "pldatasrc.h"
#endif

#include <string>
#include <curl/curl.h>

// Internal singleton class that initializes and deinitializes curl
class PLCurlInitializer
{
public:
  CURL * getHandle();
  void finalize();

private:
  friend class PLURLSource;
  PLCurlInitializer();
  ~PLCurlInitializer();

  CURL * m_CurlHandle;

};

// This is a class which takes a URL as a source of
// picture data.
class PLURLSource : public PLDataSource
{
public:
  //!
  PLURLSource
    ();

  //!
  virtual ~PLURLSource
    ();

  //!
  virtual int Open(const char *pURL);

  //!
  virtual void Close
    ();

  virtual PLBYTE * ReadNBytes
    ( int n
    );

  //! Read but don't advance file pointer.
  virtual PLBYTE * GetBufferPtr
    ( int MinBytesInBuffer
    );

  //! This is a legacy routine that interferes with progress notifications.
  //! Don't call it!
  virtual PLBYTE * ReadEverything
    ();

  virtual void Seek
    ( int n
    );

  const char * GetCurlErrStr ();
  int GetCurlErrCode ();

private:
  static size_t WriteCurlData(void *ptr, size_t size, size_t nmemb, void *stream);
  const std::string httpErr2Str(int HTTPCode);
  // So curl gets initialized once only.
  static PLCurlInitializer s_CurlInitializer;
  std::string m_RawData;
  int m_CurPos;

  std::string m_sErrStr;
  int m_ErrCode;
};

#endif
/*
/--------------------------------------------------------------------
|
|      $Log: plurlsrc.h,v $
|      Revision 1.4  2004/08/20 14:39:38  uzadow
|      Added rle format to sgi decoder. Doesn't work yet, though.
|
|      Revision 1.3  2003/04/20 12:44:47  uzadow
|      Added EXIF documentation.
|
|      Revision 1.2  2003/04/14 10:48:19  uzadow
|      Added connection reuse capability to PLURLSource.
|
|      Revision 1.1  2003/02/15 21:26:58  uzadow
|      Added win32 version of url data source.
|
|
\--------------------------------------------------------------------
*/