]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
Various 'const' casting mods from Bruce Guenter <bruceg@qcc.sk.ca>
authorsopwith <sopwith>
Mon, 8 Sep 1997 20:00:11 +0000 (20:00 +0000)
committersopwith <sopwith>
Mon, 8 Sep 1997 20:00:11 +0000 (20:00 +0000)
button.c
checkbox.c
dialogboxes.c
entry.c
form.c
label.c
listbox.c
newt.c
newt.h

index 42f5c0f01a12d12b9f96623ca4ffc02e6daba171..ee3543dae4f1753d7c638d2d089df53352c2b2d2 100644 (file)
--- a/button.c
+++ b/button.c
@@ -25,7 +25,7 @@ static struct componentOps buttonOps = {
     buttonDestroy,
 } ;
 
-static newtComponent createButton(int left, int row, char * text, int compact) {
+static newtComponent createButton(int left, int row, const char * text, int compact) {
     newtComponent co;
     struct button * bu;
 
@@ -55,11 +55,11 @@ static newtComponent createButton(int left, int row, char * text, int compact) {
     return co;
 }
 
-newtComponent newtCompactButton(int left, int row, char * text) {
+newtComponent newtCompactButton(int left, int row, const char * text) {
     return createButton(left, row, text, 1);
 }
 
-newtComponent newtButton(int left, int row, char * text) {
+newtComponent newtButton(int left, int row, const char * text) {
     return createButton(left, row, text, 0);
 }
 
index 2f8329872cc66e9943fcdb34f693f0b70cf0ccfd..c4f24b5b4e1c441a742714c1e3bc50ae7fafbcfd 100644 (file)
@@ -15,7 +15,7 @@ struct checkbox {
     enum type type;
     char value;
     int active, inactive;
-    void * data;
+    const void * data;
     int flags;
 };
 
@@ -32,8 +32,8 @@ static struct componentOps cbOps = {
     cbDestroy,
 } ;
 
-newtComponent newtListitem(int left, int top, char * text, int isDefault,
-                             newtComponent prevItem, void * data, int flags) {
+newtComponent newtListitem(int left, int top, const char * text, int isDefault,
+                             newtComponent prevItem, const void * data, int flags) {
     newtComponent co;
     struct checkbox * li;
 
@@ -51,10 +51,10 @@ newtComponent newtListitem(int left, int top, char * text, int isDefault,
 void * newtListitemGetData(newtComponent co) {
     struct checkbox * rb = co->data;
 
-    return rb->data;
+    return (void *)rb->data;
 }
 
-void newtListitemSet(newtComponent co, char * text) {
+void newtListitemSet(newtComponent co, const char * text) {
     struct checkbox * li = co->data;
 
     free(li->text);
@@ -64,7 +64,7 @@ void newtListitemSet(newtComponent co, char * text) {
        co->width = strlen(text) + 4;
 }
 
-newtComponent newtRadiobutton(int left, int top, char * text, int isDefault,
+newtComponent newtRadiobutton(int left, int top, const char * text, int isDefault,
                              newtComponent prevButton) {
     newtComponent co;
     newtComponent curr;
@@ -104,8 +104,8 @@ newtComponent newtRadioGetCurrent(newtComponent setMember) {
     return setMember;
 }
 
-newtComponent newtCheckbox(int left, int top, char * text, char defValue,
-                          char * seq, char * result) {
+newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
+                          const char * seq, char * result) {
     newtComponent co;
     struct checkbox * cb;
 
@@ -191,7 +191,7 @@ static void cbDestroy(newtComponent co) {
 struct eventResult cbEvent(newtComponent co, struct event ev) {
     struct checkbox * cb = co->data;
     struct eventResult er;
-    char * cur;
+    const char * cur;
 
     if (ev.when == EV_NORMAL) {
        switch (ev.event) {
index a2407765434237466429d055eabfa57522377317..1fadb71c07f8402e152c62c589364837a0898e59 100644 (file)
@@ -12,7 +12,7 @@
 
 /* globals -- ick */
 int buttonHeight = 1;
-newtComponent (*makeButton)(int left, int right, char * text) = 
+newtComponent (*makeButton)(int left, int right, const char * text) = 
                newtCompactButton;
 
 static void addButtons(int height, int width, newtComponent form, 
diff --git a/entry.c b/entry.c
index 4549f5941acaa65ee42ec4ce3b71ee742febf0e3..005f9a549c895c18fd46417de4614ab0b40a9d76 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -29,7 +29,7 @@ static struct componentOps entryOps = {
     entryDestroy,
 } ;
 
-void newtEntrySet(newtComponent co, char * value, int cursorAtEnd) {
+void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd) {
     struct entry * en = co->data;
 
     if ((strlen(value) + 1) > (unsigned int)en->bufAlloced) {
@@ -50,7 +50,7 @@ void newtEntrySet(newtComponent co, char * value, int cursorAtEnd) {
     entryDraw(co);
 } ;
 
-newtComponent newtEntry(int left, int top, char * initialValue, int width,
+newtComponent newtEntry(int left, int top, const char * initialValue, int width,
                        char ** resultPtr, int flags) {
     newtComponent co;
     struct entry * en;
diff --git a/form.c b/form.c
index 06b1ca2da21cca61328ce6fb195b62fad2f57789..d661a0068b1dc9c65de7cda13005e958bda41da8 100644 (file)
--- a/form.c
+++ b/form.c
@@ -28,7 +28,7 @@ struct form {
     int flags;
     int vertOffset;
     newtComponent vertBar, exitComp;
-    char * help;
+    const char * help;
     int numRows;
     int * hotKeys;
     int numHotKeys;
@@ -56,7 +56,7 @@ static inline int componentFits(newtComponent co, int compNum) {
     return 1;
 }
 
-newtComponent newtForm(newtComponent vertBar, char * help, int flags) {
+newtComponent newtForm(newtComponent vertBar, const char * help, int flags) {
     newtComponent co;
     struct form * form;
 
diff --git a/label.c b/label.c
index d882b1d711356766335725de0333501242abe151..2cc4348938cb318f083c7f955daffeec2915dc06 100644 (file)
--- a/label.c
+++ b/label.c
@@ -19,7 +19,7 @@ static struct componentOps labelOps = {
     labelDestroy,
 } ;
 
-newtComponent newtLabel(int left, int top, char * text) {
+newtComponent newtLabel(int left, int top, const char * text) {
     newtComponent co;
     struct label * la;
 
@@ -41,7 +41,7 @@ newtComponent newtLabel(int left, int top, char * text) {
     return co;
 }
 
-void newtLabelSetText(newtComponent co, char * text) {
+void newtLabelSetText(newtComponent co, const char * text) {
     int newLength;
     struct label * la = co->data;
 
index 32d288fb8162b016c37d34a72ec04f28a6344ed5..1ba443fae97a061e1f9efa84613f80d68a7cda47 100644 (file)
--- a/listbox.c
+++ b/listbox.c
@@ -14,7 +14,8 @@
 
 /* Linked list of items in the listbox */
 struct items {
-    void *key, *data;
+    void *key;
+    const void *data;
     unsigned char isSelected;
     struct items *next;
 };
@@ -141,7 +142,7 @@ void * newtListboxGetCurrent(newtComponent co) {
        i++, item = item->next);
 
     if (item)
-       return item->data;
+       return (void *)item->data;
     else
        return NULL;
 }
@@ -202,12 +203,12 @@ void ** newtListboxGetSelection(newtComponent co, int *numitems)
     for(i = 0, item = li->boxItems; item != NULL;
        item = item->next)
        if(item->isSelected)
-           retval[i++] = item->data;
+           retval[i++] = (void *)item->data;
     *numitems = li->numSelected;
     return retval;
 }
 
-void newtListboxSetText(newtComponent co, int num, char * text) {
+void newtListboxSetText(newtComponent co, int num, const char * text) {
     struct listbox * li = co->data;
     int i;
     struct items *item;
@@ -232,7 +233,7 @@ void newtListboxSetText(newtComponent co, int num, char * text) {
        listboxDraw(co);
 }
 
-void newtListboxSetEntry(newtComponent co, int num, char * text) {
+void newtListboxSetEntry(newtComponent co, int num, const char * text) {
     newtListboxSetText(co, num, text);
 }
 
@@ -247,7 +248,8 @@ void newtListboxSetData(newtComponent co, int num, void * data) {
     item->data = data;
 }
 
-int newtListboxAddEntry(newtComponent co, char * text, void * data) {
+int newtListboxAddEntry(newtComponent co, const char * text,
+       const void * data) {
     struct listbox * li = co->data;
     struct items *item;
 
@@ -279,8 +281,8 @@ int newtListboxAddEntry(newtComponent co, char * text, void * data) {
 }
 
 
-int newtListboxInsertEntry(newtComponent co, char * text, void * data, 
-                          int num) {
+int newtListboxInsertEntry(newtComponent co, const char * text,
+       const void * data, int num) {
     struct listbox * li = co->data;
     struct items *item, *t;
     int i;
@@ -414,7 +416,7 @@ void newtListboxGetEntry(newtComponent co, int num, char **text, void **data) {
        if (text)
            *text = item->key;
        if (data)
-           *data = item->data; 
+           *data = (void *)item->data; 
     }
 }
 
diff --git a/newt.c b/newt.c
index de28b4629d60427aadda04e78c78aec1b6f083d9..cb5a3b6a05d2adc777bcef647c1e45a5a3920415 100644 (file)
--- a/newt.c
+++ b/newt.c
@@ -31,7 +31,7 @@ static char ** currentHelpline = NULL;
 
 static int cursorRow, cursorCol;
 
-static char * defaultHelpLine = 
+static const char * defaultHelpLine = 
 "  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen"
 ;
 
@@ -105,7 +105,7 @@ static struct keymap keymap[] = {
 };
 static char keyPrefix = '\033';
 
-static char * version = "Newt windowing library version " VERSION
+static const char * version = "Newt windowing library version " VERSION
                        " - (C) 1996 Red Hat Software. "
                        "Redistributable under the term of the Library "
                        "GNU Public License. "
@@ -310,7 +310,7 @@ void newtClearKeyBuffer(void) {
 }
 
 int newtOpenWindow(int left, int top, int width, int height, 
-                         char * title) {
+                         const char * title) {
     int j, row, col;
     int n;
     int i;
@@ -353,7 +353,7 @@ int newtOpenWindow(int left, int top, int width, int height,
        SLsmg_set_char_set(0);
        SLsmg_write_char(' ');
        SLsmg_set_color(NEWT_COLORSET_TITLE);
-       SLsmg_write_string(currentWindow->title);
+       SLsmg_write_string((char *)currentWindow->title);
        SLsmg_set_color(NEWT_COLORSET_BORDER);
        SLsmg_write_char(' ');
        SLsmg_set_char_set(1);
@@ -501,7 +501,7 @@ void newtRedrawHelpLine(void) {
     SLsmg_write_string(buf);
 }
 
-void newtPushHelpLine(char * text) {
+void newtPushHelpLine(const char * text) {
     if (!text)
        text = defaultHelpLine;
     
@@ -527,7 +527,7 @@ void newtPopHelpLine(void) {
     newtRedrawHelpLine();
 }
 
-void newtDrawRootText(int row, int col, char * text) {
+void newtDrawRootText(int row, int col, const char * text) {
     SLsmg_set_color(NEWT_COLORSET_ROOTTEXT);
 
     if (col < 0) {
@@ -539,7 +539,7 @@ void newtDrawRootText(int row, int col, char * text) {
     }
    
     SLsmg_gotorc(row, col);
-    SLsmg_write_string(text);
+    SLsmg_write_string((char *)text);
 }
 
 int newtSetFlags(int oldFlags, int newFlags, enum newtFlagsSense sense) {
diff --git a/newt.h b/newt.h
index 7e56cc21b10cdda5be04b23cc55398aed16949e3..efc3cb95816277a79e7e10a9d9b301bd46ffded2 100644 (file)
--- a/newt.h
+++ b/newt.h
@@ -93,35 +93,35 @@ void newtClearKeyBuffer(void);
 void newtDelay(int usecs);
 /* top, left are *not* counting the border */
 int newtOpenWindow(int left, int top, int width, int height, 
-                         char * title);
+                         const char * title);
 void newtPopWindow(void);
 void newtSetColors(struct newtColors colors);
 void newtRefresh(void);
 void newtSuspend(void);
 void newtSetSuspendCallback(newtSuspendCallback cb);
 void newtResume(void);
-void newtPushHelpLine(char * text);
+void newtPushHelpLine(const char * text);
 void newtRedrawHelpLine(void);
 void newtPopHelpLine(void);
-void newtDrawRootText(int row, int col, char * text);
+void newtDrawRootText(int row, int col, const char * text);
 void newtBell(void);
 
 /* Components */
 
-newtComponent newtCompactButton(int left, int top, char * text);
-newtComponent newtButton(int left, int top, char * text);
-newtComponent newtCheckbox(int left, int top, char * text, char defValue,
-                          char * seq, char * result);
-newtComponent newtRadiobutton(int left, int top, char * text, int isDefault,
+newtComponent newtCompactButton(int left, int top, const char * text);
+newtComponent newtButton(int left, int top, const char * text);
+newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
+                          const char * seq, char * result);
+newtComponent newtRadiobutton(int left, int top, const char * text, int isDefault,
                              newtComponent prevButton);
 newtComponent newtRadioGetCurrent(newtComponent setMember);
-newtComponent newtListitem(int left, int top, char * text, int isDefault,
-                             newtComponent prevItem, void * data, int flags);
-void newtListitemSet(newtComponent co, char * text);
+newtComponent newtListitem(int left, int top, const char * text, int isDefault,
+                             newtComponent prevItem, const void * data, int flags);
+void newtListitemSet(newtComponent co, const char * text);
 void * newtListitemGetData(newtComponent co);
 
-newtComponent newtLabel(int left, int top, char * text);
-void newtLabelSetText(newtComponent co, char * text);
+newtComponent newtLabel(int left, int top, const char * text);
+void newtLabelSetText(newtComponent co, const char * text);
 newtComponent newtVerticalScrollbar(int left, int top, int height,
                                    int normalColorset, int thumbColorset);
 void newtScrollbarSet(newtComponent co, int where, int total);
@@ -129,13 +129,13 @@ void newtScrollbarSet(newtComponent co, int where, int total);
 newtComponent newtListbox(int left, int top, int height, int flags);
 void * newtListboxGetCurrent(newtComponent co);
 void newtListboxSetCurrent(newtComponent co, int num);
-void newtListboxSetText(newtComponent co, int num, char * text);
-void newtListboxSetEntry(newtComponent co, int num, char * text);
+void newtListboxSetText(newtComponent co, int num, const char * text);
+void newtListboxSetEntry(newtComponent co, int num, const char * text);
 void newtListboxSetWidth(newtComponent co, int width);
 /* return the data passed to AddEntry */
 void newtListboxSetData(newtComponent co, int num, void * data);
-int newtListboxAddEntry(newtComponent co, char * text, void * data);
-int newtListboxInsertEntry(newtComponent co, char * text, void * data, int num);
+int newtListboxAddEntry(newtComponent co, const char * text, const void * data);
+int newtListboxInsertEntry(newtComponent co, const char * text, const void * data, int num);
 int newtListboxDeleteEntry(newtComponent co, int num);
 void newtListboxClear(newtComponent co); /* removes all entries from listbox */
 void newtListboxGetEntry(newtComponent co, int num, char **text, void **data);
@@ -159,7 +159,7 @@ struct newtExitStruct {
     } u;
 } ;
 
-newtComponent newtForm(newtComponent vertBar, char * help, int flags);
+newtComponent newtForm(newtComponent vertBar, const char * help, int flags);
 newtComponent newtFormGetCurrent(newtComponent co);
 void newtFormSetBackground(newtComponent co, int color);
 void newtFormSetCurrent(newtComponent co, newtComponent subco);
@@ -172,9 +172,9 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es);
 void newtDrawForm(newtComponent form);
 void newtFormAddHotKey(newtComponent co, int key);
 
-newtComponent newtEntry(int left, int top, char * initialValue, int width,
+newtComponent newtEntry(int left, int top, const char * initialValue, int width,
                        char ** resultPtr, int flags);
-void newtEntrySet(newtComponent co, char * value, int cursorAtEnd);
+void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd);
 void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
 
 newtComponent newtScale(int left, int top, int width, long long fullValue);