Added readme
[mtetherd] / device.h
1 /*
2 maemo-tethering
3 (c) 2010 Gregor Riepl <onitake@gmail.com>
4
5 Tethering utility for Maemo
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 struct Device;
22
23 typedef struct Device {
24         char *name;
25         char *address;
26         char *startaddress;
27         char *endaddress;
28         struct Device *previous;
29         struct Device *next;
30 } Device;
31
32 // Allocates memory for a device structure and copies the name
33 Device *device_new(const char *name);
34 // Deallocates the device structure and its contents and adjusts the
35 // previous and next pointers of the adjacent structures
36 // Returns the next entry in the chain
37 Device *device_delete(Device *device);
38 // Walks through the device chain starting from device and deallocates all nodes
39 // Does not delete nodes before device!
40 // Returns the previous pointer of device
41 Device *device_delete_all(Device *device);
42 // Appends next to previous, shifting the link pointers if assigned
43 // You can also pass NULL previous, creating a new head node
44 // Returns next
45 Device *device_append(Device *previous, Device *next);
46 // Sets a new device name, deallocating the old one
47 // device->name is set to NULL if an error occurs
48 Device *device_set_name(Device *device, const char *name);
49 // Validates and assigns a new device address, deallocating the old one
50 // device->address is set to NULL if an error occurs
51 Device *device_set_address(Device *device, const char *address);
52 // Validates and assigns a new DHCP range start address, deallocating the old one
53 // device->startaddress is set to NULL if an error occurs
54 Device *device_set_startaddress(Device *device, const char *address);
55 // Validates and assigns a new DHCP range end address, deallocating the old one
56 // device->endaddress is set to NULL if an error occurs
57 Device *device_set_endaddress(Device *device, const char *address);
58 // Returns true if name, address, startaddress and endaddress are assigned, 0 if not
59 int device_validate(Device *device);
60 // Searches for a device name, starting from start and returns a pointer
61 // to the matching node, or NULL if no name matches
62 Device *device_search(Device *start, const char *name);