#include <string.h>#include <stdlib.h>#include <ctype.h>#include "mode.h"#include "util.h"#include "extr_ct.h"#include "bcf_s.h"
Include dependency graph for util.c:Data Structures | |
| struct | tagElData |
Macros | |
| #define | is_ascii(c) ((unsigned)(c) < 0x80) |
| #define | MIN_ATOM_CHARGE (-2) |
| #define | MAX_ATOM_CHARGE 2 |
| #define | NEUTRAL_STATE (-MIN_ATOM_CHARGE) |
| #define | NUM_ATOM_CHARGES (MAX_ATOM_CHARGE - MIN_ATOM_CHARGE + 1) |
| #define | MAX_NUM_VALENCES 5 /* max. number + 1 to provide zero termination */ |
| #define | MAXQ 16 |
| #define | __MYTOLOWER(c) ( ((c) >= 'A') && ((c) <= 'Z') ? ((c) - 'A' + 'a') : (c) ) |
Typedefs | |
| typedef struct tagElData | ELDATA |
Functions | |
| int | get_element_chemical_symbol (int nAtNum, char *szElement) |
| Finds chemical symbol for element of given number. | |
| int | get_element_or_pseudoelement_symbol (int nAtNum, char *szElement) |
| Finds symbol for element of given number. Accounts for (translates)pseudoelements. | |
| int | el_number_in_internal_ref_table (const char *elname) |
| int | get_periodic_table_number (const char *elname) |
| Get the periodic table number object. | |
| int | if_skip_add_H (int nPeriodicNum) |
| Check if no H addition allowed. | |
| int | get_el_valence (int nPeriodicNum, int charge, int val_num) |
| Get reference value of atom valence at given charge. | |
| int | get_unusual_el_valence (int nPeriodicNum, int charge, int radical, int bonds_valence, int num_H, int num_bonds) |
| Output valence needed to unambiguosly reconstruct bonds. | |
| int | needed_unusual_el_valence (int nPeriodicNum, int charge, int radical, int bonds_valence, int actual_bonds_valence, int num_H, int num_bonds) |
| Output valence needed to unambiguosly reconstruct number of H. | |
| int | detect_unusual_el_valence (int nPeriodicNum, int charge, int radical, int bonds_valence, int num_H, int num_bonds) |
| Output valence that does not fit any known valences. | |
| int | get_el_type (int nPeriodicNum) |
| Get the el type object. | |
| int | is_el_a_metal (int nPeriodicNum) |
| Check if an element is a metal. | |
| int | extract_charges_and_radicals (char *elname, int *pnRadical, int *pnCharge) |
| Extract charges and radicals from element name. | |
| int | extract_H_atoms (char *elname, S_CHAR num_iso_H[]) |
| Extract H atoms from element name. | |
| int | get_num_H (const char *elname, int inp_num_H, S_CHAR inp_num_iso_H[], int charge, int radical, int chem_bonds_valence, int atom_input_valence, int bAliased, int bDoNotAddH, int bHasMetalNeighbor) |
| Get the number of attached hydrogens. | |
| int | get_atomic_mass_from_elnum (int nAtNum) |
| Get the atomic mass from elnum object. | |
| int | get_atomic_mass (const char *elname) |
| Get the atomic mass object. | |
| AT_NUMB * | is_in_the_list (AT_NUMB *pathAtom, AT_NUMB nNextAtom, int nPathLen) |
| Checks if an atom is in the list/path. | |
| int * | is_in_the_ilist (int *pathAtom, int nNextAtom, int nPathLen) |
| Checks if an integer is in the list/path. | |
| int | is_ilist_inside (int *ilist, int nlist, int *ilist2, int nlist2) |
| Checks if one list of integers is inside another list (ilist in ilist2) | |
| int | nBondsValToMetal (inp_ATOM *at, int iat) |
| Gets the number of bond valences to a metal atom. | |
| int | num_of_H (inp_ATOM *at, int iat) |
| Get the number of hydrogens. | |
| U_CHAR | ion_el_group (int el) |
| Get the element group of an element. The base element rather than the periodic group is used to aid readability. | |
| int | has_other_ion_neigh (inp_ATOM *at, int iat, int iat_ion_neigh) |
| Check whether an atom has ion neighbors. | |
| int | has_other_ion_in_sphere_2 (inp_ATOM *at, int iat, int iat_ion_neigh) |
| Check whether an atom has ion neighbors within sphere (breath first search (BFS) up to r=2) | |
| int | nNoMetalNumBonds (inp_ATOM *at, int at_no) |
| Returns the number of non-metal bonds. | |
| int | nNoMetalBondsValence (inp_ATOM *at, int at_no) |
| Returns the number of non-metal bond valences. | |
| int | nNoMetalNeighIndex (inp_ATOM *at, int at_no) |
| Get the index of the first element that is not a metal. | |
| int | nNoMetalOtherNeighIndex (inp_ATOM *at, int at_no, int cur_neigh) |
| Get the index of an element that is not a metal excluding a given index. | |
| int | nNoMetalOtherNeighIndex2 (inp_ATOM *at, int at_no, int cur_neigh, int cur_neigh2) |
| Get the index of an element that is not a metal excluding a 2 given indexes. | |
| int | get_endpoint_valence (U_CHAR el_number) |
| Get the endpoint valence object. | |
| int | get_endpoint_valence_KET (U_CHAR el_number) |
| Get the endpoint valence KET object. | |
| int | normalize_string (char *name) |
| Normalize string (remove leading & trailing spaces, replace consecutive spaces with a single space, remove tabs.) | |
| int | dotify_non_printable_chars (char *line) |
| Replace non-ASCII characters with '.',. | |
| int | read_upto_delim (char **pstring, char *field, int maxlen, char *delims) |
| Read up to any delimiter from the string. | |
| int | is_matching_any_delim (char c, char *delims) |
| Check if a character is in the list of possible delimiters. | |
| void | remove_trailing_spaces (char *p) |
| Remove trailing spaces from a string. | |
| void | remove_one_lf (char *p) |
| Remove one line feed character from the end of a string. | |
| int | mystrncpy (char *target, const char *source, unsigned maxlen) |
| Copies up to maxlen characters INCLUDING end null from source to target. Fills out the rest of the target with null bytes. Protected from non-zero-terminated source and overlapped target/source. | |
| char * | lrtrim (char *p, int *nLen) |
| Trim leading and trailing spaces from a string. | |
| void | extract_inchi_substring (char **buf, const char *str, size_t slen) |
| Extract InChI substring embedded into a longer string. | |
| void | extract_auxinfo_substring (char **buf, const char *str, size_t slen) |
| Extract AuxInfo substring embedded into a longer string. | |
| int | inchi_memicmp (const void *p1, const void *p2, size_t length) |
| Compare two memory blocks in a case-insensitive manner. | |
| int | inchi_stricmp (const char *s1, const char *s2) |
| Case-insensitive string comparison. | |
| char * | inchi__strnset (char *s, int val, size_t length) |
| Set a string to a specified value for a given length. | |
| char * | inchi__strdup (const char *string) |
| Duplicate a string. | |
Variables | |
| const ELDATA | ElData [] |
| const int | ERR_ELEM = 255 |
| const int | nElDataLen = sizeof( ElData ) / sizeof( ElData[0] ) - 1 |
| #define __MYTOLOWER | ( | c | ) | ( ((c) >= 'A') && ((c) <= 'Z') ? ((c) - 'A' + 'a') : (c) ) |
| #define is_ascii | ( | c | ) | ((unsigned)(c) < 0x80) |
| #define MAX_ATOM_CHARGE 2 |
| #define MAX_NUM_VALENCES 5 /* max. number + 1 to provide zero termination */ |
| #define MAXQ 16 |
| #define MIN_ATOM_CHARGE (-2) |
| #define NEUTRAL_STATE (-MIN_ATOM_CHARGE) |
| #define NUM_ATOM_CHARGES (MAX_ATOM_CHARGE - MIN_ATOM_CHARGE + 1) |
| int detect_unusual_el_valence | ( | int | nPeriodicNum, |
| int | charge, | ||
| int | radical, | ||
| int | bonds_valence, | ||
| int | num_H, | ||
| int | num_bonds | ||
| ) |
Output valence that does not fit any known valences.
| nPeriodicNum | Periodic table number |
| charge | Charge |
| radical | Radical |
| bonds_valence | Bonds valence |
| num_H | Number of hydrogens |
| num_bonds | Number of bonds |
Here is the call graph for this function:
Here is the caller graph for this function:| int dotify_non_printable_chars | ( | char * | line | ) |
Replace non-ASCII characters with '.',.
| line | Pointer to the input line |
Here is the caller graph for this function:| int el_number_in_internal_ref_table | ( | const char * | elname | ) |
Here is the caller graph for this function:| void extract_auxinfo_substring | ( | char ** | buf, |
| const char * | str, | ||
| size_t | slen | ||
| ) |
Extract AuxInfo substring embedded into a longer string.
| buf | Pointer to output buffer |
| str | Pointer to input string |
| slen | Length of the input string |
Here is the caller graph for this function:| int extract_charges_and_radicals | ( | char * | elname, |
| int * | pnRadical, | ||
| int * | pnCharge | ||
| ) |
Extract charges and radicals from element name.
| elname | Element name |
| pnRadical | Number of radicals |
| pnCharge | Number of charges |
Here is the caller graph for this function:| int extract_H_atoms | ( | char * | elname, |
| S_CHAR | num_iso_H[] | ||
| ) |
Extract H atoms from element name.
| elname | Element name |
| num_iso_H | Number of isotopic H |
Here is the caller graph for this function:| void extract_inchi_substring | ( | char ** | buf, |
| const char * | str, | ||
| size_t | slen | ||
| ) |
Extract InChI substring embedded into a longer string.
| buf | Pointer to output buffer |
| str | Pointer to input string |
| slen | Length of the input string |
Here is the caller graph for this function:| int get_atomic_mass | ( | const char * | elname | ) |
Get the atomic mass object.
| elname | Element name |
Here is the call graph for this function:
Here is the caller graph for this function:| int get_atomic_mass_from_elnum | ( | int | nAtNum | ) |
Get the atomic mass from elnum object.
| nAtNum | Element number |
Here is the caller graph for this function:| int get_el_type | ( | int | nPeriodicNum | ) |
Get the el type object.
| nPeriodicNum | Periodic table number |
Here is the caller graph for this function:| int get_el_valence | ( | int | nPeriodicNum, |
| int | charge, | ||
| int | val_num | ||
| ) |
Get reference value of atom valence at given charge.
| nPeriodicNum | Periodic table number |
| charge | Charge |
| val_num | Valence number |
Here is the caller graph for this function:| int get_element_chemical_symbol | ( | int | nAtNum, |
| char * | szElement | ||
| ) |
Finds chemical symbol for element of given number.
| nAtNum | Atom number |
| szElement | Pointer to chemical symbol |
Here is the caller graph for this function:| int get_element_or_pseudoelement_symbol | ( | int | nAtNum, |
| char * | szElement | ||
| ) |
Finds symbol for element of given number. Accounts for (translates)pseudoelements.
| nAtNum | Atom number |
| szElement | Pointer to chemical symbol |
Here is the caller graph for this function:| int get_endpoint_valence | ( | U_CHAR | el_number | ) |
Get the endpoint valence object.
| el_number | Element number |
Here is the caller graph for this function:| int get_endpoint_valence_KET | ( | U_CHAR | el_number | ) |
Get the endpoint valence KET object.
| el_number | Element number |
Here is the caller graph for this function:| int get_num_H | ( | const char * | elname, |
| int | inp_num_H, | ||
| S_CHAR | num_iso_H[], | ||
| int | charge, | ||
| int | radical, | ||
| int | chem_bonds_valence, | ||
| int | atom_input_valence, | ||
| int | bAliased, | ||
| int | bDoNotAddH, | ||
| int | bHasMetalNeighbor | ||
| ) |
Get the number of attached hydrogens.
| elname | Element name |
| inp_num_H | Input number of H |
| num_iso_H | Number of isotopic H |
| charge | Charge |
| radical | Radical |
| chem_bonds_valence | Number of chemical valence bonds |
| atom_input_valence | Number of atom valence |
| bAliased | Flag indicating whether the atom is aliased?? |
| bDoNotAddH | Flag indicating whether to add hydrogens |
| bHasMetalNeighbor | Flag indicating whether there is a metal neighbor |
Here is the call graph for this function:
Here is the caller graph for this function:| int get_periodic_table_number | ( | const char * | elname | ) |
Get the periodic table number object.
| elname | Pointer to element name |
Here is the call graph for this function:
Here is the caller graph for this function:| int get_unusual_el_valence | ( | int | nPeriodicNum, |
| int | charge, | ||
| int | radical, | ||
| int | bonds_valence, | ||
| int | num_H, | ||
| int | num_bonds | ||
| ) |
Output valence needed to unambiguosly reconstruct bonds.
| nPeriodicNum | Periodic table number |
| charge | Charge |
| radical | Radical |
| bonds_valence | Bonds valence |
| num_H | Number of hydrogens |
| num_bonds | Number of bonds |
Here is the call graph for this function:
Here is the caller graph for this function:| int has_other_ion_in_sphere_2 | ( | inp_ATOM * | at, |
| int | iat, | ||
| int | iat_ion_neigh | ||
| ) |
Check whether an atom has ion neighbors within sphere (breath first search (BFS) up to r=2)
| at | Pointer to atom array |
| iat | Atom id |
| iat_ion_neigh | Atom id of ion neighbor |
Here is the call graph for this function:
Here is the caller graph for this function:| int has_other_ion_neigh | ( | inp_ATOM * | at, |
| int | iat, | ||
| int | iat_ion_neigh | ||
| ) |
Check whether an atom has ion neighbors.
| at | Pointer to atom array |
| iat | Atom id |
| iat_ion_neigh | Atom id of ion neighbor |
Here is the call graph for this function:
Here is the caller graph for this function:| int if_skip_add_H | ( | int | nPeriodicNum | ) |
Check if no H addition allowed.
| nPeriodicNum | Periodic table number |
Here is the caller graph for this function:| char * inchi__strdup | ( | const char * | string | ) |
Duplicate a string.
| string | Pointer to the input string |
Here is the caller graph for this function:| char * inchi__strnset | ( | char * | s, |
| int | val, | ||
| size_t | length | ||
| ) |
Set a string to a specified value for a given length.
| s | Pointer to the string |
| val | Value to set |
| length | Length of the string to set |
| int inchi_memicmp | ( | const void * | p1, |
| const void * | p2, | ||
| size_t | length | ||
| ) |
Compare two memory blocks in a case-insensitive manner.
| p1 | Pointer to the first memory block. |
| p2 | Pointer to the second memory block. |
| length | Number of bytes to compare. |
Here is the caller graph for this function:| int inchi_stricmp | ( | const char * | s1, |
| const char * | s2 | ||
| ) |
Case-insensitive string comparison.
| s1 | Pointer to first string |
| s2 | Pointer to second string |
Here is the caller graph for this function:| U_CHAR ion_el_group | ( | int | el | ) |
Get the element group of an element. The base element rather than the periodic group is used to aid readability.
| el | Element number |
Here is the caller graph for this function:| int is_el_a_metal | ( | int | nPeriodicNum | ) |
Check if an element is a metal.
| nPeriodicNum | Periodic table number |
Here is the caller graph for this function:| int is_ilist_inside | ( | int * | ilist, |
| int | nlist, | ||
| int * | ilist2, | ||
| int | nlist2 | ||
| ) |
Checks if one list of integers is inside another list (ilist in ilist2)
| ilist | Pointer to the first list of integers |
| nlist | Length of ilist |
| ilist2 | Pointer to the second list of integers |
| nlist2 | Length of ilist2 |
Here is the call graph for this function:
Here is the caller graph for this function:| int * is_in_the_ilist | ( | int * | pathAtom, |
| int | nNextAtom, | ||
| int | nPathLen | ||
| ) |
Checks if an integer is in the list/path.
| pathAtom | Pointer to the list/path of integers |
| nNextAtom | Integer to find |
| nPathLen | Length of the list/path |
Here is the caller graph for this function:Checks if an atom is in the list/path.
| pathAtom | Pointer to the list/path of atoms |
| nNextAtom | Atom to find |
| nPathLen | List length |
Here is the caller graph for this function:| int is_matching_any_delim | ( | char | c, |
| char * | delims | ||
| ) |
Check if a character is in the list of possible delimiters.
| c | Character to check |
| delims | String of delimiter characters |
Here is the caller graph for this function:| char * lrtrim | ( | char * | p, |
| int * | nLen | ||
| ) |
Trim leading and trailing spaces from a string.
| p | Pointer to the input string |
| nLen | Length of the trimmed string |
Here is the caller graph for this function:| int mystrncpy | ( | char * | target, |
| const char * | source, | ||
| unsigned | maxlen | ||
| ) |
Copies up to maxlen characters INCLUDING end null from source to target. Fills out the rest of the target with null bytes. Protected from non-zero-terminated source and overlapped target/source.
| target | Target string |
| source | Source string |
| maxlen | Maximum length to copy |
Here is the caller graph for this function:| int nBondsValToMetal | ( | inp_ATOM * | at, |
| int | iat | ||
| ) |
Gets the number of bond valences to a metal atom.
| at | Pointer to atom list |
| iat | Atom number |
Here is the call graph for this function:
Here is the caller graph for this function:| int needed_unusual_el_valence | ( | int | nPeriodicNum, |
| int | charge, | ||
| int | radical, | ||
| int | bonds_valence, | ||
| int | actual_bonds_val, | ||
| int | num_H, | ||
| int | num_bonds | ||
| ) |
Output valence needed to unambiguosly reconstruct number of H.
| nPeriodicNum | Periodic table number |
| charge | Charge |
| radical | Radical |
| bonds_valence | Bonds valence |
| actual_bonds_val | Actual bonds valence |
| num_H | Number of hydrogens |
| num_bonds | Number of bonds |
Here is the call graph for this function:
Here is the caller graph for this function:| int nNoMetalBondsValence | ( | inp_ATOM * | at, |
| int | at_no | ||
| ) |
Returns the number of non-metal bond valences.
| at | Pointer to atom list |
| at_no | Atom number |
Here is the call graph for this function:
Here is the caller graph for this function:| int nNoMetalNeighIndex | ( | inp_ATOM * | at, |
| int | at_no | ||
| ) |
Get the index of the first element that is not a metal.
| at | Pointer to atom list |
| at_no | Atom number |
Here is the call graph for this function:
Here is the caller graph for this function:| int nNoMetalNumBonds | ( | inp_ATOM * | at, |
| int | at_no | ||
| ) |
Returns the number of non-metal bonds.
| at | Pointer to atom list |
| at_no | Atom number |
Here is the call graph for this function:
Here is the caller graph for this function:| int nNoMetalOtherNeighIndex | ( | inp_ATOM * | at, |
| int | at_no, | ||
| int | cur_neigh | ||
| ) |
Get the index of an element that is not a metal excluding a given index.
| at | Pointer to atom list |
| at_no | Atom number |
| cur_neigh | Excluding atom number |
Here is the call graph for this function:
Here is the caller graph for this function:| int nNoMetalOtherNeighIndex2 | ( | inp_ATOM * | at, |
| int | at_no, | ||
| int | cur_neigh, | ||
| int | cur_neigh2 | ||
| ) |
Get the index of an element that is not a metal excluding a 2 given indexes.
| at | Pointer to atom list |
| at_no | Atom number |
| cur_neigh | Excluding atom number 1 |
| cur_neigh2 | Excluding atom number 2 |
Here is the call graph for this function:
Here is the caller graph for this function:| int normalize_string | ( | char * | name | ) |
Normalize string (remove leading & trailing spaces, replace consecutive spaces with a single space, remove tabs.)
| name | Input string to normalize |
Here is the caller graph for this function:| int num_of_H | ( | inp_ATOM * | at, |
| int | iat | ||
| ) |
Get the number of hydrogens.
| at | Pointer to atom list |
| iat | Input atom id |
Here is the caller graph for this function:| int read_upto_delim | ( | char ** | pstring, |
| char * | field, | ||
| int | maxlen, | ||
| char * | delims | ||
| ) |
Read up to any delimiter from the string.
| pstring | Pointer to input string |
| field | Pointer to output field |
| maxlen | Maximum length of the field |
| delims | Delimiters |
Here is the call graph for this function:
Here is the caller graph for this function:| void remove_one_lf | ( | char * | p | ) |
Remove one line feed character from the end of a string.
| p | Input string |
Here is the caller graph for this function:| void remove_trailing_spaces | ( | char * | p | ) |
Remove trailing spaces from a string.
| p | Input string |
Here is the caller graph for this function:| const ELDATA ElData[] |
| const int ERR_ELEM = 255 |