~ubuntu-branches/ubuntu/natty/libextractor/natty

« back to all changes in this revision

Viewing changes to src/plugins/exiv2/sonymn.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-11-17 20:27:32 UTC
  • mfrom: (1.10.4 upstream) (5.2.5 sid)
  • Revision ID: james.westby@ubuntu.com-20091117202732-ipm2h3gks5bdw2vx
Tags: 0.5.23+dfsg-3
* Building against libltdl7.
* Updating to standards version 3.8.3.
* Adding maintainer homepage field to control.
* Marking maintainer homepage field to be also included in binary
  packages and changelog.
* Adding README.source.
* Simplifying autotools handling in rules.
* Updating README.source.
* Moving maintainer homepage field from control to copyright.
* Dropping la files.
* Simplyfing debhelper install files.
* Bumping versioned build-depends on debhelper.
* Adding depends to dpkg install info.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ***************************************************************** -*- C++ -*-
2
 
/*
3
 
 * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
4
 
 *
5
 
 * This program is part of the Exiv2 distribution.
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU General Public License
9
 
 * as published by the Free Software Foundation; either version 2
10
 
 * of the License, or (at your option) any later version.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
 
 */
21
 
/*
22
 
  File:      sonymn.cpp
23
 
  Version:   $Rev: 600 $
24
 
  Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
25
 
  History:   18-Apr-05, ahu: created
26
 
 */
27
 
// *****************************************************************************
28
 
#include "rcsid.hpp"
29
 
EXIV2_RCSID("@(#) $Id: sonymn.cpp 600 2005-07-09 10:38:09Z ahuggel $");
30
 
 
31
 
// *****************************************************************************
32
 
// included header files
33
 
#include "types.hpp"
34
 
#include "sonymn.hpp"
35
 
#include "makernote.hpp"
36
 
#include "value.hpp"
37
 
 
38
 
// + standard includes
39
 
#include <string>
40
 
#include <sstream>
41
 
#include <iomanip>
42
 
#include <cassert>
43
 
 
44
 
// *****************************************************************************
45
 
// class member definitions
46
 
namespace Exiv2 {
47
 
 
48
 
    //! @cond IGNORE
49
 
    SonyMakerNote::RegisterMn::RegisterMn()
50
 
    {
51
 
        MakerNoteFactory::registerMakerNote("SONY", "*", createSonyMakerNote);
52
 
        MakerNoteFactory::registerMakerNote(
53
 
            sonyIfdId, MakerNote::AutoPtr(new SonyMakerNote));
54
 
 
55
 
        ExifTags::registerMakerTagInfo(sonyIfdId, tagInfo_);
56
 
    }
57
 
    //! @endcond
58
 
 
59
 
    // Sony MakerNote Tag Info
60
 
    const TagInfo SonyMakerNote::tagInfo_[] = {
61
 
        TagInfo(0x2000, "0x2000", "Unknown", sonyIfdId, makerTags, undefined, printValue),
62
 
        TagInfo(0x9001, "0x9001", "Unknown", sonyIfdId, makerTags, undefined, printValue),
63
 
        TagInfo(0x9002, "0x9002", "Unknown", sonyIfdId, makerTags, undefined, printValue),
64
 
        TagInfo(0x9003, "0x9003", "Unknown", sonyIfdId, makerTags, undefined, printValue),
65
 
        TagInfo(0x9004, "0x9004", "Unknown", sonyIfdId, makerTags, undefined, printValue),
66
 
        TagInfo(0x9005, "0x9005", "Unknown", sonyIfdId, makerTags, undefined, printValue),
67
 
        TagInfo(0x9006, "0x9006", "Unknown", sonyIfdId, makerTags, undefined, printValue),
68
 
        TagInfo(0x9007, "0x9007", "Unknown", sonyIfdId, makerTags, undefined, printValue),
69
 
        TagInfo(0x9008, "0x9008", "Unknown", sonyIfdId, makerTags, undefined, printValue),
70
 
        // End of list marker
71
 
        TagInfo(0xffff, "(UnknownSonyMakerNoteTag)", "Unknown SonyMakerNote tag", sonyIfdId, makerTags, invalidTypeId, printValue)
72
 
    };
73
 
 
74
 
    SonyMakerNote::SonyMakerNote(bool alloc)
75
 
        : IfdMakerNote(sonyIfdId, alloc, false)
76
 
    {
77
 
        byte buf[] = {
78
 
            'S', 'O', 'N', 'Y', ' ', 'D', 'S', 'C', ' ', '\0', '\0', '\0'
79
 
        };
80
 
        readHeader(buf, 12, byteOrder_);
81
 
    }
82
 
 
83
 
    SonyMakerNote::SonyMakerNote(const SonyMakerNote& rhs)
84
 
        : IfdMakerNote(rhs)
85
 
    {
86
 
    }
87
 
 
88
 
    int SonyMakerNote::readHeader(const byte* buf,
89
 
                                   long len,
90
 
                                   ByteOrder byteOrder)
91
 
    {
92
 
        if (len < 12) return 1;
93
 
        header_.alloc(12);
94
 
        memcpy(header_.pData_, buf, header_.size_);
95
 
        // Adjust the offset of the IFD for the prefix
96
 
        adjOffset_ = 12;
97
 
        return 0;
98
 
    }
99
 
 
100
 
    int SonyMakerNote::checkHeader() const
101
 
    {
102
 
        int rc = 0;
103
 
        // Check the SONY prefix
104
 
        if (   header_.size_ < 12
105
 
            || std::string(reinterpret_cast<char*>(header_.pData_), 12)
106
 
               != std::string("SONY DSC \0\0\0", 12)) {
107
 
            rc = 2;
108
 
        }
109
 
        return rc;
110
 
    }
111
 
 
112
 
    SonyMakerNote::AutoPtr SonyMakerNote::create(bool alloc) const
113
 
    {
114
 
        return AutoPtr(create_(alloc));
115
 
    }
116
 
 
117
 
    SonyMakerNote* SonyMakerNote::create_(bool alloc) const
118
 
    {
119
 
        AutoPtr makerNote = AutoPtr(new SonyMakerNote(alloc));
120
 
        assert(makerNote.get() != 0);
121
 
        makerNote->readHeader(header_.pData_, header_.size_, byteOrder_);
122
 
        return makerNote.release();
123
 
    }
124
 
 
125
 
    SonyMakerNote::AutoPtr SonyMakerNote::clone() const
126
 
    {
127
 
        return AutoPtr(clone_());
128
 
    }
129
 
 
130
 
    SonyMakerNote* SonyMakerNote::clone_() const
131
 
    {
132
 
        return new SonyMakerNote(*this);
133
 
    }
134
 
 
135
 
// *****************************************************************************
136
 
// free functions
137
 
 
138
 
    MakerNote::AutoPtr createSonyMakerNote(bool alloc,
139
 
                                            const byte* buf,
140
 
                                            long len,
141
 
                                            ByteOrder byteOrder,
142
 
                                            long offset)
143
 
    {
144
 
        return MakerNote::AutoPtr(new SonyMakerNote(alloc));
145
 
    }
146
 
 
147
 
}                                       // namespace Exiv2