arr_utils.c File Reference


Detailed Description

Dungeon Keeper Array Tools.

Purpose:
Utility functions for working with arrays and strings.
Comment:
None.
Author:
Tomasz Lis
Date:
15 Nov 2007 - 22 Jul 2008
Copying and copyrights:
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Definition in file arr_utils.c.

#include "arr_utils.h"
#include "globals.h"
#include <stdarg.h>

Go to the source code of this file.

Functions

void strip_crlf (char *string_in)
 Strips control characters from end of a string.
char * trim_right (char *string_in)
 Trimms white & control character from string end.
char * trim_left (char *string_in)
 Trimms white & control character from string start.
char * strdup_noquot (char *src)
 Duplicates a string without quotes.
char * strdup_trim (char *src)
 Duplicates a string with trimming.
char * filename_from_path (char *pathname)
 Returns file name only from given filename with path.
short format_map_fname (char *fname, const char *usrinput, const char *levels_path)
 Creates map filename from given string.
char * prepare_short_fname (const char *fname, unsigned int maxlen)
 Prepares short version of the given filename.
short format_data_fname (char **fullname, const char *data_path, const char *format,...)
 Formats data file name.
int arr_ushort_pos (const unsigned short *arr, unsigned short arr_item, int array_count)
 Searches for position of an item in array of unsigned short.


Function Documentation

int arr_ushort_pos ( const unsigned short *  arr,
unsigned short  arr_item,
int  array_count 
)

Searches for position of an item in array of unsigned short.

Parameters:
arr Pointer to the source array.
arr_item The searched item.
array_count Size of the array (number of elements in it).
Returns:
Returns the position, or -1 if cannot find.

Definition at line 280 of file arr_utils.c.

Referenced by cube_wib_animate(), get_orientation_next(), is_animated_cube(), slab_is_door(), slab_is_liquid(), slab_is_room(), slab_is_short_unclmabl(), slab_is_space(), slab_is_tall_unclmabl(), slab_is_wall(), and slab_is_wealth().

char* filename_from_path ( char *  pathname  ) 

Returns file name only from given filename with path.

See also:
prepare_short_fname
Parameters:
pathname The source filename, possibly with path.
Returns:
Pointer to the name in pathname string, with path skipped.

Definition at line 146 of file arr_utils.c.

short format_data_fname ( char **  fullname,
const char *  data_path,
const char *  format,
  ... 
)

Formats data file name.

Allocates memory and prints formatted file name into it. fullname Pointer to the returned file name. data_path Path to the data directory, inserted before filename. format The string format used to create file name.

See also:
format_map_fname
Returns:
Returns true on success.

Definition at line 251 of file arr_utils.c.

Referenced by change_draw_data_texture(), and load_draw_data().

short format_map_fname ( char *  fname,
const char *  usrinput,
const char *  levels_path 
)

Creates map filename from given string.

See also:
format_data_fname
Parameters:
fname The output filename.
usrinput The input string used to create filename.
levels_path Directory path to the folder containing levels.
Returns:
Returns true on success.

Definition at line 168 of file arr_utils.c.

Referenced by format_lvl_fname(), and format_lvl_savfname().

char* prepare_short_fname ( const char *  fname,
unsigned int  maxlen 
)

Prepares short version of the given filename.

Resulting string is never longer than maxlen. Allocates memory for the returned string - you should free() it after use.

Parameters:
fname The input (possibly long) file name.
maxlen Maximal size of the returned output string.
Returns:
Returns the short file name, or NULL on error.

Definition at line 214 of file arr_utils.c.

Referenced by add_stats_to_script(), load_mapfile(), load_mapfile_msg(), and save_mapfile().

char* strdup_noquot ( char *  src  ) 

Duplicates a string without quotes.

Allocates memory and copies null-terminated string, skipping any quotes at start/end of the source. Any white/control character outside of quotes are skipped. All white/control characters inside quotes are preserved.

Parameters:
src The string which is duplicated.
Returns:
The duplicate, or NULL on error.

Definition at line 93 of file arr_utils.c.

Referenced by execute_adikted_command().

char* strdup_trim ( char *  src  ) 

Duplicates a string with trimming.

Allocates memory and copies null-terminated string, skipping any white/control characters at start/end of the source.

Parameters:
src The string which is duplicated.
Returns:
The duplicate, or NULL on error.

Definition at line 124 of file arr_utils.c.

Referenced by load_lif().

void strip_crlf ( char *  string_in  ) 

Strips control characters from end of a string.

See also:
trim_right
Parameters:
string_in the string which is stripped.

Definition at line 28 of file arr_utils.c.

char* trim_left ( char *  string_in  ) 

Trimms white & control character from string start.

See also:
trim_right
Parameters:
string_in The string which is trimmed.
Returns:
Returns string_in+n, where n is amount of characters trimmed.

Definition at line 69 of file arr_utils.c.

char* trim_right ( char *  string_in  ) 

Trimms white & control character from string end.

See also:
strip_crlf
Parameters:
string_in The string which is trimmed.
Returns:
Returns string_in, which is the trimmed string.

Definition at line 48 of file arr_utils.c.


Generated on Tue Sep 2 18:51:48 2008 for libAdikted by  doxygen 1.5.6