1 /*This file is a part of luscus project*/
2 /*Licensed under the Academic Free License version 3.0*/
3 /* $Revision: 7.7 $ */
4 
5 /*****************************************************************************
6 *                                                                            *
7 * This software is copyrighted. You are granted the use of this software and *
8 * can redistribute it freely provided that the software is redistributed in  *
9 * its original form without omissions.                                       *
10 *                                                                            *
11 * Any modifications are prohibited unless explicitly permitted by the MOLCAS *
12 * development group.                                                         *
13 * URL: http://www.teokem.lu.se/molcas                                        *
14 *                                                                            *
15 * Copyright: Theoretical Chemistry                                           *
16 *           Lund University                                                  *
17 *           Sweden                                                           *
18 *                                                                            *
19 *****************************************************************************/
20 
21 
22 #ifndef _mystring_H_
23 #define _mystring_H_
24 
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <ctype.h>
29 
30 void *xmalloc (size_t size);
31 
32 int mytoken (char *in, unsigned int c, char *out, char *innew);
33    /* cut string _in_ at the position _c_
34       in == out // c // innew
35       return 1 if OK.
36     */
37 
38 int myNext (char *, char, int *, int *);
39    /*
40       NOTE : input sring must be mydiet();
41       while (myNext(in,' ', &shift, &len)==0)
42       {
43       strncpy(out,in+shift,len);
44       out[len]=0;
45       shift=shift+len+1;
46       }
47 
48     */
49 
50 int mycut (char *in, char c, char *out);
51    /* cut string _in_ at the position _c_
52       in == out // c // ...
53       return 1
54     */
55 
56 char *strcatc (char *str, unsigned int c);
57   /* strcat for char */
58 char *mystrcatl (char *str, unsigned int c);
59   /* strcatc if last char not c */
60 
61 char *chomp (char *str);
62 char *chop (char *str);
63 
64 int myterminate (char *in, char *term);
65     /* cut string, if any char from terminator are exist */
66 
67 int my7cut (char *in, char c);
68    /* cut string _in_ at the position _c_
69       out == out // c // ...
70       return 1
71     */
72 
73 char *myexchange (char *in, unsigned int a, unsigned int b);
74    /*  replace in _in_ char _a_ to _b_
75       return in.
76     */
77 
78 
79 int myfgets (char *str, int len, FILE * inp);
80    /*  like fgets, but
81     *    -remove \n
82     *    -skip chars before next line
83     *   return 0 at eof, else 1.
84     */
85 
86 int mylastchar (char *str, char c);
87    /*  is last char in str _c_ ?
88     *   return 0 if not, else 1.
89     */
90 
91 int mylastvchar (char *str, char c);
92    /*  is last visible char in str _c_ ?
93     *  return 0 is not, else 1.
94     */
95 
96 int mylastdel (char *str, unsigned int c);
97    /*  is last char in str is _c_ delete it
98     */
99 
100 int mysubdelete (char *str, char *token, char c);
101    /*  if token exist in str, cut token before char c
102     */
103 
104 int mysubstitute (char *in, char *out, char *token, char *ins);
105    /*  if token exist in in, substitute it to ins
106     */
107 int mysubtranc (char *in, char *token, char *ins);
108    /*  substitute all token to ins on place. strlen(token)>=strlen(ins)
109     */
110 
111 char *mydiet (char *str);
112    /*  remove all extra space and \n from str
113     */
114 
115 char *myextradiet (char *str, char c);
116    /*  remove all c from str;
117     */
118 
119 char *mydietspace (char *str);
120    /*  remove all extra space  from str
121     */
122 
123 char *mystrupr (char *str);
124    /*  strupr
125     */
126 char *mystrlwr (char *str);
127    /*  strlwr
128     */
129 
130 int mycount (char *in, unsigned int c);
131     /* return number of chars c in in */
132 int mycount2 (char *in, unsigned int c, int n);
133 int mycounts (char *in, char *sub, char c);
134 
135 int mycounts_next (char *in, char *sub, char c, char *next, int len);
136 
137 int mycutsub (char *in, char c);
138    /* remove beginning of in */
139 int myisnan(double);
140 
141 void printlog(char*);
142 #endif
143