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

Get a space delimited word from a string. More...

#include <stdio.h>
#include <string.h>
#include "macros.h"
#include "SysDefs.h"
#include "array.h"

Go to the source code of this file.

Functions

char * blGetWord (char *buffer, char *word, int maxlen)
 
char * blGetWordNC (char *buffer, char *word, int maxlen)
 
char ** blSplitStringOnCommas (char *string, int minItemLen)
 
char ** blSplitStringOnChars (char *string)
 

Detailed Description

Get a space delimited word from a string.

Version
V2.4
Date
12.03.15
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 GetWord.c.

Function Documentation

char* blGetWord ( char *  buffer,
char *  word,
int  maxlen 
)
Parameters
[in]*bufferInput buffer to read words from
[in]maxlenMax length of output word
[out]*wordWord read from buffer
Returns
Pointer to start of next word in buffer or NULL

This code is a wrapper to doGetWord()

Reads a whitespace/comma delimited word out of buffer into word.

Words containing white space may be wrapped in double inverted commas. A \ is used as an escape character and maybe used to escape any following character. In particular: "\\" -> '\' To get a backslash "\ " -> ' ' To get a hard whitespace (alternatively wrap the string in double inverted commas) "\"" -> '"' To get a double inverted comma

  • 10.06.99 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 268 of file GetWord.c.

char* blGetWordNC ( char *  buffer,
char *  word,
int  maxlen 
)
Parameters
[in]*bufferInput buffer to read words from
[in]maxlenMax length of output word
[out]*wordWord read from buffer
Returns
Pointer to start of next word in buffer or NULL

This code is a wrapper to doGetWord()

Reads a whitespace delimited word out of buffer into word. Commas are treated just like normal characters.

Words containing white space may be wrapped in double inverted commas. A \ is used as an escape character and maybe used to escape any following character. In particular: "\\" -> '\' To get a backslash "\ " -> ' ' To get a hard whitespace (alternatively wrap the string in double inverted commas) "\"" -> '"' To get a double inverted comma

  • 10.06.99 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 300 of file GetWord.c.

char** blSplitStringOnChars ( char *  string)
Parameters
[in]*stringString containing comma-separated items
Returns
Malloc'd array of strings

Splits a string into a list of items malloc'ing a 2D array which contains the item strings. The first dimension will be the number if items plus one. The second dimension will be 2 - a single charcater plus the \0

The last position in the first array will be set to a null string

Note that this routine malloc's a 2D array which will need to be freed

  • 12.03.15 Original By: ACRM

Definition at line 394 of file GetWord.c.

char** blSplitStringOnCommas ( char *  string,
int  minItemLen 
)
Parameters
[in]*stringString containing comma-separated items
[in]minItemLengthMin size to allocate for each item
Returns
Malloc'd array of strings

Splits a comma separated list of items malloc'ing a 2D array which contains the item strings. The first dimension will be the number if items plus one. The second dimension will be the maximum item length plus one, or at least minItemLen.

The last position in the first array will be set to a null string

Note that this routine malloc's a 2D array which will need to be freed

  • 10.03.15 Original By: ACRM

Definition at line 325 of file GetWord.c.