[BACK]Return to Utilities.c CVS log [TXT][DIR] Up to [contributed] / brogue-ce / src / brogue

Annotation of brogue-ce/src/brogue/Utilities.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:  *  Utilities.c
                      3:  *  Brogue
                      4:  *
                      5:  *  Copyright 2012. All rights reserved.
                      6:  *
                      7:  *  This file is part of Brogue.
                      8:  *
                      9:  *  This program is free software: you can redistribute it and/or modify
                     10:  *  it under the terms of the GNU Affero General Public License as
                     11:  *  published by the Free Software Foundation, either version 3 of the
                     12:  *  License, or (at your option) any later version.
                     13:  *
                     14:  *  This program is distributed in the hope that it will be useful,
                     15:  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16:  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17:  *  GNU Affero General Public License for more details.
                     18:  *
                     19:  *  You should have received a copy of the GNU Affero General Public License
                     20:  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
                     21:  */
                     22:
                     23: #include "Rogue.h"
                     24:
                     25: // String Functions
                     26: boolean endswith(const char *str, const char *ending)
                     27: {
                     28:     int str_len = strlen(str), ending_len = strlen(ending);
                     29:     if (str_len < ending_len) return false;
                     30:     return strcmp(str + str_len - ending_len, ending) == 0 ? true : false;
                     31: }
                     32:
                     33: void append(char *str, char *ending, int bufsize) {
                     34:     int str_len = strlen(str), ending_len = strlen(ending);
                     35:     if (str_len + ending_len + 1 > bufsize) return;
                     36:     strcpy(str + str_len, ending);
                     37: }

CVSweb