~ubuntu-branches/debian/sid/nordugrid-arc/sid

« back to all changes in this revision

Viewing changes to src/services/a-rex/grid-manager/conf/conf.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2012-12-13 16:41:31 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20121213164131-0fumka0jar8mxm07
Tags: 2.0.1-1
* 2.0.1 Release
* Drop patches accepted upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#include "../misc/escaped.h"
9
9
#include "environment.h"
10
10
 
11
 
#if defined __GNUC__ && __GNUC__ >= 3
12
 
 
13
 
#include <limits>
14
 
#define istream_readline(__f,__s,__n) {      \
15
 
   __f.get(__s,__n,__f.widen('\n'));         \
16
 
   if(__f.fail()) __f.clear();               \
17
 
   __f.ignore(std::numeric_limits<std::streamsize>::max(), __f.widen('\n')); \
18
 
}
19
 
 
20
 
#else
21
 
 
22
 
#define istream_readline(__f,__s,__n) {      \
23
 
   __f.get(__s,__n,'\n');         \
24
 
   if(__f.fail()) __f.clear();               \
25
 
   __f.ignore(INT_MAX,'\n'); \
26
 
}
27
 
 
28
 
#endif
29
 
 
30
11
bool config_open(std::ifstream &cfile,const GMEnvironment& env) {
31
12
  return config_open(cfile,env.nordugrid_config_loc());
32
13
}
49
30
std::string config_read_line(std::istream &cfile) {
50
31
  std::string rest;
51
32
  for(;;) {
52
 
    if(cfile.eof()) { rest=""; return rest; };
53
 
    {
54
 
      char buf[4096];
55
 
      istream_readline(cfile,buf,sizeof(buf));
56
 
      rest=buf;
57
 
    };
58
 
    std::string::size_type n=rest.find_first_not_of(" \t");
59
 
    if(n == std::string::npos) continue; /* empty string - skip */
60
 
    if(rest[n] == '#') continue; /* comment - skip */
 
33
    if(cfile.eof() || cfile.fail()) { rest=""; return rest; };
 
34
    std::getline(cfile,rest);
 
35
    Arc::trim(rest," \t\r\n");
 
36
    if(rest.empty()) continue; /* empty string - skip */
 
37
    if(rest[0] == '#') continue; /* comment - skip */
61
38
    break;
62
39
  };
63
40
  return rest;