File: allocgz.C

package info (click to toggle)
saods9 8.6%2Brepack-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 23,220 kB
  • sloc: tcl: 78,253; cpp: 71,015; ansic: 3,955; xml: 1,555; sh: 968; makefile: 183; perl: 68
file content (30 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (3)
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
// Copyright (C) 1999-2021
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#include <unistd.h>
#include "allocgz.h"

FitsAllocGZ::FitsAllocGZ(const char* fn)
{
  parse(fn);
  if (!valid_)
    return;

  // reset
  valid_ =0;

  if (!pName_)
    return;

  // we need the 'b' for windows...
  if (!strncmp(pName_, "stdin", 5) || 
      !strncmp(pName_, "STDIN", 5) || 
      !strncmp(pName_, "-", 1))
    stream_ = gzdopen(dup(STDIN_FILENO), "rb");
  else 
    stream_ = gzopen(pName_, "rb");

  valid_ = stream_ ? 1 : 0;
}