Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
Functions
openorpipe.c File Reference

Open a file for writing unless the filename starts with a | in which case open as a pipe. More...

#include "port.h"
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include "macros.h"

Go to the source code of this file.

Functions

FILE * popen (char *, char *)
 
int pclose (FILE *)
 
FILE * blOpenOrPipe (char *filename)
 
int blCloseOrPipe (FILE *fp)
 

Detailed Description

Open a file for writing unless the filename starts with a | in which case open as a pipe.

Version
V1.10
Date
17.07.14
Author
Dr. Andrew C. R. Martin
Institute of Structural & Molecular Biology, University College London, Gower Street, London. WC1E 6BT.
andre.nosp@m.w@bi.nosp@m.oinf..nosp@m.org..nosp@m.uk andre.nosp@m.w.ma.nosp@m.rtin@.nosp@m.ucl..nosp@m.ac.uk

This code is NOT IN THE PUBLIC DOMAIN, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC.

The code may be modified as required, but any modifications must be documented so that the person responsible can be identified.

The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.

Description:

Usage:

Revision History:

Definition in file openorpipe.c.

Function Documentation

int blCloseOrPipe ( FILE *  fp)
Parameters
[in]*fpFile pointer to be closed
Returns
Error code (as for fclose())

Attempts to close a file pointer as a pipe. If it isn't associated with a pipe (i.e. pclose returns (-1)), tries again to close it as a normal file.

  • 26.05.97 Original By: ACRM
  • 26.06.97 Added call to signal()
  • 28.01.05 Added NOPIPE define
  • 02.04.09 Moved 'int ret' to be in the #else
  • 07.07.14 Use bl prefix for functions By: CTP
  • 17.07.14 Added check that the file pointer isn't stdout By: ACRM

Definition at line 172 of file openorpipe.c.

FILE* blOpenOrPipe ( char *  filename)
Parameters
[in]*filenameA file or pipe to be opened
Returns
A file pointer

Opens a file for writing unless the filename begins with a | in which case it is opened as a pipe.

Broken pipe signals are ignored.

  • 26.05.97 Original By: ACRM
  • 26.06.97 Added call to signal()
  • 18.08.98 Added case to popen() for SunOS
  • 28.01.05 Added NOPIPE define
  • 07.07.14 Use bl prefix for functions By: CTP
  • 17.07.14 Added special 'stdout' file By: ACRM

Definition at line 128 of file openorpipe.c.

int pclose ( FILE *  )
FILE* popen ( char *  ,
char *   
)