123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <string.h>
- #include "Config.h"
- //------------------------------------------------------------------------------
- void trim(char *s)
- {
- int i = 0, j, k, l = 0;
- while ((s[i] == ' ') || (s[i] == '\t') || (s[i] == '\n')) {
- i++;
- }
- j = strlen(s) - 1;
- while ((s[j] == ' ') || (s[j] == '\t') || (s[j] == '\n')) {
- j--;
- }
- if (i == 0 && j == strlen(s) - 1) { }
- else if (i == 0) { s[j + 1] = '\0'; }
- else {
- for (k = i; k <= j; k++) { s[l++] = s[k]; }
- s[l] = '\0';
- }
- }
- int mystrcmp(char *p1, char *p2)
- {
- while (*p1 == *p2) {
- if (*p1 == '\0' || *p2 == '\0') {
- break;
- }
- p1++;
- p2++;
- }
- if (*p1 == '\0' && *p2 == '\0') {
- return (PASS);
- } else {
- return (FAIL);
- }
- }
- void substr(char *dest, const char *src, uint32_t start, uint32_t cnt)
- {
- strncpy(dest, src + start, cnt);
- dest[cnt] = 0;
- }
- void split(char **arr, char *str, const char *del)
- {
- char *s = strtok(str, del);
- while (s != NULL) {
- *arr++ = s;
- s = strtok(NULL, del);
- }
- }
|