win32-taskscheduler 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +12 -0
- data/README +21 -15
- data/Rakefile +54 -0
- data/doc/taskscheduler.txt +419 -0
- data/examples/taskscheduler_example.rb +56 -0
- data/lib/win32/taskscheduler.rb +1677 -0
- data/test/{tc_taskscheduler.rb → test_taskscheduler.rb} +35 -5
- data/win32-taskscheduler.gemspec +36 -0
- metadata +19 -15
- data/ext/extconf.rb +0 -14
- data/ext/win32/taskscheduler.c +0 -2036
- data/ext/win32/taskscheduler.h +0 -103
data/ext/win32/taskscheduler.h
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
#define WIN32_TASKSCHEDULER_VERSION "0.1.0"
|
2
|
-
|
3
|
-
// Prototype
|
4
|
-
static VALUE ts_new_work_item(VALUE self, VALUE job, VALUE trigger);
|
5
|
-
|
6
|
-
#ifdef __cplusplus
|
7
|
-
# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
|
8
|
-
# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
|
9
|
-
#else
|
10
|
-
# define VALUEFUNC(f) (f)
|
11
|
-
# define VOIDFUNC(f) (f)
|
12
|
-
#endif
|
13
|
-
|
14
|
-
#define TASKS_TO_RETRIEVE 5
|
15
|
-
#define TOTAL_RUN_TIME_TO_FETCH 10
|
16
|
-
#define ERROR_BUFFER 1024
|
17
|
-
|
18
|
-
#ifndef NAME_MAX
|
19
|
-
#define NAME_MAX 256
|
20
|
-
#endif
|
21
|
-
|
22
|
-
// I dug these out of WinBase.h
|
23
|
-
#ifndef BELOW_NORMAL_PRIORITY_CLASS
|
24
|
-
#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000
|
25
|
-
#endif
|
26
|
-
|
27
|
-
#ifndef ABOVE_NORMAL_PRIORITY_CLASS
|
28
|
-
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
|
29
|
-
#endif
|
30
|
-
|
31
|
-
#ifndef TASK_FLAG_RUN_ONLY_IF_LOGGED_ON
|
32
|
-
#define TASK_FLAG_RUN_ONLY_IF_LOGGED_ON 0x2000
|
33
|
-
#endif
|
34
|
-
|
35
|
-
static VALUE cTSError;
|
36
|
-
|
37
|
-
struct tsstruct {
|
38
|
-
ITaskScheduler *pITS;
|
39
|
-
ITask *pITask;
|
40
|
-
};
|
41
|
-
|
42
|
-
typedef struct tsstruct TSStruct;
|
43
|
-
|
44
|
-
static void ts_free(TSStruct *p){
|
45
|
-
if(p->pITask != NULL)
|
46
|
-
p->pITask->Release();
|
47
|
-
|
48
|
-
if(p->pITS != NULL)
|
49
|
-
p->pITS->Release();
|
50
|
-
|
51
|
-
CoUninitialize();
|
52
|
-
free(p);
|
53
|
-
}
|
54
|
-
|
55
|
-
static VALUE obj_free(VALUE obj){
|
56
|
-
rb_gc();
|
57
|
-
return Qnil;
|
58
|
-
}
|
59
|
-
|
60
|
-
DWORD bitFieldToHumanDays(DWORD day){
|
61
|
-
return (DWORD)((log((double)day)/log((double)2))+1);
|
62
|
-
}
|
63
|
-
|
64
|
-
DWORD humanDaysToBitField(DWORD day){
|
65
|
-
return (DWORD)pow((double)2, (int)(day-1));
|
66
|
-
}
|
67
|
-
|
68
|
-
// Return an error code as a string
|
69
|
-
LPTSTR ErrorString(DWORD p_dwError)
|
70
|
-
{
|
71
|
-
HLOCAL hLocal = NULL;
|
72
|
-
static char ErrStr[1024];
|
73
|
-
int len;
|
74
|
-
|
75
|
-
if (!(len=FormatMessage(
|
76
|
-
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
77
|
-
FORMAT_MESSAGE_FROM_SYSTEM |
|
78
|
-
FORMAT_MESSAGE_IGNORE_INSERTS,
|
79
|
-
NULL,
|
80
|
-
p_dwError,
|
81
|
-
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
82
|
-
(LPTSTR)&hLocal,
|
83
|
-
0,
|
84
|
-
NULL)))
|
85
|
-
{
|
86
|
-
rb_raise(rb_eStandardError,"Unable to format error message");
|
87
|
-
}
|
88
|
-
memset(ErrStr, 0, ERROR_BUFFER);
|
89
|
-
strncpy(ErrStr, (LPTSTR)hLocal, len-2); // remove \r\n
|
90
|
-
LocalFree(hLocal);
|
91
|
-
return ErrStr;
|
92
|
-
}
|
93
|
-
|
94
|
-
/* Private internal function that validates that the TS and ITask struct
|
95
|
-
* members are not null.
|
96
|
-
*/
|
97
|
-
void check_ts_ptr(TSStruct* ptr, const char* func_name){
|
98
|
-
if(ptr->pITS == NULL)
|
99
|
-
rb_raise(cTSError, "Fatal error: null pointer (%s)", func_name);
|
100
|
-
|
101
|
-
if(ptr->pITask == NULL)
|
102
|
-
rb_raise(cTSError, "No currently active task");
|
103
|
-
}
|