~ubuntu-branches/ubuntu/lucid/sword/lucid

« back to all changes in this revision

Viewing changes to src/modules/filters/cipherfil.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Marsden, Jonathan Marsden, Dmitrijs Ledkovs, Closed Bugs
  • Date: 2009-05-30 11:55:55 UTC
  • mfrom: (1.1.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090530115555-1tdz23ekn0pk1va1
Tags: 1.6.0+dfsg-1
[ Jonathan Marsden ]
* New upstream release. (Closes: #507960) (LP: #320558)
* debian/patches/02_libver.diff:
  - Bump SONAME to 8 -- SWORD 1.6 is not backward compatible with 1.5.11.
* debian/patches/series:
  - Remove 10_diatheke.diff -- included in upstream source.
* debian/patches/:
  - Remove several old unused .diff files.
  - Add 11_regex_only_when_needed.diff to conditionally include regex lib.
  - Add 12_fix_compiler_warnings.diff to remove all compiler warnings.
  - Add 13_fix_osis2mod_compression_default.diff from upstream svn.
  - Add 14_closing_section_not_chapter.diff from upstream svn.
* debian/libsword7.*: 
  - Rename to libsword8.*
  - Change libsword7 to libsword8 within files.
* debian/rules: 
  - SONAME bump to 8.
  - Set library version check to >= 1.6
* debian/control:
  - Change libsword7 to libsword8.
  - Add libsword7 to Conflicts.
  - Fix case of sword to SWORD in package descriptions.
  - Bump Standards-Version to 3.8.1 (no changes needed).
  - Fix section for libsword-dbg to avoid lintian warning.
* debian/rules:
  - Add DFSG get-orig-source target.
* debian/copyright:
  - Fix various mistakes in initial attempt to document copyrights.

[ Dmitrijs Ledkovs ]
* debian/rules: Added utils.mk to use missing-files target and call it on
  each build.
* debian/libsword-dev.install: Added libsword.la, previously missing.
* debian/libsword7.install: Added missing libicu translit files.
* debian/control:
  - Updated all uses of SWORD version to 1.6
  - Added libsword-dbg package
* debian/watch: Fixed a small mistake which was resulting in extra "."
  in final version name.
* debian/rules: simplified manpage processing.
* debian/libsword8.lintian-overrides: added override for module
  installation directory.
* debian/copyright: Updated with information about everyfile.
  Closes: #513448 LP: #322638
* debian/diatheke.examples: moved examples here from the diatheke.install
* debian/rules:
  - enabled shell script based testsuite
  - added commented out cppunit testsuite
* debian/patches/40_missing_includes.diff: 
  - added several missing stdio.h includes to prevent FTBFS of testsuite.

[ Closed Bugs ]
* FTBFS on intrepid (LP: #305172)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *
 
3
 * cipherfil -  SWFilter descendant to decipher a module
 
4
 *
 
5
 * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
 
6
 *      CrossWire Bible Society
 
7
 *      P. O. Box 2528
 
8
 *      Tempe, AZ  85280-2528
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or modify it
 
11
 * under the terms of the GNU General Public License as published by the
 
12
 * Free Software Foundation version 2.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful, but
 
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
 * General Public License for more details.
 
18
 *
 
19
 */
 
20
 
 
21
 
 
22
#include <stdlib.h>
 
23
#include <cipherfil.h>
 
24
#include <swcipher.h>
 
25
#include <swbuf.h>
 
26
 
 
27
SWORD_NAMESPACE_START
 
28
 
 
29
CipherFilter::CipherFilter(const char *key) {
 
30
        cipher = new SWCipher((unsigned char *)key);
 
31
}
 
32
 
 
33
 
 
34
CipherFilter::~CipherFilter() {
 
35
        delete cipher;
 
36
}
 
37
 
 
38
 
 
39
SWCipher *CipherFilter::getCipher() {
 
40
        return cipher;
 
41
}
 
42
 
 
43
 
 
44
char CipherFilter::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
 
45
        if (text.length() > 2) { //check if it's large enough to substract 2 in the next step.
 
46
                unsigned long len = text.length();
 
47
                if (!key) {     // hack, using key to determine encipher, or decipher
 
48
                        cipher->cipherBuf(&len, text.getRawData()); //set buffer to enciphered text
 
49
                        memcpy(text.getRawData(), cipher->Buf(), len);
 
50
//                      text = cipher->Buf(); //get the deciphered buffer
 
51
                }
 
52
                else if ((unsigned long)key == 1) {
 
53
                        cipher->Buf(text.getRawData(), len);
 
54
                        memcpy(text.getRawData(), cipher->cipherBuf(&len), len);
 
55
//                      text = cipher->cipherBuf(&len);
 
56
                }
 
57
        }
 
58
        return 0;
 
59
}
 
60
 
 
61
SWORD_NAMESPACE_END