-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpsub.h
75 lines (68 loc) · 1.52 KB
/
psub.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "time.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "threads.h"
#define BUFFER_SIZE 256
#ifndef __PSUB_H__
#define __PSUB_H__
struct waiting_queue{
int ID;
int status;
char path[BUFFER_SIZE];
char script[BUFFER_SIZE];
char name[BUFFER_SIZE];
char sub_time[BUFFER_SIZE];
};
struct working_queue{
int ID;
char path[BUFFER_SIZE];
char script[BUFFER_SIZE];
char name[BUFFER_SIZE];
char sub_time[BUFFER_SIZE];
char start_time[BUFFER_SIZE];
int status;
};
struct finished_quque{
int ID;
char path[BUFFER_SIZE];
char script[BUFFER_SIZE];
char name[BUFFER_SIZE];
char sub_time[BUFFER_SIZE];
char start_time[BUFFER_SIZE];
char end_time[BUFFER_SIZE];
};
char *getTime(char *timegetted)
{
char buf[256];
struct tm *ptr;
time_t it;
time(&it);
ptr = localtime(&it);
sprintf(buf, "%4d/%02d/%02d %d:%d:%d",ptr->tm_year, ptr->tm_mon, ptr->tm_mday, ptr->tm_hour, ptr->tm_min, ptr->tm_sec);
strcpy(timegetted, buf);
return timegetted;
}
int detectFiles(char *script)
{
FILE *opener;
opener = fopen(script, "r");
if(opener == NULL)
return -1;
else{
fclose(opener);
return 1;
}
} // 1 == exists; -1 == not
char *getFolderName(char *PATH,char *FolderName)
{
int i,count=0;
for(i=strlen(PATH)-1;PATH[i]!='/';i--);
i++;
for(;PATH[i]!='\0';i++){
FolderName[count]=PATH[i];
count++;
}FolderName[count]='\0';
return FolderName;
}
#endif