~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to src/lib/libpsio/filescfg.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <libpsio/psio.h>
 
2
#include <libpsio/psio.hpp>
 
3
 
 
4
#include <string>
 
5
#include <map>
 
6
#include <sstream>
 
7
#include <algorithm>
 
8
#include <cctype>
 
9
 
 
10
using namespace std;
 
11
using namespace psi;
 
12
 
 
13
namespace {
 
14
  std::string fullkwd(const char* kwdgrp, const char* kwd, int unit) {
 
15
    std::string unitname;
 
16
    if (unit < 0)
 
17
      unitname = "DEFAULT";
 
18
    else {
 
19
      std::ostringstream oss;
 
20
      oss << "FILE"<< unit;
 
21
      unitname = oss.str();
 
22
    }
 
23
    const std::string sep(":");
 
24
    
 
25
    std::string fkwd = sep + kwdgrp + sep + "FILES"+ sep + unitname + sep + kwd;
 
26
    // convert to upper case
 
27
    std::transform(fkwd.begin(), fkwd.end(), fkwd.begin(), static_cast<int(*)(int)>(toupper));
 
28
    return fkwd;
 
29
  }
 
30
}
 
31
 
 
32
void PSIO::filecfg_kwd(const char* kwdgrp, const char* kwd, int unit,
 
33
                       const char* kwdval) {
 
34
  std::string fkwd = fullkwd(kwdgrp, kwd, unit);
 
35
  files_keywords_[fkwd] = kwdval;
 
36
}
 
37
 
 
38
const std::string&PSIO::filecfg_kwd(const char* kwdgrp, const char* kwd,
 
39
                                    int unit) {
 
40
  static std::string nullstr;
 
41
  
 
42
  const std::string fkwd = fullkwd(kwdgrp, kwd, unit);
 
43
  KWDMap::const_iterator kwd_loc = files_keywords_.find(fkwd);
 
44
  if (kwd_loc != files_keywords_.end())
 
45
    return kwd_loc->second;
 
46
  else
 
47
    return nullstr;
 
48
}
 
49
 
 
50
extern "C" {
 
51
  
 
52
  int psio_set_filescfg_kwd(const char* kwdgrp, const char* kwd, int unit,
 
53
                            const char* kwdval) {
 
54
    _default_psio_lib_->filecfg_kwd(kwdgrp, kwd, unit, kwdval);
 
55
    return 1;
 
56
  }
 
57
  
 
58
  const char* psio_get_filescfg_kwd(const char* kwdgrp, const char* kwd,
 
59
                                    int unit) {
 
60
    return _default_psio_lib_->filecfg_kwd(kwdgrp,kwd,unit).c_str();
 
61
  }
 
62
 
 
63
}