Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

nanomud-strings.c File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <windows.h>
#include <winsock.h>
#include <richedit.h>
#include <assert.h>
#include "NanoMud.h"

Include dependency graph for nanomud-strings.c:

Include dependency graph

Go to the source code of this file.

Defines

#define MAX_BUF   512

Functions

char * one_argument (char *argument, char *arg_first)
char * script_strip (char *argument, char *arg_first)
BOOL simple_str_match (char *input, char *pattern)
char * str_dup (const char *str)
int str_ret (const char *str)
BOOL str_search (const char *str)
BOOL string_compare (const char *ostr, const char *tstr)
void strip_junk (char *str)
bool strprefix (const char *astr, const char *bstr)

Variables

char str_empty [1]
char * string_space
char * top_string


Define Documentation

#define MAX_BUF   512
 

Definition at line 37 of file nanomud-strings.c.


Function Documentation

char* one_argument char *  argument,
char *  arg_first
 

Definition at line 153 of file nanomud-strings.c.

References isspace(), and LOWER.

Referenced by check_alias(), check_path(), do_repeat(), and handle_input().

00154 {
00155     char cEnd;
00156 
00157     while (isspace (*argument))
00158         argument++;
00159 
00160     cEnd = ' ';
00161     if (*argument == '\'' || *argument == '"')
00162         cEnd = *argument++;
00163 
00164     while (*argument != '\0')
00165     {
00166         if (*argument == cEnd)
00167         {
00168             argument++;
00169             break;
00170         }
00171         *arg_first = LOWER (*argument);
00172         arg_first++;
00173         argument++;
00174     }
00175     *arg_first = '\0';
00176 
00177     while (isspace (*argument))
00178         argument++;
00179 
00180     return argument;
00181 }

Here is the call graph for this function:

char* script_strip char *  argument,
char *  arg_first
 

Definition at line 182 of file nanomud-strings.c.

References isspace().

Referenced by handle_aliases(), handle_class(), handle_path(), handle_triggers(), and handle_var().

00183 {
00184     char cEnd;
00185 
00186     while (isspace (*argument))
00187         argument++;
00188 
00189     cEnd = '{';
00190     if (*argument == '{' || *argument == '}')
00191         cEnd = *argument++;
00192 
00193     while (*argument != '\0')
00194     {
00195         if (*argument == cEnd || *argument == '}')
00196         {
00197             argument++;
00198             break;
00199         }
00200         
00201         *arg_first = *argument;
00202         arg_first++;
00203         argument++;
00204     }
00205     *arg_first = '\0';
00206 
00207     while (isspace (*argument))
00208         argument++;
00209     while (*argument == '{' || *argument == '}')
00210         argument++;
00211 
00212     return argument;
00213 }

Here is the call graph for this function:

BOOL simple_str_match char *  input,
char *  pattern
 

Definition at line 215 of file nanomud-strings.c.

References BOOL.

00215                                                   {
00216     char *inputPtr = input;
00217     char *whereInput = input;
00218     char *wherePattern = pattern;
00219     
00220     for ( ; inputPtr != '\0' ; inputPtr++) {
00221         whereInput = inputPtr;
00222         wherePattern = pattern;
00223         
00224         if (*whereInput == *wherePattern) {
00225             for ( ; wherePattern != '\0' ; wherePattern++) {
00226                 whereInput++;
00227                 
00228                 if (*whereInput != *wherePattern) {
00229                     break;
00230                 }
00231             }
00232             
00233             return TRUE;
00234         }
00235     }
00236     
00237     return FALSE;
00238 }

char* str_dup const char *  str  ) 
 

Definition at line 57 of file nanomud-strings.c.

References nano_malloc(), and str_empty.

Referenced by add_term(), check_url(), handle_aliases(), handle_class(), handle_input(), handle_path(), handle_set_options(), handle_triggers(), handle_var(), log_html(), parse_ansi(), and ParseLines().

00058 {
00059     char *str_new;
00060 
00061     if (str[0] == '\0' || !str)
00062         return &str_empty[0];
00063     str_new = nano_malloc(strlen (str) > 0 ? strlen(str) : 10,__FILE__,__LINE__);
00064     memcpy(str_new, str, strlen(str));
00065     str_new[strlen(str)] = '\0';
00066     
00067     return str_new;
00068     
00069 }

Here is the call graph for this function:

int str_ret const char *  str  ) 
 

Definition at line 99 of file nanomud-strings.c.

00100 {
00101     const char *point=str;
00102     int i;
00103     for (i=0;*point;point++,i++)
00104     {
00105         if (*point == '\e')
00106             return i;
00107     }
00108     return 0;
00109 }

BOOL str_search const char *  str  ) 
 

Definition at line 72 of file nanomud-strings.c.

References BOOL.

00073 {
00074     
00075     const char *point = str;
00076 
00077 
00078     BOOL efound=FALSE;
00079     BOOL mfound=FALSE;
00080     if (str == NULL)
00081         return FALSE;
00082     for (;;point++)
00083     {
00084         if (*point == '\e')
00085             efound = TRUE;
00086         if (*point == 'm')
00087             mfound = TRUE;
00088         if (!*point)
00089             break;
00090         
00091     }
00092     if (efound && !mfound)
00093         return FALSE;
00094     else
00095         return TRUE;
00096         
00097     
00098 }

BOOL string_compare const char *  ostr,
const char *  tstr
 

Definition at line 41 of file nanomud-strings.c.

References BOOL, and LOWER.

Referenced by del_heap(), handle_aliases(), handle_path(), and handle_triggers().

00042 {
00043     if (ostr == NULL || tstr == NULL)
00044     {
00045         return FALSE;
00046     }
00047     for (;*ostr||*tstr;ostr++,tstr++)
00048     {
00049         if (LOWER(*ostr) != LOWER(*tstr))
00050             
00051             return FALSE;
00052     
00053     }
00054     return TRUE;
00055 }

void strip_junk char *  str  ) 
 

Definition at line 110 of file nanomud-strings.c.

00111 {
00112    
00113     const char *point;
00114     char fleh[8000];
00115     char *buf;
00116     buf = fleh;
00117 
00118     if (str == NULL)
00119         return;
00120     point = str;
00121      for (point=str;*point;point++)
00122     {
00123         if (*point != '\e')
00124         {
00125            *buf = *point;
00126            *++buf ='\0';
00127         }
00128         
00129     }
00130     *++buf = '\0';
00131     str = buf;
00132     return;
00133 }

bool strprefix const char *  astr,
const char *  bstr
 

Definition at line 137 of file nanomud-strings.c.

References LOWER.

Referenced by handle_input(), and handle_set_options().

00138 {
00139 
00140     if (astr == NULL)
00141         return TRUE;
00142     if (bstr == NULL)
00143         return TRUE;
00144     for (; (*astr || *bstr) && *astr != '\0'; astr++, bstr++)
00145     {
00146         if (LOWER (*astr) != LOWER (*bstr))
00147             return TRUE;
00148     }
00149 
00150     return FALSE;
00151 }


Variable Documentation

char str_empty[1]
 

Definition at line 32 of file nanomud-strings.c.

Referenced by str_dup().

char* string_space
 

Definition at line 33 of file nanomud-strings.c.

char* top_string
 

Definition at line 34 of file nanomud-strings.c.


Generated on Sat May 14 02:47:52 2005 for Nanomud by  doxygen 1.3.9.1