-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpri_func.c
72 lines (65 loc) · 1.77 KB
/
pri_func.c
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "pri_func.h"
int convert(char a)
{
if (a >= '0' && a <= '9') {
return a - '0';
} else if (a >= 'A' && a <= 'F') {
return a - 'A' + 10;
} else if (a >= 'a' && a <= 'f') {
return a - 'a' + 10;
} else {
return -1;
}
}
int modify_log(char *path, char *modify_path)
{
FILE *fp;
struct timeval now;
struct tm *timenow;
gettimeofday(&now, NULL);
timenow = localtime(&now.tv_sec);
fp = fopen(path, "a+");
if (fp == NULL) return -1;
if (feof(fp)) {
if (!fseek(fp, -1, SEEK_END)) {
if (fgetc(fp) != '\n') {
fprintf(fp, "\n");
}
if(fseek(fp, 0, SEEK_END)) return -2;
} else return -1;
}
fprintf(fp, "# [%d.%d.%d-%d:%d:%d-%ld] modify [%s] BY Loading\n", (1900+timenow->tm_year), (1+timenow->tm_mon), timenow->tm_mday, timenow->tm_hour, timenow->tm_min, timenow->tm_sec, now.tv_usec, modify_path);
return 0;
}
void uuid_log(FILE *fp,char* str)
{
char c[200] = {0};
char ttime[100] = {0};
char ttim[100] = {0};
char tq[100] = {0};
memset(c, 0, 200);
memset(ttime, 0, 100);
memset(ttim, 0, 100);
memset(tq, 0, 100);
if (fp != NULL) {
while(!feof(fp))
{
fp_get_str(c, fp);
if(strcmp(c, "\0") != 0) {
fp_get_time_easy(ttime, c);
fp_get_time(ttim, c);
if (strcmp(ttime, str) == 0) {
fp_get(tq, c);
if (bool_q931_q921(tq) == 0) {
printf("%s %s\n", ttim, tq);
syntax_q921(tq);
} else if (bool_q931_q921(tq) == 1) {
printf("%s %s\n", ttim, tq);
syntax_q931(tq);
}
}
}
}
}
fclose(fp);
}