changeset 2771:fb399dcc5866

clean up struct typedefs
author p37sitdu, corvid
date Sat, 12 Jan 2013 20:13:36 +0000
parents b73d5f7cf8a3
children df1a2f4f9d5a
files dlib/dlib.h dpi/ftp.c dpip/dpip.h src/bitvec.h src/bw.h src/cache.h src/chain.h src/decode.h src/dicache.c src/dicache.h src/dns.h src/domain.c src/gif.c src/html_common.hh src/jpeg.c src/klist.h src/misc.c src/nav.c src/png.c src/prefs.h src/prefsparser.cc src/url.h
diffstat 22 files changed, 53 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/dlib/dlib.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/dlib/dlib.h	Sat Jan 12 20:13:36 2013 +0000
@@ -99,7 +99,7 @@
  */
 #define Dstr_char_t    char
 
-typedef struct _dstr {
+typedef struct {
    int sz;          /* allocated size (private) */
    int len;
    Dstr_char_t *str;
@@ -128,13 +128,11 @@
 /*
  *-- dList --------------------------------------------------------------------
  */
-struct Dlist_ {
+typedef struct {
    int sz;          /* allocated size (private) */
    int len;
    void **list;
-};
-
-typedef struct Dlist_ Dlist;
+} Dlist;
 
 /* dCompareFunc:
  * Return: 0 if parameters are equal (for dList_find_custom).
--- a/dpi/ftp.c	Sat Jan 12 19:14:49 2013 +0100
+++ b/dpi/ftp.c	Sat Jan 12 20:13:36 2013 +0000
@@ -62,7 +62,7 @@
 /*---------------------------------------------------------------------------*/
 
 /* TODO: could use dStr ADT! */
-typedef struct ContentType_ {
+typedef struct {
    const char *str;
    int len;
 } ContentType_t;
--- a/dpip/dpip.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/dpip/dpip.h	Sat Jan 12 20:13:36 2013 +0000
@@ -28,8 +28,7 @@
 /*
  * Dpip socket handler type.
  */
-typedef struct _DpipSocketHandler Dsh;
-struct _DpipSocketHandler {
+typedef struct {
    int fd_in;
    int fd_out;
    /* FILE *in;    --Unused. The stream functions block when reading. */
@@ -41,7 +40,7 @@
 
    int mode;       /* mode flags: DPIP_TAG | DPIP_LAST_TAG | DPIP_RAW */
    int status;     /* status code: DPIP_EAGAIN | DPIP_ERROR | DPIP_EOF */
-};
+} Dsh;
 
 
 /*
--- a/src/bitvec.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/bitvec.h	Sat Jan 12 20:13:36 2013 +0000
@@ -6,12 +6,10 @@
 #define BVEC_TYPE uchar_t
 #define BVEC_SIZE sizeof(BVEC_TYPE)
 
-typedef struct _bitvec bitvec_t;
-
-struct _bitvec {
+typedef struct {
    BVEC_TYPE *vec;
    int len;       /* number of bits [1 based] */
-};
+} bitvec_t;
 
 
 /*
--- a/src/bw.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/bw.h	Sat Jan 12 20:13:36 2013 +0000
@@ -11,12 +11,8 @@
 #define BW_Force           (4)  /* Stop connection too */
 
 
-typedef struct _BrowserWindow BrowserWindow;
-
-
 /* browser_window contains the specific data for a single window */
-struct _BrowserWindow
-{
+typedef struct {
    /* Pointer to the UI object this bw belongs to */
    void *ui;
 
@@ -61,7 +57,7 @@
    /* HTML-bugs detected at parse time */
    int num_page_bugs;
    Dstr *page_bugs;
-};
+} BrowserWindow;
 
 
 #ifdef __cplusplus
--- a/src/cache.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/cache.h	Sat Jan 12 20:13:36 2013 +0000
@@ -34,16 +34,17 @@
 #define CA_HugeFile     0x1000  /* URL content is too big */
 #define CA_IsEmpty      0x2000  /* True until a byte of content arrives */
 
+typedef struct CacheClient CacheClient_t;
+
 /*
  * Callback type for cache clients
  */
-typedef struct _CacheClient CacheClient_t;
 typedef void (*CA_Callback_t)(int Op, CacheClient_t *Client);
 
 /*
  * Data structure for cache clients.
  */
-struct _CacheClient {
+struct CacheClient {
    int Key;                 /* Primary Key for this client */
    const DilloUrl *Url;     /* Pointer to a cache entry Url */
    int Version;             /* Dicache version of this Url (0 if not used) */
--- a/src/chain.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/chain.h	Sat Jan 12 20:13:36 2013 +0000
@@ -29,14 +29,12 @@
 #define FWD 1
 #define BCK 2
 
-
-typedef struct _ChainLink ChainLink;
-typedef struct _DataBuf DataBuf;
+typedef struct ChainLink ChainLink;
 typedef void (*ChainFunction_t)(int Op, int Branch, int Dir, ChainLink *Info,
                                 void *Data1, void *Data2);
 
 /* This is the main data structure for CCC nodes */
-struct _ChainLink {
+struct ChainLink {
    void *LocalKey;
 
    int Flags;
@@ -51,11 +49,11 @@
 };
 
 /* A convenience data structure for passing data chunks between nodes */
-struct _DataBuf {
+typedef struct {
    char *Buf;
    int Size;
    int Code;
-};
+} DataBuf;
 
 
 
--- a/src/decode.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/decode.h	Sat Jan 12 20:13:36 2013 +0000
@@ -7,15 +7,13 @@
 extern "C" {
 #endif /* __cplusplus */
 
-typedef struct _Decode    Decode;
-
-struct _Decode {
+typedef struct Decode {
    char *buffer;
    Dstr *leftover;
    void *state;
-   Dstr *(*decode) (Decode *dc, const char *instr, int inlen);
-   void (*free) (Decode *dc);
-};
+   Dstr *(*decode) (struct Decode *dc, const char *instr, int inlen);
+   void (*free) (struct Decode *dc);
+} Decode;
 
 Decode *a_Decode_transfer_init(const char *format);
 Decode *a_Decode_content_init(const char *format);
--- a/src/dicache.c	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/dicache.c	Sat Jan 12 20:13:36 2013 +0000
@@ -21,7 +21,6 @@
 #include "dgif.h"
 #include "djpeg.h"
 
-typedef struct _DICacheNode DICacheNode;
 
 enum {
    DIC_Gif,
@@ -29,11 +28,11 @@
    DIC_Jpeg
 };
 
-struct _DICacheNode {
+typedef struct {
    int valid;            /* flag */
    DilloUrl *url;        /* primary "Key" for this dicache entry */
    DICacheEntry *first;  /* pointer to the first dicache entry in this list */
-};
+} DICacheNode;
 
 /*
  * List of DICacheNode. One node per URL. Each node may have several
--- a/src/dicache.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/dicache.h	Sat Jan 12 20:13:36 2013 +0000
@@ -24,9 +24,7 @@
    DIC_Abort       /* Image transfer aborted */
 } DicEntryState;
 
-typedef struct _DICacheEntry DICacheEntry;
-
-struct _DICacheEntry {
+typedef struct DICacheEntry {
    DilloUrl *url;          /* Image URL for this entry */
    uint_t width, height;   /* As taken from image data */
    DilloImgType type;      /* Image type */
@@ -44,8 +42,8 @@
    void *DecoderData;      /* Client function data */
    uint_t DecodedSize;     /* Size of already decoded data */
 
-   DICacheEntry *next;     /* Link to the next "newer" version */
-};
+   struct DICacheEntry *next; /* Link to the next "newer" version */
+} DICacheEntry;
 
 
 void a_Dicache_init (void);
--- a/src/dns.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/dns.h	Sat Jan 12 20:13:36 2013 +0000
@@ -20,12 +20,12 @@
 #  define DILLO_ADDR_MAX sizeof(struct in_addr)
 #endif
 
-typedef struct _DilloHost
-{
+typedef struct {
   int af;
   int alen;
   char data[DILLO_ADDR_MAX];
 } DilloHost;
+
 void a_Dns_dillohost_to_string(DilloHost *host, char *dst, size_t size);
 
 #ifdef __cplusplus
--- a/src/domain.c	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/domain.c	Sat Jan 12 20:13:36 2013 +0000
@@ -14,7 +14,7 @@
 #include "list.h"
 #include "domain.h"
 
-typedef struct Rule {
+typedef struct {
    char *origin;
    char *destination;
 } Rule;
--- a/src/gif.c	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/gif.c	Sat Jan 12 20:13:36 2013 +0000
@@ -79,7 +79,7 @@
 #define        MAX_LWZ_BITS            12
 
 
-typedef struct _DilloGif {
+typedef struct {
    DilloImage *Image;
    DilloUrl *url;
    int version;
--- a/src/html_common.hh	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/html_common.hh	Sat Jan 12 20:13:36 2013 +0000
@@ -39,9 +39,6 @@
  * Typedefs
  */
 
-typedef struct _DilloHtmlImage   DilloHtmlImage;
-typedef struct _DilloHtmlState   DilloHtmlState;
-
 typedef enum {
    DT_NONE,
    DT_HTML,
@@ -94,12 +91,12 @@
  * Data Structures
  */
 
-struct _DilloHtmlImage {
+typedef struct {
    DilloUrl *url;
    DilloImage *image;
-};
+} DilloHtmlImage;
 
-struct _DilloHtmlState {
+typedef struct {
    DilloHtmlParseMode parse_mode;
    DilloHtmlTableMode table_mode;
    DilloHtmlTableBorderMode table_border_mode;
@@ -120,7 +117,7 @@
       have to be "handed over" (see Html_add_indented and
       Html_eventually_pop_dw). */
    bool hand_over_break;
-};
+} DilloHtmlState;
 
 /*
  * Classes
--- a/src/jpeg.c	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/jpeg.c	Sat Jan 12 20:13:36 2013 +0000
@@ -46,20 +46,22 @@
    DILLO_JPEG_ERROR
 } DilloJpegState;
 
+typedef struct DilloJpeg DilloJpeg;
+
 /* An implementation of a suspending source manager */
 
 typedef struct {
    struct jpeg_source_mgr pub;  /* public fields */
-   struct DilloJpeg *jpeg;      /* a pointer back to the jpeg object */
+   DilloJpeg *jpeg;             /* a pointer back to the jpeg object */
 } my_source_mgr;
 
 struct my_error_mgr {
    struct jpeg_error_mgr pub;    /* "public" fields */
    jmp_buf setjmp_buffer;        /* for return to caller */
 };
-typedef struct my_error_mgr * my_error_ptr;
+typedef struct my_error_mgr *my_error_ptr;
 
-typedef struct DilloJpeg {
+struct DilloJpeg {
    DilloImage *Image;
    DilloUrl *url;
    int version;
@@ -74,7 +76,7 @@
 
    struct jpeg_decompress_struct cinfo;
    struct my_error_mgr jerr;
-} DilloJpeg;
+};
 
 /*
  * Forward declarations
--- a/src/klist.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/klist.h	Sat Jan 12 20:13:36 2013 +0000
@@ -8,19 +8,16 @@
 extern "C" {
 #endif /* __cplusplus */
 
-typedef struct _KlistNode KlistNode_t;
-typedef struct _Klist Klist_t;
-
-struct _KlistNode {
+typedef struct {
    int Key;        /* primary key */
    void *Data;     /* data reference */
-};
+} KlistNode_t;
 
-struct _Klist {
+typedef struct {
    Dlist *List;
    int Clean;      /* check flag */
    int Counter;    /* counter (for making keys) */
-};
+} Klist_t;
 
 
 /*
--- a/src/misc.c	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/misc.c	Sat Jan 12 20:13:36 2013 +0000
@@ -97,7 +97,7 @@
 }
 
 /* TODO: could use dStr ADT! */
-typedef struct ContentType_ {
+typedef struct {
    const char *str;
    int len;
 } ContentType_t;
--- a/src/nav.c	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/nav.c	Sat Jan 12 20:13:36 2013 +0000
@@ -27,12 +27,10 @@
  * For back and forward navigation, each bw keeps an url index,
  * and its scroll position.
  */
-typedef struct _nav_stack_item nav_stack_item;
-struct _nav_stack_item
-{
+typedef struct {
    int url_idx;
    int posx, posy;
-};
+} nav_stack_item;
 
 
 
--- a/src/png.c	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/png.c	Sat Jan 12 20:13:36 2013 +0000
@@ -58,8 +58,7 @@
  * ones for XBM and PNM are.
  */
 
-typedef
-struct _DilloPng {
+typedef struct {
    DilloImage *Image;           /* Image meta data */
    DilloUrl *url;               /* Primary Key for the dicache */
    int version;                 /* Secondary Key for the dicache */
--- a/src/prefs.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/prefs.h	Sat Jan 12 20:13:36 2013 +0000
@@ -26,9 +26,7 @@
 /* Panel sizes */
 enum { P_tiny = 0, P_small, P_medium };
 
-typedef struct _DilloPrefs DilloPrefs;
-
-struct _DilloPrefs {
+typedef struct {
    int width;
    int height;
    int xpos;
@@ -99,7 +97,7 @@
    bool_t middle_click_drags_page;
    int penalty_hyphen, penalty_hyphen_2;
    int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2;
-};
+} DilloPrefs;
 
 /* Global Data */
 extern DilloPrefs prefs;
--- a/src/prefsparser.cc	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/prefsparser.cc	Sat Jan 12 20:13:36 2013 +0000
@@ -35,7 +35,7 @@
    PREFS_PANEL_SIZE
 } PrefType_t;
 
-typedef struct SymNode_ {
+typedef struct {
    const char *name;
    void *pref;
    PrefType_t type;
--- a/src/url.h	Sat Jan 12 19:14:49 2013 +0100
+++ b/src/url.h	Sat Jan 12 20:13:36 2013 +0000
@@ -84,13 +84,11 @@
 #define URL_ILLEGAL_CHARS_SPC(u)    URL_ILLEGAL_CHARS_SPC_(u)
 
 
-typedef struct _DilloUrl DilloUrl;
-
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-struct _DilloUrl {
+typedef struct {
    Dstr  *url_string;
    const char *buffer;
    const char *scheme;            /**/
@@ -106,7 +104,7 @@
    int ismap_url_len;             /* Used by server side image maps */
    int illegal_chars;             /* number of illegal chars */
    int illegal_chars_spc;         /* number of illegal space chars */
-};
+} DilloUrl;
 
 
 DilloUrl* a_Url_new(const char *url_str, const char *base_url);