Add project for windows DLL
[usb-relay-hid.git] / lib / usb-relay-dll / usb_relay_lib_win32.c
1 // Windows version
2
3 #include "stdafx.h"
4
5 #define USBRL_API __declspec(dllexport)
6 #include "../usb_relay_device.h"
7 #include "../usb_relay_hw.h"
8
9 #include <stdio.h>
10
11 #ifdef _MSC_VER
12 #pragma comment(lib, "setupapi")
13 #pragma comment(lib, "hid")
14 #endif /*_MSC_VER*/
15
16 #undef ERROR
17 #define ERROR (-1)
18 #define OK (0)
19
20 #define dbgprintf(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
21 //#define dbgprintf(fmt, ...) printf(fmt, __VA_ARGS__)
22 //#define dbgprintf(fmt, ...) __noop(fmt, __VA_ARGS__)
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 // Globals
29
30
31 // Public functions:
32
33 /** Initialize the USB Relay Library
34 @returns: This function returns 0 on success and -1 on error.
35 */
36 int USBRL_API usb_relay_init(void)
37 {
38 dbgprintf("Init lib\n");
39 return ERROR;
40 }
41
42 /** Finalize the USB Relay Library.
43 This function frees all of the static data associated with USB Relay Library.
44 It should be called at the end of execution to avoid memory leaks.
45 @returns: This function returns 0 on success and -1 on error.
46 */
47 int USBRL_API usb_relay_exit(void)
48 {
49 return OK;
50 }
51
52 /** Enumerate the USB Relay Devices.*/
53 struct usb_relay_device_info USBRL_API * usb_relay_device_enumerate(void)
54 {
55 return NULL;
56 }
57
58
59 /** Free an enumeration Linked List*/
60 void USBRL_API usb_relay_device_free_enumerate(struct usb_relay_device_info *di)
61 {
62 return;
63 }
64
65 /** Open device by serial number
66 @return: This function returns a valid handle to the device on success or NULL on failure.
67 Example: usb_relay_device_open_with_serial_number("abcde", 5) */
68 intptr_t USBRL_API usb_relay_device_open_with_serial_number(const char *serial_number, unsigned len)
69 {
70 return ERROR;
71 }
72
73 /* Open a USB relay device
74 @return: This function returns a valid handle to the device on success or NULL on failure.
75 */
76 intptr_t USBRL_API usb_relay_device_open(struct usb_relay_device_info *device_info)
77 {
78 return ERROR;
79 }
80
81 /* Close a USB relay device*/
82 void USBRL_API usb_relay_device_close(intptr_t hHandle)
83 {
84 return;
85 }
86
87 /** Turn ON a relay channel on the USB-Relay-Device
88 @param index -- which channel your want to open
89 @param hHandle -- which usb relay device your want to operate
90 @returns: 0 -- success; 1 -- error; 2 -- index is outnumber the number of the usb relay device
91 */
92 int USBRL_API usb_relay_device_open_one_relay_channel(intptr_t hHandle, int index)
93 {
94 return ERROR;
95 }
96
97 /** Turn ON all relay channels on the USB-Relay-Device
98 @param hHandle -- which usb relay device your want to operate
99 @returns: 0 -- success; 1 -- error
100 */
101 int USBRL_API usb_relay_device_open_all_relay_channel(intptr_t hHandle)
102 {
103 return ERROR;
104 }
105
106 /** Turn OFF a relay channel on the USB-Relay-Device
107 @param index -- which channel your want to close
108 @paramhHandle -- which usb relay device your want to operate
109 @returns: 0 -- success; 1 -- error; 2 -- index is outnumber the number of the usb relay device
110 */
111 int USBRL_API usb_relay_device_close_one_relay_channel(intptr_t hHandle, int index)
112 {
113 return ERROR;
114 }
115
116 /** Turn OFF all relay channels on the USB-Relay-Device
117 @paramter: hHandle -- which usb relay device your want to operate
118 @returns: 0 -- success; 1 -- error
119 */
120 int USBRL_API usb_relay_device_close_all_relay_channel(intptr_t hHandle)
121 {
122 return ERROR;
123 }
124
125 /*
126 Status bits: one bit indicate a relay status.
127 bit 0/1/2/3/4/5/6/7/8 indicate channel 1/2/3/4/5/6/7/8 status
128 1 -- means ON, 0 -- means OFF.
129 @returns: 0 -- success; 1 -- error
130 */
131 int USBRL_API usb_relay_device_get_status(intptr_t hHandle, unsigned int *status)
132 {
133 return ERROR;
134 }
135
136 #ifdef __cplusplus
137 }
138 #endif
139