46 lines
803 B
C
46 lines
803 B
C
|
#include "../include/util.h"
|
||
|
#include "../include/types.h"
|
||
|
#include <stdarg.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
void pdebug(lm_ctx_t *ctx, const char *func, const char *fmt, ...){
|
||
|
if(!ctx->debug)
|
||
|
return;
|
||
|
|
||
|
va_list args;
|
||
|
va_start(args, fmt);
|
||
|
|
||
|
printf("[DEBUG] %s: ", func);
|
||
|
vprintf(fmt, args);
|
||
|
printf("\n");
|
||
|
|
||
|
va_end(args);
|
||
|
}
|
||
|
|
||
|
bool eq(char *s1, char *s2) {
|
||
|
if (NULL == s1 || NULL == s2)
|
||
|
return false;
|
||
|
|
||
|
if (strlen(s1) != strlen(s2))
|
||
|
return false;
|
||
|
|
||
|
return strcmp(s1, s2) == 0;
|
||
|
}
|
||
|
|
||
|
bool is_letter(char c) {
|
||
|
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
||
|
}
|
||
|
|
||
|
bool is_digit(char c) {
|
||
|
return c >= '0' && c <= '9';
|
||
|
}
|
||
|
|
||
|
bool contains(char *str, char s) {
|
||
|
for (char *c = str; *c != 0; c++)
|
||
|
if (*c == s)
|
||
|
return true;
|
||
|
return false;
|
||
|
}
|