54 lines
1.3 KiB
C
54 lines
1.3 KiB
C
/*
|
|
* utils.c
|
|
* This file is part of Network-inador
|
|
*
|
|
* Copyright (C) 2022 - Félix Arreola Rodríguez
|
|
*
|
|
* Network-inador 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.
|
|
*
|
|
* Network-inador is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Network-inador; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "utils.h"
|
|
|
|
void utils_trim (char * s) {
|
|
char * p = s;
|
|
int l = strlen(p);
|
|
|
|
while(l > 0 && isspace(p[l - 1])) p[--l] = 0;
|
|
while(* p && isspace(* p)) ++p, --l;
|
|
|
|
memmove(s, p, l + 1);
|
|
}
|
|
|
|
void utils_trim_comment (char *s) {
|
|
char *p = s;
|
|
int l = strlen (p);
|
|
|
|
while (*p != 0 && *p != '#') {
|
|
++p;
|
|
}
|
|
|
|
if (*p == '#') {
|
|
*p = 0;
|
|
}
|
|
}
|
|
|