list.h
Go to the documentation of this file.
00001 /*
00002  *  Driver for the wge100 camera
00003  *  Copyright (C) 2009, 2010 Willow Garage, Inc.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #ifndef __EMLIST_H_
00021 #define __EMLIST_H_
00022 #include "build.h"
00023 #include "ipcam_packet.h"
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00037 /*
00038  * Simple doubly linked list implementation.
00039  *
00040  * Some of the internal functions ("__xxx") are useful when
00041  * manipulating whole lists rather than single entries, as
00042  * sometimes we already know the next/prev entries and we can
00043  * generate better code by using them directly rather than
00044  * using the generic single-entry routines.
00045  */
00046 
00047 struct list_head {
00048         struct list_head *next, *prev;
00049 };
00050 
00051 #define LIST_HEAD_INIT(name) { &(name), &(name) }
00052 
00053 #define LIST_HEAD(name) \
00054         struct list_head name = LIST_HEAD_INIT(name)
00055 
00056 #define INIT_LIST_HEAD(ptr) do { \
00057         (ptr)->next = (ptr); (ptr)->prev = (ptr); \
00058 } while (0)
00059 
00060 /*
00061  * Insert a new entry between two known consecutive entries.
00062  *
00063  * This is only for internal list manipulation where we know
00064  * the prev/next entries already!
00065  */
00066 static inline void __list_add(struct list_head *new_item,
00067                               struct list_head *prev,
00068                               struct list_head *next)
00069 {
00070         next->prev = new_item;
00071         new_item->next = next;
00072         new_item->prev = prev;
00073         prev->next = new_item;
00074 }
00075 
00084 static inline void list_add(struct list_head *new_item, struct list_head *head)
00085 {
00086         __list_add(new_item, head, head->next);
00087 }
00088 
00097 static inline void list_add_tail(struct list_head *new_item, struct list_head *head)
00098 {
00099         __list_add(new_item, head->prev, head);
00100 }
00101 
00102 /*
00103  * Delete a list entry by making the prev/next entries
00104  * point to each other.
00105  *
00106  * This is only for internal list manipulation where we know
00107  * the prev/next entries already!
00108  */
00109 static inline void __list_del(struct list_head *prev, struct list_head *next)
00110 {
00111         next->prev = prev;
00112         prev->next = next;
00113 }
00114 
00120 static inline void list_del(struct list_head *entry)
00121 {
00122         __list_del(entry->prev, entry->next);
00123         entry->next = (struct list_head *) 0;
00124         entry->prev = (struct list_head *) 0;
00125 }
00126 
00131 static inline void list_del_init(struct list_head *entry)
00132 {
00133         __list_del(entry->prev, entry->next);
00134         INIT_LIST_HEAD(entry);
00135 }
00136 
00142 static inline void list_move(struct list_head *list, struct list_head *head)
00143 {
00144         __list_del(list->prev, list->next);
00145         list_add(list, head);
00146 }
00147 
00153 static inline void list_move_tail(struct list_head *list,
00154                                   struct list_head *head)
00155 {
00156         __list_del(list->prev, list->next);
00157         list_add_tail(list, head);
00158 }
00159 
00164 static inline int list_empty(struct list_head *head)
00165 {
00166         return head->next == head;
00167 }
00168 
00169 static inline void __list_splice(struct list_head *list,
00170                                  struct list_head *head)
00171 {
00172         struct list_head *first = list->next;
00173         struct list_head *last = list->prev;
00174         struct list_head *at = head->next;
00175 
00176         first->prev = head;
00177         head->next = first;
00178 
00179         last->next = at;
00180         at->prev = last;
00181 }
00182 
00188 static inline void list_splice(struct list_head *list, struct list_head *head)
00189 {
00190         if (!list_empty(list))
00191                 __list_splice(list, head);
00192 }
00193 
00201 static inline void list_splice_init(struct list_head *list,
00202                                     struct list_head *head)
00203 {
00204         if (!list_empty(list)) {
00205                 __list_splice(list, head);
00206                 INIT_LIST_HEAD(list);
00207         }
00208 }
00209 
00216 #define list_entry(ptr, type, member) \
00217         ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
00218 
00224 #define list_for_each(pos, head) \
00225         for (pos = (head)->next; pos != (head); \
00226                 pos = pos->next)
00227 
00232 #define list_for_each_prev(pos, head) \
00233         for (pos = (head)->prev; pos != (head); \
00234                 pos = pos->prev)
00235 
00242 #define list_for_each_safe(pos, n, head) \
00243         for (pos = (head)->next, n = pos->next; pos != (head); \
00244                 pos = n, n = pos->next)
00245 
00252 #define list_for_each_entry(pos, head, member)                          \
00253         for (pos = list_entry((head)->next, typeof(*pos), member);      \
00254              &pos->member != (head);                                    \
00255              pos = list_entry(pos->member.next, typeof(*pos), member))
00256 
00264 #define list_for_each_entry_safe(pos, n, head, member)                  \
00265         for (pos = list_entry((head)->next, typeof(*pos), member),      \
00266                 n = list_entry(pos->member.next, typeof(*pos), member); \
00267              &pos->member != (head);                                    \
00268              pos = n, n = list_entry(n->member.next, typeof(*n), member))
00269 
00270 typedef enum { CamStatusDiscovered, CamStatusConfigured, CamStatusVideo, CamStatusError, CamStatusMissing } IpCamStatus;
00271 
00272 #define WGE100_CAMINFO_LEN 100
00273 
00274 typedef struct {
00275         uint32_t serial;
00276 
00283   uint32_t hw_version;
00284 
00291   uint32_t fw_version;
00292 
00293         char ifName[128]; // FIXME This is so long that we will never hit the limit. (famous last words)
00294         uint8_t mac[6];
00295         IPAddress ip;
00296   char ip_str[16];
00297 
00298         IpCamStatus status;
00299 
00300         struct list_head list;
00301 
00302   char hwinfo[WGE100_CAMINFO_LEN];
00303 
00304   char cam_name[CAMERA_NAME_LEN];
00305 } IpCamList;
00306 
00307 int wge100CamListInit( IpCamList *ipCamList );
00308 int wge100CamListAdd( IpCamList *ipCamList, IpCamList *newItem);
00309 int wge100CamListFind( IpCamList *ipCamList, uint32_t serial);
00310 int wge100CamListNumEntries( const IpCamList *ipCamList );
00311 IpCamList *wge100CamListGetEntry( const IpCamList *ipCamList, int index );
00312 int wge100CamListDelEntry( IpCamList *ipCamList, int index );
00313 void wge100CamListDelAll( IpCamList *ipCamList );
00314 
00315 #define CAMLIST_ADD_OK  0
00316 #define CAMLIST_ADD_DUP 1
00317 
00318 #ifdef __cplusplus
00319 }
00320 #endif
00321   
00322 #endif


wge100_camera
Author(s): Blaise Gassend, Patrick Mihelich, Eric MacIntosh, David Palchak
autogenerated on Sat Jun 8 2019 20:51:24