-
Notifications
You must be signed in to change notification settings - Fork 0
/
u_util.h
55 lines (45 loc) · 1.91 KB
/
u_util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//------------------------------------------------------------------------
// Utility functions
//------------------------------------------------------------------------
//
// Copyright (C) 2021-2022 The OBSIDIAN Team
// Copyright (c) 2008-2017 Andrew J Apted
//
// 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.
//
// This program 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.
//
//------------------------------------------------------------------------
#include <chrono>
#include <thread>
#ifndef __LIB_UTIL_H__
#define __LIB_UTIL_H__
/* string utilities */
int StringCaseCmp(const char *A, const char *B);
int StringCaseCmpPartial(const char *A, const char *B);
void StringMaxCopy(char *dest, const char *src, int max);
char *StringUpper(const char *name);
char *StringNew(int length);
char *StringDup(const char *orig);
char *StringPrintf(const char *str, ...); // GCCATTR((format (printf, 1, 2)));
void StringFree(const char *str);
/* math utilities */
u32_t IntHash(u32_t key);
u32_t StringHash(const char *str);
#define AlignLen(x) (((x) + 3) & ~3)
double PerpDist(double x, double y, double x1, double y1, double x2, double y2);
double AlongDist(double x, double y, double x1, double y1, double x2,
double y2);
double CalcAngle(double sx, double sy, double ex, double ey);
double ComputeDist(double sx, double sy, double ex, double ey);
double ComputeDist(double sx, double sy, double sz, double ex, double ey,
double ez);
#endif /* __LIB_UTIL_H__ */
//--- editor settings ---
// vi:ts=2:sw=2:expandtab