Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
general.h
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file general.h
5 
6  \version V1.21
7  \date 26.06.15
8  \brief Header file for general purpose routines
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1994-2015
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.0 11.05.94 Original By: ACRM
50 - V1.1 24.08.94 Added OpenStdFiles()
51 - V1.2 22.09.94 Added OpenFile()
52 - V1.3 17.07.95 Added countchar()
53 - V1.4 11.09.95 Added fgetsany()
54 - V1.5 18.10.95 Moved YorN() to WindIO.h
55 - V1.6 06.11.95 Added StoreString(), InStringList() and FreeStringList()
56 - V1.7 15.12.95 Added QueryStrStr()
57 - V1.8 09.07.96 Added IndxReal()
58 - V1.9 18.09.96 Added padchar()
59 - V1.11 13.06.00 Added strcatalloc()
60 - V1.12 30.05.02 Added WrapString(), WrapPrint(), RightJustify(),
61  GetWordNC() and getfield()
62 - V1.13 07.07.14 Use bl prefix for functions By: CTP
63 - V1.14 31.07.14 Updated deprecation: Removed deprecated.h and added
64  prototypes for renamed functions. By: CTP
65 - V1.15 14.08.14 Moved deprecated function prototypes to deprecated.h
66  By: CTP
67 - V1.16 10.03.15 Added blSplitStringOnCommas() By: ACRM
68 - V1.17 12.03.15 Added blSplitStringOnChars(), blCheckProgName()
69 - V1.18 26.03.15 Added blStrncat()
70 - V1.19 28.04.15 Added blCollapseSpaces()
71 - V1.20 14.05.15 Added blStrdup()
72 - V1.21 26.06.15 Added FREESTRINGLIST() macro
73 
74 *************************************************************************/
75 #ifndef _GENERAL_H
76 #define _GENERAL_H
77 
78 #include <stdio.h>
79 #include "SysDefs.h"
80 #include "MathType.h"
81 
82 typedef struct _stringlist
83 {
84  struct _stringlist *next;
85  char *string;
86 } STRINGLIST;
87 
88 #define FREESTRINGLIST(l) do { \
89  STRINGLIST *_s = NULL; \
90  for(_s = (l); _s != NULL; NEXT(_s)) { \
91  if(_s->string != NULL) free(_s->string); \
92  } \
93  FREELIST((l), STRINGLIST); \
94  } \
95  while(0)
96 
97 
98 void blStringToLower(char *string1, char *string2);
99 void blStringToUpper(char *string1, char *string2);
100 char *blKillLeadSpaces(char *string);
101 void blKillLine(FILE *fp);
102 void blSetExtn(char *File, char *Ext);
103 int blChindex(char *string, char ch);
104 void blWord(char *string1, char *string2);
105 void blWordN(char *string1, char *string2, int MaxChar);
106 void blPadterm(char *string, int length); /* defined in cssr.h */
107 void blPadchar(char *string, int length, char ch);
108 BOOL blCheckExtn(char *string, char *ext);
109 char *blFtostr(char *str, int maxlen, REAL x, int precision);
110 
111 void blGetFilestem(char *filename, char *stem);
112 int blUpstrcmp(char *word1, char *word2);
113 int blUpstrncmp(char *word1, char *word2, int ncomp);
114 char *blGetWord(char *buffer, char *word, int maxsize);
115 char **blSplitStringOnCommas(char *string, int minItemLen);
116 char **blSplitStringOnChars(char *string);
117 BOOL blOpenStdFiles(char *infile, char *outfile, FILE **in, FILE **out);
118 FILE *blOpenFile(char *filename, char *envvar, char *mode, BOOL *noenv);
119 int blCountchar(char *string, char ch);
120 char *blFgetsany(FILE *fp);
121 char *blStrcatalloc(char *instr, char *catstr);
122 char *blStrncat(char *out, const char *in, size_t len);
123 
124 STRINGLIST *blStoreString(STRINGLIST *StringList, char *string);
125 BOOL blInStringList(STRINGLIST *StringList, char *string);
126 void blFreeStringList(STRINGLIST *StringList);
127 
128 char *blQueryStrStr(char *string, char *substring);
129 
130 void blIndexReal(REAL *arrin, int *indx, int n);
131 
132 FILE *blOpenOrPipe(char *filename);
133 int blCloseOrPipe(FILE *fp);
134 
135 BOOL blWrapString(char *in, char *out, int maxlen);
136 BOOL blWrapPrint(FILE *out, char *string);
137 void blRightJustify(char *string);
138 char *blGetWordNC(char *buffer, char *word, int maxlen);
139 void blGetfield(char *buffer, int start, int width, char *str);
140 BOOL blCheckProgName(char *name, char *expected);
141 char *blCollapseSpaces(char *inText);
142 
143 /************************************************************************/
144 /* Include deprecated functions */
145 #define _GENERAL_H_DEPRECATED
146 #include "deprecated.h"
147 /************************************************************************/
148 
149 #endif
int blCountchar(char *string, char ch)
Definition: countchar.c:115
BOOL blWrapString(char *in, char *out, int maxlen)
Definition: wrapprint.c:104
void blWord(char *string1, char *string2)
Definition: Word.c:121
short BOOL
Definition: SysDefs.h:64
void blStringToUpper(char *string1, char *string2)
BOOL blCheckProgName(char *name, char *expected)
Definition: filename.c:95
char * blGetWordNC(char *buffer, char *word, int maxlen)
Definition: GetWord.c:300
void blKillLine(FILE *fp)
Definition: KillLine.c:117
void blPadchar(char *string, int length, char ch)
Definition: padchar.c:119
Redirect calls to deprecated functions.
void blPadterm(char *string, int length)
Definition: padterm.c:117
char * blKillLeadSpaces(char *string)
int blCloseOrPipe(FILE *fp)
Definition: openorpipe.c:172
char * blStrncat(char *out, const char *in, size_t len)
Definition: stringcat.c:97
int blChindex(char *string, char ch)
Definition: chindex.c:122
void blIndexReal(REAL *arrin, int *indx, int n)
Definition: IndxReal.c:110
FILE * blOpenOrPipe(char *filename)
Definition: openorpipe.c:128
BOOL blOpenStdFiles(char *infile, char *outfile, FILE **in, FILE **out)
Definition: OpenStdFiles.c:126
char * blCollapseSpaces(char *inText)
Definition: stringutil.c:108
FILE * blOpenFile(char *filename, char *envvar, char *mode, BOOL *noenv)
Definition: OpenFile.c:146
char * blFtostr(char *str, int maxlen, REAL x, int precision)
Definition: ftostr.c:133
void blSetExtn(char *File, char *Ext)
Definition: SetExtn.c:125
double REAL
Definition: MathType.h:67
char * blStrcatalloc(char *instr, char *catstr)
Definition: strcatalloc.c:100
struct _stringlist * next
Definition: general.h:84
char * blQueryStrStr(char *string, char *substring)
Definition: QueryStrStr.c:113
BOOL blCheckExtn(char *string, char *ext)
Definition: CheckExtn.c:120
BOOL blWrapPrint(FILE *out, char *string)
Definition: wrapprint.c:204
char * blGetWord(char *buffer, char *word, int maxsize)
Definition: GetWord.c:268
void blWordN(char *string1, char *string2, int MaxChar)
Definition: WordN.c:122
int blUpstrcmp(char *word1, char *word2)
Definition: upstrcmp.c:116
void blGetfield(char *buffer, int start, int width, char *str)
Definition: getfield.c:99
void blGetFilestem(char *filename, char *stem)
Definition: GetFilestem.c:116
char * blFgetsany(FILE *fp)
Definition: fgetsany.c:143
void blRightJustify(char *string)
Definition: justify.c:90
STRINGLIST * blStoreString(STRINGLIST *StringList, char *string)
Definition: StoreString.c:131
System-type variable type definitions.
int blUpstrncmp(char *word1, char *word2, int ncomp)
Definition: upstrncmp.c:116
void blFreeStringList(STRINGLIST *StringList)
Type definitions for maths.
void blStringToLower(char *string1, char *string2)
char ** blSplitStringOnChars(char *string)
Definition: GetWord.c:394
char * string
Definition: general.h:85
struct _stringlist STRINGLIST
char ** blSplitStringOnCommas(char *string, int minItemLen)
Definition: GetWord.c:325
BOOL blInStringList(STRINGLIST *StringList, char *string)
Definition: InStringList.c:118