Updated documentation for 0.2 release
[mtetherd] / device.h
1 /*
2   mtetherd
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 #ifndef _MTETHERD_DEVICE_H
22 #define _MTETHERD_DEVICE_H
23
24 typedef struct _Device Device;
25
26 struct _Device {
27         char *name;
28         char *address;
29         char *startaddress;
30         char *endaddress;
31         Device *previous;
32         Device *next;
33 };
34
35 // Allocates memory for a device structure and copies the name
36 Device *device_new(const char *name);
37 // Deallocates the device structure and its contents and adjusts the
38 // previous and next pointers of the adjacent structures
39 // Returns the next entry in the chain
40 Device *device_delete(Device *device);
41 // Walks through the device chain starting from device and deallocates all nodes
42 // Does not delete nodes before device!
43 // Returns the previous pointer of device
44 Device *device_delete_all(Device *device);
45 // Appends next to previous, shifting the link pointers if assigned
46 // You can also pass NULL previous, creating a new head node
47 // Returns next
48 Device *device_append(Device *previous, Device *next);
49 // Sets a new device name, deallocating the old one
50 // device->name is set to NULL if an error occurs
51 Device *device_set_name(Device *device, const char *name);
52 // Validates and assigns a new device address, deallocating the old one
53 // device->address is set to NULL if an error occurs
54 Device *device_set_address(Device *device, const char *address);
55 // Validates and assigns a new DHCP range start address, deallocating the old one
56 // device->startaddress is set to NULL if an error occurs
57 Device *device_set_startaddress(Device *device, const char *address);
58 // Validates and assigns a new DHCP range end address, deallocating the old one
59 // device->endaddress is set to NULL if an error occurs
60 Device *device_set_endaddress(Device *device, const char *address);
61 // Returns true if name, address, startaddress and endaddress are assigned, 0 if not
62 int device_validate(Device *device);
63 // Searches for a device name, starting from start and returns a pointer
64 // to the matching node, or NULL if no name matches
65 Device *device_search(Device *start, const char *name);
66
67 #endif //_MTETHERD_DEVICE_H
68