Added readme
[mtetherd] / device.h
diff --git a/device.h b/device.h
new file mode 100644 (file)
index 0000000..66e0002
--- /dev/null
+++ b/device.h
@@ -0,0 +1,62 @@
+/*
+maemo-tethering
+(c) 2010 Gregor Riepl <onitake@gmail.com>
+
+Tethering utility for Maemo
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+struct Device;
+
+typedef struct Device {
+       char *name;
+       char *address;
+       char *startaddress;
+       char *endaddress;
+       struct Device *previous;
+       struct Device *next;
+} Device;
+
+// Allocates memory for a device structure and copies the name
+Device *device_new(const char *name);
+// Deallocates the device structure and its contents and adjusts the
+// previous and next pointers of the adjacent structures
+// Returns the next entry in the chain
+Device *device_delete(Device *device);
+// Walks through the device chain starting from device and deallocates all nodes
+// Does not delete nodes before device!
+// Returns the previous pointer of device
+Device *device_delete_all(Device *device);
+// Appends next to previous, shifting the link pointers if assigned
+// You can also pass NULL previous, creating a new head node
+// Returns next
+Device *device_append(Device *previous, Device *next);
+// Sets a new device name, deallocating the old one
+// device->name is set to NULL if an error occurs
+Device *device_set_name(Device *device, const char *name);
+// Validates and assigns a new device address, deallocating the old one
+// device->address is set to NULL if an error occurs
+Device *device_set_address(Device *device, const char *address);
+// Validates and assigns a new DHCP range start address, deallocating the old one
+// device->startaddress is set to NULL if an error occurs
+Device *device_set_startaddress(Device *device, const char *address);
+// Validates and assigns a new DHCP range end address, deallocating the old one
+// device->endaddress is set to NULL if an error occurs
+Device *device_set_endaddress(Device *device, const char *address);
+// Returns true if name, address, startaddress and endaddress are assigned, 0 if not
+int device_validate(Device *device);
+// Searches for a device name, starting from start and returns a pointer
+// to the matching node, or NULL if no name matches
+Device *device_search(Device *start, const char *name);