#include <stdio.h>#include <ctype.h>#include <stdlib.h>#include <string.h>#include <strings.h>#include "common.h"Go to the source code of this file.
Functions | |
| void | NAMD_truncate (char *) |
| int | NAMD_read_line (FILE *, char *, int bufsize=512) |
| int | NAMD_find_word (const char *, const char *) |
| int | NAMD_blank_string (char *) |
| void | NAMD_find_first_word (char *, char *) |
| int | NAMD_read_int (FILE *, const char *) |
| void | NAMD_pad (char *, size_t) |
| void | NAMD_remove_comment (char *) |
|
|
Definition at line 222 of file strlib.C. Referenced by Parameters::read_charmm_parameter_file(), Molecule::read_go_file(), and Parameters::read_parameter_file(). 00223 {
00224 int i; // Current position in str
00225 int blank=1; // Flag 1-> string is blank
00226 int len; // length of the string str
00227
00228 len=strlen(str);
00229
00230 for (i=0; i<len && blank; i++)
00231 {
00232 blank = isspace(str[i]);
00233 }
00234
00235 return(blank);
00236 }
|
|
||||||||||||
|
Definition at line 258 of file strlib.C. References j. Referenced by Parameters::read_charmm_parameter_file(), Molecule::read_go_file(), and Parameters::read_parameter_file(). 00260 {
00261 int i=0; // Position within source
00262 int j=0; // Position within word
00263
00264 /* Skip leading white space */
00265 while ( (source[i] != STRINGNULL) && isspace(source[i]))
00266 i++;
00267
00268 /* Copy the word */
00269 while ( (source[i] != STRINGNULL) && !isspace(source[i]))
00270 {
00271 word[j]=source[i];
00272 i++;
00273 j++;
00274 }
00275
00276 word[j]=STRINGNULL;
00277
00278 return;
00279 }
|
|
||||||||||||
|
Definition at line 180 of file strlib.C. 00182 {
00183 int i=0; // Position inside source
00184 int search_length; // Length of string search
00185 int source_length; // Length of string source
00186 int found=0; // Flag 1-> found the value
00187
00188 search_length=strlen(search);
00189 source_length=strlen(source);
00190
00191 /* While we haven't found it and we haven't readched the */
00192 /* point where our current position plus the length of the */
00193 /* string we are looking for is longer than the string itself,*/
00194 /* check the next search_length characters for a match */
00195 while (!found && ((i+search_length)<=(source_length)))
00196 {
00197 found = (strncasecmp(source+i, search, search_length)==0);
00198
00199 i++;
00200 }
00201
00202 return(found);
00203 }
|
|
||||||||||||
|
Definition at line 382 of file strlib.C. 00384 {
00385 char tmp_string[128];
00386 size_t i;
00387
00388 if (strlen(str) >= length)
00389 return;
00390
00391 for (i=0; i<(length-strlen(str)); i++)
00392 {
00393 tmp_string[i] = ' ';
00394 }
00395
00396 tmp_string[i] = STRINGNULL;
00397
00398 strcat(str, tmp_string);
00399 }
|
|
||||||||||||
|
Definition at line 302 of file strlib.C. References NAMD_die(). 00304 {
00305 int i; // Loop counter
00306 int c; // Character read in from file
00307 char tmp_string[11]; // Temporary string for integer
00308 int isNeg;
00309
00310 /* Skip white space */
00311 while ( ((c=fgetc(fd)) == '\n') || isspace(c) )
00312 {
00313 }
00314
00315 /* Check to make sure we didn't hit EOF */
00316 if (c==EOF)
00317 {
00318 char err_msg[128];
00319
00320 sprintf(err_msg, "EOF ENCOUNTERED READING %s FROM PSF FILE", msg);
00321 NAMD_die(err_msg);
00322 }
00323
00324 /* Now read in the integer itself */
00325 i=0;
00326
00327 /* Modified to read an integer with '-' or '+' sign --Chao Mei */
00328 isNeg = 0;
00329 if(c=='-'){
00330 c = fgetc(fd);
00331 isNeg = 1;
00332 }
00333 if(c=='+')
00334 c = fgetc(fd);
00335
00336
00337 while (!isspace(c))
00338 {
00339 /* Check to make sure we only get #'s */
00340 if (!isdigit(c))
00341 {
00342 char err_msg[128];
00343
00344 sprintf(err_msg, "ALPHA CHARCTER ENCOUNTERED WHILE READING %s FROM PSF FILE", msg);
00345 NAMD_die(err_msg);
00346 }
00347
00348 tmp_string[i] = c;
00349 i++;
00350
00351 c=fgetc(fd);
00352
00353 /* Check to make sure we didn't hit EOF*/
00354 if (c==EOF)
00355 {
00356 char err_msg[128];
00357
00358 sprintf(err_msg, "EOF ENCOUNTERED WHILE READING %s FROM PSF FILE", msg);
00359 NAMD_die(err_msg);
00360 }
00361 }
00362
00363 tmp_string[i]=STRINGNULL;
00364
00365 /* Convert the string to an integer and return its value */
00366 if(isNeg)
00367 return(-atoi(tmp_string));
00368 else
00369 return(atoi(tmp_string));
00370 }
|
|
||||||||||||||||
|
Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved. Definition at line 38 of file strlib.C. References NAMD_die(). Referenced by Parameters::read_charmm_parameter_file(), Molecule::read_go_file(), and Parameters::read_parameter_file(). 00040 {
00041 int i=0; // Current position in buf
00042 int c; // Character read in from file
00043
00044 /* Loop and read characters until we get either an EOF or a */
00045 /* newline */
00046 while ( ((c=fgetc(fd)) != EOF) && (c != '\n') )
00047 {
00048 /* If we encounter a bracketed comment, skip it. This */
00049 /* basically means read EVERYTHING until the next } and*/
00050 /* throw it into the big bit bucket */
00051 if (c == '{')
00052 {
00053 while ( ((c=fgetc(fd)) != EOF) && (c!='}') )
00054 {
00055 }
00056
00057 if (c==EOF)
00058 {
00059 buf[i]=STRINGNULL;
00060 char *err_msg = new char[128 + strlen(buf)];
00061 sprintf(err_msg, "ABNORMAL EOF FOUND - buffer=*%s*\n", buf);
00062 NAMD_die(err_msg);
00063 }
00064
00065 continue;
00066 }
00067
00068 /* Also, use this little piece of logic to remove */
00069 /* any leading spaces from the line */
00070 if ((i>0) || !isspace(c))
00071 {
00072 buf[i] = c;
00073 i++;
00074 if ( i == bufsize ) {
00075 i--;
00076 buf[i]=STRINGNULL;
00077 char *err_msg = new char[128 + strlen(buf)];
00078 sprintf(err_msg, "BUFFER OVERRUN - buffer=*%s*\n",
00079 buf);
00080 NAMD_die(err_msg);
00081 }
00082 }
00083 }
00084
00085 /* NULL terminate the string */
00086 buf[i]=STRINGNULL;
00087
00088 /* Check for an EOF in the middle of a line */
00089 if ((c==EOF) && (i!=0))
00090 {
00091 buf[i]=STRINGNULL;
00092 char *err_msg = new char[128 + strlen(buf)];
00093 sprintf(err_msg, "ABNORMAL EOF FOUND - buffer=*%s*\n", buf);
00094 NAMD_die(err_msg);
00095 }
00096
00097 /* Return the appropriate value */
00098 if (c==EOF)
00099 return(-1);
00100 else
00101 return(0);
00102 }
|
|
|
Definition at line 119 of file strlib.C. 00121 {
00122 int i=0;
00123
00124 while ( (str[i] != STRINGNULL) && (str[i] != '!') )
00125 {
00126 i++;
00127 }
00128
00129 str[i] = STRINGNULL;
00130 }
|
|
|
Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved. Definition at line 145 of file strlib.C. 00147 {
00148 int i; // Current position in str
00149
00150 i=strlen(str);
00151
00152 /* Loop from the back of the string until we find a non-space */
00153 for (i--; i>=0 && isspace(str[i]); i--)
00154 {
00155 }
00156
00157 str[i+1]=STRINGNULL;
00158 }
|
1.3.9.1