From 3261805fee19e346b4d1f84b23816daa1628764a Mon Sep 17 00:00:00 2001 From: lecoanet Date: Wed, 16 Apr 2003 09:49:22 +0000 Subject: Update from the Windows port and general cleanup/restructure --- generic/MapInfo.c | 1245 +++++++++++++++++++++++++++-------------------------- 1 file changed, 631 insertions(+), 614 deletions(-) (limited to 'generic/MapInfo.c') diff --git a/generic/MapInfo.c b/generic/MapInfo.c index ddbbc16..f050898 100644 --- a/generic/MapInfo.c +++ b/generic/MapInfo.c @@ -29,7 +29,12 @@ #include #include +#ifndef _WIN32 #include +#include +#else +#include +#endif #include "MapInfo.h" #include "tkZinc.h" @@ -37,7 +42,6 @@ #include #include -#include static const char rcsid[] = "$Id$"; @@ -53,37 +57,37 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " */ typedef struct { ZnPtr tag; - MapInfoLineStyle style; + ZnMapInfoLineStyle style; int width; - MapInfoPointStruct center; + ZnMapInfoPointStruct center; unsigned int radius; int start_angle; int extend; -} MapInfoArcStruct, *MapInfoArc; +} ZnMapInfoArcStruct, *ZnMapInfoArc; typedef struct { ZnPtr tag; - MapInfoLineStyle style; + ZnMapInfoLineStyle style; int width; - MapInfoPointStruct from; - MapInfoPointStruct to; + ZnMapInfoPointStruct from; + ZnMapInfoPointStruct to; unsigned int num_marks; - MapInfoPoint marks; -} MapInfoLineStruct, *MapInfoLine; + ZnMapInfoPoint marks; +} ZnMapInfoLineStruct, *ZnMapInfoLine; typedef struct { ZnPtr tag; - MapInfoPointStruct at; + ZnMapInfoPointStruct at; char symbol[2]; -} MapInfoSymbolStruct, *MapInfoSymbol; +} ZnMapInfoSymbolStruct, *ZnMapInfoSymbol; typedef struct { ZnPtr tag; - MapInfoTextStyle text_style; - MapInfoLineStyle line_style; - MapInfoPointStruct at; + ZnMapInfoTextStyle text_style; + ZnMapInfoLineStyle line_style; + ZnMapInfoPointStruct at; char *text; -} MapInfoTextStruct, *MapInfoText; +} ZnMapInfoTextStruct, *ZnMapInfoText; typedef struct { char *name; @@ -91,7 +95,7 @@ typedef struct { ZnList symbols; ZnList texts; ZnList arcs; -} MapInfoStruct, *MapInfo; +} ZnMapInfoStruct, *ZnMapInfo; #define MARKERS_SPACING 80.0 /* 10 nautic miles in 1/8 of a mile */ @@ -106,7 +110,7 @@ typedef struct { *----------------------------------------------------------------------- */ #define NOT_MARKED_STYLE(style) \ -((style) == MapInfoLineMarked ? MapInfoLineSimple : (style)); +((style) == ZnMapInfoLineMarked ? ZnMapInfoLineSimple : (style)); /* @@ -119,7 +123,7 @@ typedef struct { */ static void -ComputeLineMarks(MapInfoLine marked_line) +ComputeLineMarks(ZnMapInfoLine marked_line) { double length; unsigned int j; @@ -134,7 +138,7 @@ ComputeLineMarks(MapInfoLine marked_line) length = sqrt((double)((delta_x) * (delta_x) + (delta_y) * (delta_y))); step_x = (int) ((x_to - x_from) * MARKERS_SPACING / length); step_y = (int) ((y_to - y_from) * MARKERS_SPACING / length); - marked_line->num_marks = (int) length / MARKERS_SPACING; + marked_line->num_marks = (int) (length / MARKERS_SPACING); /* We don't want markers at ends, so we get rid of the last one if it is at an end */ @@ -143,7 +147,7 @@ ComputeLineMarks(MapInfoLine marked_line) } if (marked_line->num_marks) { - marked_line->marks = (MapInfoPoint) ZnMalloc(marked_line->num_marks * sizeof(MapInfoPointStruct)); + marked_line->marks = (ZnMapInfoPoint) ZnMalloc(marked_line->num_marks * sizeof(ZnMapInfoPointStruct)); } for (j = 0; j < marked_line->num_marks; j++) { @@ -153,62 +157,62 @@ ComputeLineMarks(MapInfoLine marked_line) } -static MapInfoId -MapInfoCreate(char *name) +static ZnMapInfoId +ZnMapInfoCreate(char *name) { - MapInfo new_map; + ZnMapInfo new_map; - new_map = (MapInfo) ZnMalloc(sizeof(MapInfoStruct)); - memset((char *) new_map, 0, sizeof(MapInfoStruct)); + new_map = (ZnMapInfo) ZnMalloc(sizeof(ZnMapInfoStruct)); + memset((char *) new_map, 0, sizeof(ZnMapInfoStruct)); if (!name) { name = ""; } new_map->name = (char *) ZnMalloc(strlen(name)+1); strcpy(new_map->name, name); - return((MapInfoId) new_map); + return((ZnMapInfoId) new_map); } static char * -MapInfoName(MapInfoId map_info) +ZnMapInfoName(ZnMapInfoId map_info) { if (!map_info) { return ""; } - return ((MapInfo) map_info)->name; + return ((ZnMapInfo) map_info)->name; } -static MapInfoId -MapInfoDuplicate(MapInfoId map_info) +static ZnMapInfoId +ZnMapInfoDuplicate(ZnMapInfoId map_info) { - MapInfo cur_map = (MapInfo) map_info; - MapInfo new_map; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfo new_map; int i, num_lines, num_texts; - MapInfoText new_texts, cur_texts; - MapInfoLine new_lines, cur_lines; + ZnMapInfoText new_texts, cur_texts; + ZnMapInfoLine new_lines, cur_lines; if (!cur_map) { - return ((MapInfoId) NULL); + return ((ZnMapInfoId) NULL); } - new_map = (MapInfo) MapInfoCreate(cur_map->name); + new_map = (ZnMapInfo) ZnMapInfoCreate(cur_map->name); if (cur_map->lines) { new_map->lines = ZnListDuplicate(cur_map->lines); - cur_lines = (MapInfoLine) ZnListArray(cur_map->lines); - new_lines = (MapInfoLine) ZnListArray(new_map->lines); + cur_lines = (ZnMapInfoLine) ZnListArray(cur_map->lines); + new_lines = (ZnMapInfoLine) ZnListArray(new_map->lines); num_lines = ZnListSize(cur_map->lines); for (i = 0; i < num_lines; i++) { - if (new_lines[i].style == MapInfoLineMarked) { - new_lines[i].marks = (MapInfoPoint) ZnMalloc(new_lines[i].num_marks * - sizeof(MapInfoPointStruct)); + if (new_lines[i].style == ZnMapInfoLineMarked) { + new_lines[i].marks = (ZnMapInfoPoint) ZnMalloc(new_lines[i].num_marks * + sizeof(ZnMapInfoPointStruct)); memcpy((char *) new_lines[i].marks, (char *) cur_lines[i].marks, - new_lines[i].num_marks * sizeof(MapInfoPointStruct)); + new_lines[i].num_marks * sizeof(ZnMapInfoPointStruct)); } } } @@ -218,8 +222,8 @@ MapInfoDuplicate(MapInfoId map_info) if (cur_map->texts) { new_map->texts = ZnListDuplicate(cur_map->texts); - cur_texts = (MapInfoText) ZnListArray(cur_map->texts); - new_texts = (MapInfoText) ZnListArray(new_map->texts); + cur_texts = (ZnMapInfoText) ZnListArray(cur_map->texts); + new_texts = (ZnMapInfoText) ZnListArray(new_map->texts); num_texts = ZnListSize(cur_map->texts); for (i = 0; i < num_texts; i++) { @@ -231,22 +235,22 @@ MapInfoDuplicate(MapInfoId map_info) new_map->arcs = ZnListDuplicate(cur_map->arcs); } - return((MapInfoId) new_map); + return((ZnMapInfoId) new_map); } static void -MapInfoDelete(MapInfoId map_info) +ZnMapInfoDelete(ZnMapInfoId map_info) { - MapInfo cur_map = (MapInfo) map_info; + ZnMapInfo cur_map = (ZnMapInfo) map_info; int i, num_texts, num_lines; - MapInfoText cur_texts; - MapInfoLine cur_lines; + ZnMapInfoText cur_texts; + ZnMapInfoLine cur_lines; if (cur_map) { if (cur_map->texts) { num_texts = ZnListSize(cur_map->texts); - cur_texts = (MapInfoText) ZnListArray(cur_map->texts); + cur_texts = (ZnMapInfoText) ZnListArray(cur_map->texts); for (i = 0; i < num_texts; i++) { ZnFree((char *) cur_texts[i].text); @@ -257,10 +261,10 @@ MapInfoDelete(MapInfoId map_info) if (cur_map->lines) { num_lines = ZnListSize(cur_map->lines); - cur_lines = (MapInfoLine) ZnListArray(cur_map->lines); + cur_lines = (ZnMapInfoLine) ZnListArray(cur_map->lines); for (i = 0; i < num_lines; i++) { - if (cur_lines[i].style == MapInfoLineMarked) { + if (cur_lines[i].style == ZnMapInfoLineMarked) { ZnFree((char *) cur_lines[i].marks); } } @@ -282,9 +286,9 @@ MapInfoDelete(MapInfoId map_info) } static void -MapInfoEmpty(MapInfoId map_info) +ZnMapInfoEmpty(ZnMapInfoId map_info) { - MapInfo cur_map = (MapInfo) map_info; + ZnMapInfo cur_map = (ZnMapInfo) map_info; if (cur_map) { if (cur_map->texts) { @@ -304,22 +308,22 @@ MapInfoEmpty(MapInfoId map_info) static void -MapInfoAddLine(MapInfoId map_info, - unsigned int index, - ZnPtr tag, - MapInfoLineStyle line_style, - int line_width, - int x_from, - int y_from, - int x_to, - int y_to) +ZnMapInfoAddLine(ZnMapInfoId map_info, + unsigned int index, + ZnPtr tag, + ZnMapInfoLineStyle line_style, + int line_width, + int x_from, + int y_from, + int x_to, + int y_to) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoLineStruct line_struct; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoLineStruct line_struct; if (cur_map) { if (!cur_map->lines) { - cur_map->lines = ZnListNew(16, sizeof(MapInfoLineStruct)); + cur_map->lines = ZnListNew(16, sizeof(ZnMapInfoLineStruct)); } line_struct.style = line_style; @@ -335,7 +339,7 @@ MapInfoAddLine(MapInfoId map_info, line_struct.to.x = x_to; line_struct.to.y = y_to; - if (line_style == MapInfoLineMarked) { + if (line_style == ZnMapInfoLineMarked) { ComputeLineMarks(&line_struct); } @@ -345,23 +349,23 @@ MapInfoAddLine(MapInfoId map_info, static void -MapInfoReplaceLine(MapInfoId map_info, - unsigned int index, - ZnPtr tag, - MapInfoLineStyle line_style, - int line_width, - int x_from, - int y_from, - int x_to, - int y_to) +ZnMapInfoReplaceLine(ZnMapInfoId map_info, + unsigned int index, + ZnPtr tag, + ZnMapInfoLineStyle line_style, + int line_width, + int x_from, + int y_from, + int x_to, + int y_to) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoLine line_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoLine line_ptr; if (cur_map && cur_map->lines) { - line_ptr = (MapInfoLine) ZnListAt(cur_map->lines, index); + line_ptr = (ZnMapInfoLine) ZnListAt(cur_map->lines, index); if (line_ptr) { - if (line_ptr->style == MapInfoLineMarked) { + if (line_ptr->style == ZnMapInfoLineMarked) { ZnFree((char *) line_ptr->marks); } @@ -378,7 +382,7 @@ MapInfoReplaceLine(MapInfoId map_info, line_ptr->to.x = x_to; line_ptr->to.y = y_to; - if (line_ptr->style == MapInfoLineMarked) { + if (line_ptr->style == ZnMapInfoLineMarked) { ComputeLineMarks(line_ptr); } } @@ -387,16 +391,16 @@ MapInfoReplaceLine(MapInfoId map_info, static void -MapInfoRemoveLine(MapInfoId map_info, - unsigned int index) +ZnMapInfoRemoveLine(ZnMapInfoId map_info, + unsigned int index) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoLine line_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoLine line_ptr; if (cur_map && cur_map->lines) { - line_ptr = (MapInfoLine) ZnListAt(cur_map->lines, index); + line_ptr = (ZnMapInfoLine) ZnListAt(cur_map->lines, index); if (line_ptr) { - if (line_ptr->style == MapInfoLineMarked) { + if (line_ptr->style == ZnMapInfoLineMarked) { ZnFree((char *) line_ptr->marks); } @@ -407,21 +411,21 @@ MapInfoRemoveLine(MapInfoId map_info, void -MapInfoGetLine(MapInfoId map_info, - unsigned int index, - ZnPtr *tag, - MapInfoLineStyle *line_style, - int *line_width, - int *x_from, - int *y_from, - int *x_to, - int *y_to) +ZnMapInfoGetLine(ZnMapInfoId map_info, + unsigned int index, + ZnPtr *tag, + ZnMapInfoLineStyle *line_style, + int *line_width, + int *x_from, + int *y_from, + int *x_to, + int *y_to) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoLine line_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoLine line_ptr; if (cur_map && cur_map->lines) { - line_ptr = (MapInfoLine) ZnListAt(cur_map->lines, index); + line_ptr = (ZnMapInfoLine) ZnListAt(cur_map->lines, index); if (line_ptr) { if (tag) { *tag = line_ptr->tag; @@ -455,17 +459,17 @@ MapInfoGetLine(MapInfoId map_info, void -MapInfoGetMarks(MapInfoId map_info, - unsigned int index, - MapInfoPoint *marks, - unsigned int *num_marks) +ZnMapInfoGetMarks(ZnMapInfoId map_info, + unsigned int index, + ZnMapInfoPoint *marks, + unsigned int *num_marks) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoLine line_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoLine line_ptr; if (cur_map && cur_map->lines) { - line_ptr = (MapInfoLine) ZnListAt(cur_map->lines, index); - if (line_ptr && line_ptr->style == MapInfoLineMarked) { + line_ptr = (ZnMapInfoLine) ZnListAt(cur_map->lines, index); + if (line_ptr && line_ptr->style == ZnMapInfoLineMarked) { if (marks) { *marks = line_ptr->marks; } @@ -478,9 +482,9 @@ MapInfoGetMarks(MapInfoId map_info, unsigned int -MapInfoNumLines(MapInfoId map_info) +ZnMapInfoNumLines(ZnMapInfoId map_info) { - MapInfo cur_map = (MapInfo) map_info; + ZnMapInfo cur_map = (ZnMapInfo) map_info; if (cur_map && cur_map->lines) { return ZnListSize(cur_map->lines); @@ -492,19 +496,19 @@ MapInfoNumLines(MapInfoId map_info) static void -MapInfoAddSymbol(MapInfoId map_info, - unsigned int index, - ZnPtr tag, - int x, - int y, - char symbol) +ZnMapInfoAddSymbol(ZnMapInfoId map_info, + unsigned int index, + ZnPtr tag, + int x, + int y, + int symbol) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoSymbolStruct symbol_struct; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoSymbolStruct symbol_struct; if (cur_map) { if (!cur_map->symbols) { - cur_map->symbols = ZnListNew(16, sizeof(MapInfoSymbolStruct)); + cur_map->symbols = ZnListNew(16, sizeof(ZnMapInfoSymbolStruct)); } symbol_struct.tag = tag; @@ -519,15 +523,15 @@ MapInfoAddSymbol(MapInfoId map_info, static void -MapInfoReplaceSymbol(MapInfoId map_info, - unsigned int index, - ZnPtr tag, - int x, - int y, - char symbol) +ZnMapInfoReplaceSymbol(ZnMapInfoId map_info, + unsigned int index, + ZnPtr tag, + int x, + int y, + int symbol) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoSymbolStruct symbol_struct; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoSymbolStruct symbol_struct; if (cur_map && cur_map->symbols) { symbol_struct.tag = tag; @@ -542,10 +546,10 @@ MapInfoReplaceSymbol(MapInfoId map_info, static void -MapInfoRemoveSymbol(MapInfoId map_info, - unsigned int index) +ZnMapInfoRemoveSymbol(ZnMapInfoId map_info, + unsigned int index) { - MapInfo cur_map = (MapInfo) map_info; + ZnMapInfo cur_map = (ZnMapInfo) map_info; if (cur_map && cur_map->symbols) { ZnListDelete(cur_map->symbols, index); @@ -554,18 +558,18 @@ MapInfoRemoveSymbol(MapInfoId map_info, void -MapInfoGetSymbol(MapInfoId map_info, - unsigned int index, - ZnPtr *tag, - int *x, - int *y, - char *symbol) +ZnMapInfoGetSymbol(ZnMapInfoId map_info, + unsigned int index, + ZnPtr *tag, + int *x, + int *y, + char *symbol) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoSymbol symbol_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoSymbol symbol_ptr; if (cur_map && cur_map->symbols) { - symbol_ptr = (MapInfoSymbol) ZnListAt(cur_map->symbols, index); + symbol_ptr = (ZnMapInfoSymbol) ZnListAt(cur_map->symbols, index); if (symbol_ptr) { if (tag) { *tag = symbol_ptr->tag; @@ -585,9 +589,9 @@ MapInfoGetSymbol(MapInfoId map_info, unsigned int -MapInfoNumSymbols(MapInfoId map_info) +ZnMapInfoNumSymbols(ZnMapInfoId map_info) { - MapInfo cur_map = (MapInfo) map_info; + ZnMapInfo cur_map = (ZnMapInfo) map_info; if (cur_map && cur_map->symbols) { return ZnListSize(cur_map->symbols); @@ -599,21 +603,21 @@ MapInfoNumSymbols(MapInfoId map_info) static void -MapInfoAddText(MapInfoId map_info, - unsigned int index, - ZnPtr tag, - MapInfoTextStyle text_style, - MapInfoLineStyle line_style, - int x, - int y, - char *text) +ZnMapInfoAddText(ZnMapInfoId map_info, + unsigned int index, + ZnPtr tag, + ZnMapInfoTextStyle text_style, + ZnMapInfoLineStyle line_style, + int x, + int y, + char *text) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoTextStruct text_struct; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoTextStruct text_struct; if (cur_map) { if (!cur_map->texts) { - cur_map->texts = ZnListNew(16, sizeof(MapInfoTextStruct)); + cur_map->texts = ZnListNew(16, sizeof(ZnMapInfoTextStruct)); } text_struct.tag = tag; @@ -630,20 +634,20 @@ MapInfoAddText(MapInfoId map_info, static void -MapInfoReplaceText(MapInfoId map_info, - unsigned int index, - ZnPtr tag, - MapInfoTextStyle text_style, - MapInfoLineStyle line_style, - int x, - int y, - char *text) +ZnMapInfoReplaceText(ZnMapInfoId map_info, + unsigned int index, + ZnPtr tag, + ZnMapInfoTextStyle text_style, + ZnMapInfoLineStyle line_style, + int x, + int y, + char *text) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoText text_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoText text_ptr; if (cur_map && cur_map->texts) { - text_ptr = (MapInfoText) ZnListAt(cur_map->texts, index); + text_ptr = (ZnMapInfoText) ZnListAt(cur_map->texts, index); if (text_ptr) { ZnFree(text_ptr->text); @@ -660,14 +664,14 @@ MapInfoReplaceText(MapInfoId map_info, static void -MapInfoRemoveText(MapInfoId map_info, - unsigned int index) +ZnMapInfoRemoveText(ZnMapInfoId map_info, + unsigned int index) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoText text_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoText text_ptr; if (cur_map && cur_map->texts) { - text_ptr = (MapInfoText) ZnListAt(cur_map->texts, index); + text_ptr = (ZnMapInfoText) ZnListAt(cur_map->texts, index); if (text_ptr) { ZnFree(text_ptr->text); @@ -678,20 +682,20 @@ MapInfoRemoveText(MapInfoId map_info, void -MapInfoGetText(MapInfoId map_info, - unsigned int index, - ZnPtr *tag, - MapInfoTextStyle *text_style, - MapInfoLineStyle *line_style, - int *x, - int *y, - char **text) +ZnMapInfoGetText(ZnMapInfoId map_info, + unsigned int index, + ZnPtr *tag, + ZnMapInfoTextStyle *text_style, + ZnMapInfoLineStyle *line_style, + int *x, + int *y, + char **text) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoText text_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoText text_ptr; if (cur_map && cur_map->texts) { - text_ptr = (MapInfoText) ZnListAt(cur_map->texts, index); + text_ptr = (ZnMapInfoText) ZnListAt(cur_map->texts, index); if (text_ptr) { if (tag) { *tag = text_ptr->tag; @@ -717,9 +721,9 @@ MapInfoGetText(MapInfoId map_info, unsigned int -MapInfoNumTexts(MapInfoId map_info) +ZnMapInfoNumTexts(ZnMapInfoId map_info) { - MapInfo cur_map = (MapInfo) map_info; + ZnMapInfo cur_map = (ZnMapInfo) map_info; if (cur_map && cur_map->texts) { return ZnListSize(cur_map->texts); @@ -731,23 +735,23 @@ MapInfoNumTexts(MapInfoId map_info) static void -MapInfoAddArc(MapInfoId map_info, - unsigned int index, - ZnPtr tag, - MapInfoLineStyle line_style, - int line_width, - int center_x, - int center_y, - unsigned int radius, - int start_angle, - int extend) +ZnMapInfoAddArc(ZnMapInfoId map_info, + unsigned int index, + ZnPtr tag, + ZnMapInfoLineStyle line_style, + int line_width, + int center_x, + int center_y, + unsigned int radius, + int start_angle, + int extend) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoArcStruct arc_struct; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoArcStruct arc_struct; if (cur_map) { if (!cur_map->arcs) { - cur_map->arcs = ZnListNew(16, sizeof(MapInfoArcStruct)); + cur_map->arcs = ZnListNew(16, sizeof(ZnMapInfoArcStruct)); } arc_struct.style = NOT_MARKED_STYLE(line_style); @@ -770,22 +774,22 @@ MapInfoAddArc(MapInfoId map_info, static void -MapInfoReplaceArc(MapInfoId map_info, - unsigned int index, - ZnPtr tag, - MapInfoLineStyle line_style, - int line_width, - int center_x, - int center_y, - unsigned int radius, - int start_angle, - int extend) +ZnMapInfoReplaceArc(ZnMapInfoId map_info, + unsigned int index, + ZnPtr tag, + ZnMapInfoLineStyle line_style, + int line_width, + int center_x, + int center_y, + unsigned int radius, + int start_angle, + int extend) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoArc arc_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoArc arc_ptr; if (cur_map && cur_map->arcs) { - arc_ptr = (MapInfoArc) ZnListAt(cur_map->arcs, index); + arc_ptr = (ZnMapInfoArc) ZnListAt(cur_map->arcs, index); if (arc_ptr) { arc_ptr->style = NOT_MARKED_STYLE(line_style); if (line_width == 1) { @@ -806,14 +810,14 @@ MapInfoReplaceArc(MapInfoId map_info, static void -MapInfoRemoveArc(MapInfoId map_info, - unsigned int index) +ZnMapInfoRemoveArc(ZnMapInfoId map_info, + unsigned int index) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoArc arc_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoArc arc_ptr; if (cur_map && cur_map->arcs) { - arc_ptr = (MapInfoArc) ZnListAt(cur_map->arcs, index); + arc_ptr = (ZnMapInfoArc) ZnListAt(cur_map->arcs, index); if (arc_ptr) { ZnListDelete(cur_map->arcs, index); } @@ -822,22 +826,22 @@ MapInfoRemoveArc(MapInfoId map_info, void -MapInfoGetArc(MapInfoId map_info, - unsigned int index, - ZnPtr *tag, - MapInfoLineStyle *line_style, - int *line_width, - int *center_x, - int *center_y, - unsigned int *radius, - int *start_angle, - int *extend) +ZnMapInfoGetArc(ZnMapInfoId map_info, + unsigned int index, + ZnPtr *tag, + ZnMapInfoLineStyle *line_style, + int *line_width, + int *center_x, + int *center_y, + int *radius, + int *start_angle, + int *extend) { - MapInfo cur_map = (MapInfo) map_info; - MapInfoArc arc_ptr; + ZnMapInfo cur_map = (ZnMapInfo) map_info; + ZnMapInfoArc arc_ptr; if (cur_map && cur_map->arcs) { - arc_ptr = (MapInfoArc) ZnListAt(cur_map->arcs, index); + arc_ptr = (ZnMapInfoArc) ZnListAt(cur_map->arcs, index); if (arc_ptr) { if (tag) { *tag = arc_ptr->tag; @@ -873,9 +877,9 @@ MapInfoGetArc(MapInfoId map_info, } unsigned int -MapInfoNumArcs(MapInfoId map_info) +ZnMapInfoNumArcs(ZnMapInfoId map_info) { - MapInfo cur_map = (MapInfo) map_info; + ZnMapInfo cur_map = (ZnMapInfo) map_info; if (cur_map && cur_map->arcs) { return ZnListSize(cur_map->arcs); @@ -886,68 +890,68 @@ MapInfoNumArcs(MapInfoId map_info) } static void -MapInfoScale(MapInfoId map_info, - double factor) +ZnMapInfoScale(ZnMapInfoId map_info, + double factor) { - MapInfo mp = (MapInfo) map_info; - int i, num; - MapInfoLine line_ptr; - MapInfoSymbol sym_ptr; - MapInfoText text_ptr; - MapInfoArc arc_ptr; + ZnMapInfo mp = (ZnMapInfo) map_info; + int i, num, int_factor = (int) factor; + ZnMapInfoLine line_ptr; + ZnMapInfoSymbol sym_ptr; + ZnMapInfoText text_ptr; + ZnMapInfoArc arc_ptr; if (mp && mp->lines) { num = ZnListSize(mp->lines); - line_ptr = (MapInfoLine) ZnListArray(mp->lines); + line_ptr = (ZnMapInfoLine) ZnListArray(mp->lines); for (i = 0; i < num; i++, line_ptr++) { - line_ptr->from.x *= factor; - line_ptr->from.y *= factor; - line_ptr->to.x *= factor; - line_ptr->to.y *= factor; + line_ptr->from.x *= int_factor; + line_ptr->from.y *= int_factor; + line_ptr->to.x *= int_factor; + line_ptr->to.y *= int_factor; } } if (mp && mp->symbols) { num = ZnListSize(mp->symbols); - sym_ptr = (MapInfoSymbol) ZnListArray(mp->symbols); + sym_ptr = (ZnMapInfoSymbol) ZnListArray(mp->symbols); for (i = 0; i < num; i++, sym_ptr++) { - sym_ptr->at.x *= factor; - sym_ptr->at.y *= factor; + sym_ptr->at.x *= int_factor; + sym_ptr->at.y *= int_factor; } } if (mp && mp->texts) { num = ZnListSize(mp->texts); - text_ptr = (MapInfoText) ZnListArray(mp->texts); + text_ptr = (ZnMapInfoText) ZnListArray(mp->texts); for (i = 0; i < num; i++, text_ptr++) { - text_ptr->at.x *= factor; - text_ptr->at.y *= factor; + text_ptr->at.x *= int_factor; + text_ptr->at.y *= int_factor; } } if (mp && mp->arcs) { num = ZnListSize(mp->arcs); - arc_ptr = (MapInfoArc) ZnListArray(mp->arcs); + arc_ptr = (ZnMapInfoArc) ZnListArray(mp->arcs); for (i = 0; i < num; i++, arc_ptr++) { - arc_ptr->center.x *= factor; - arc_ptr->center.y *= factor; - arc_ptr->radius *= factor; + arc_ptr->center.x *= int_factor; + arc_ptr->center.y *= int_factor; + arc_ptr->radius *= int_factor; } } } static void -MapInfoTranslate(MapInfoId map_info, - int x, - int y) +ZnMapInfoTranslate(ZnMapInfoId map_info, + int x, + int y) { - MapInfo mp = (MapInfo) map_info; + ZnMapInfo mp = (ZnMapInfo) map_info; int i, num; - MapInfoLine line_ptr; - MapInfoSymbol sym_ptr; - MapInfoText text_ptr; - MapInfoArc arc_ptr; + ZnMapInfoLine line_ptr; + ZnMapInfoSymbol sym_ptr; + ZnMapInfoText text_ptr; + ZnMapInfoArc arc_ptr; if (mp && mp->lines) { num = ZnListSize(mp->lines); - line_ptr = (MapInfoLine) ZnListArray(mp->lines); + line_ptr = (ZnMapInfoLine) ZnListArray(mp->lines); for (i = 0; i < num; i++, line_ptr++) { line_ptr->from.x += x; line_ptr->from.y += y; @@ -957,7 +961,7 @@ MapInfoTranslate(MapInfoId map_info, } if (mp && mp->symbols) { num = ZnListSize(mp->symbols); - sym_ptr = (MapInfoSymbol) ZnListArray(mp->symbols); + sym_ptr = (ZnMapInfoSymbol) ZnListArray(mp->symbols); for (i = 0; i < num; i++, sym_ptr++) { sym_ptr->at.x += x; sym_ptr->at.y += y; @@ -965,7 +969,7 @@ MapInfoTranslate(MapInfoId map_info, } if (mp && mp->texts) { num = ZnListSize(mp->texts); - text_ptr = (MapInfoText) ZnListArray(mp->texts); + text_ptr = (ZnMapInfoText) ZnListArray(mp->texts); for (i = 0; i < num; i++, text_ptr++) { text_ptr->at.x += x; text_ptr->at.y += y; @@ -973,7 +977,7 @@ MapInfoTranslate(MapInfoId map_info, } if (mp && mp->arcs) { num = ZnListSize(mp->arcs); - arc_ptr = (MapInfoArc) ZnListArray(mp->arcs); + arc_ptr = (ZnMapInfoArc) ZnListArray(mp->arcs); for (i = 0; i < num; i++, arc_ptr++) { arc_ptr->center.x += x; arc_ptr->center.y += y; @@ -1021,19 +1025,19 @@ ReorderVidomap(VideoMap *vm) { int loop; - vm->id = ntohi(vm->id); - vm->dashed = ntohi(vm->dashed); - vm->expanded = ntohi(vm->expanded); - vm->marked = ntohi(vm->marked); - vm->color = ntohi(vm->color); + vm->id = ntohi((unsigned int) vm->id); + vm->dashed = ntohi((unsigned int) vm->dashed); + vm->expanded = ntohi((unsigned int) vm->expanded); + vm->marked = ntohi((unsigned int) vm->marked); + vm->color = ntohi((unsigned int) vm->color); for (loop = 0; loop < 50; loop++) { - vm->elements[loop] = ntohi(vm->elements[loop]); - vm->x[loop] = ntohi(vm->x[loop]); - vm->y[loop] = ntohi(vm->y[loop]); - vm->symbol[loop] = ntohi(vm->symbol[loop]); - vm->text[loop] = ntohi(vm->text[loop]); + vm->elements[loop] = ntohi((unsigned int) vm->elements[loop]); + vm->x[loop] = ntohi((unsigned int) vm->x[loop]); + vm->y[loop] = ntohi((unsigned int) vm->y[loop]); + vm->symbol[loop] = ntohi((unsigned int) vm->symbol[loop]); + vm->text[loop] = ntohi((unsigned int) vm->text[loop]); } - vm->num_elements = ntohi(vm->num_elements); + vm->num_elements = ntohi((unsigned int) vm->num_elements); } /* @@ -1045,9 +1049,9 @@ ReorderVidomap(VideoMap *vm) */ static void -FillMap(MapInfoId map, VideoMap *vm) +FillMap(ZnMapInfoId map, VideoMap *vm) { - unsigned int i; + int i; ZnBool has_start_pos = False; int x_cur=0, y_cur=0; char ch; @@ -1059,103 +1063,103 @@ FillMap(MapInfoId map, VideoMap *vm) for (i = 0; i < vm->num_elements; i++) { switch(vm->elements[i] & 0xFF) { - case 'p': - case 'P': - if (in_text) { - in_text = in_mod_text = False; - while (text[text_size - 1] == ' ') { - text_size--; - } - text[text_size] = (char) 0; - MapInfoAddText(map, MapInfoNumTexts(map), NULL, MapInfoNormalText, - MapInfoLineSimple, text_x, text_y, text); + case 'p': + case 'P': + if (in_text) { + in_text = in_mod_text = False; + while (text[text_size - 1] == ' ') { + text_size--; } + text[text_size] = (char) 0; + ZnMapInfoAddText(map, ZnMapInfoNumTexts(map), NULL, ZnMapInfoNormalText, + ZnMapInfoLineSimple, text_x, text_y, text); + } - x_cur = (int) (short) vm->x[i]; - y_cur = (int) (short) vm->y[i]; - has_start_pos = True; + x_cur = (int) (short) vm->x[i]; + y_cur = (int) (short) vm->y[i]; + has_start_pos = True; - if (vm->symbol[i]) { - MapInfoAddSymbol(map, MapInfoNumSymbols(map), NULL, x_cur, y_cur, vm->symbol[i]); - } - break; + if (vm->symbol[i]) { + ZnMapInfoAddSymbol(map, ZnMapInfoNumSymbols(map), NULL, x_cur, y_cur, (char) vm->symbol[i]); + } + break; - /* We gather consecutive 'T' elements in a text. We skip - leading and trailing spaces and mod texts (between '@' - and now obsolete) */ + /* We gather consecutive 'T' elements in a text. We skip + leading and trailing spaces and mod texts (between '@' + and now obsolete) */ - case 't': - case 'T': - if (!has_start_pos) { - ZnWarning("Bogus map block, it has been discarded\n"); - return; - } + case 't': + case 'T': + if (!has_start_pos) { + ZnWarning("Bogus map block, it has been discarded\n"); + return; + } - if (in_text == False) { - ch = (char) vm->text[i] & 0xFF; - if (ch == '@') { - if (in_mod_text == True) { - in_mod_text = False; - } - else { - in_mod_text = True; - } + if (in_text == False) { + ch = (char) vm->text[i] & 0xFF; + if (ch == '@') { + if (in_mod_text == True) { + in_mod_text = False; } - else if (in_mod_text == False) { - in_text = True; - text_size = 0; - text_x = x_cur; - text_y = y_cur; - text[0] = (char) 0; + else { + in_mod_text = True; } } - if (in_text) { - text[text_size] = (char) vm->text[i] & 0xFF; - text_size++; + else if (in_mod_text == False) { + in_text = True; + text_size = 0; + text_x = x_cur; + text_y = y_cur; + text[0] = (char) 0; } - break; + } + if (in_text) { + text[text_size] = (char) vm->text[i] & 0xFF; + text_size++; + } + break; - case 'v': - case 'V': - if (!has_start_pos) { - ZnWarning("Bogus map block, it has been discarded\n"); - return; - } + case 'v': + case 'V': + if (!has_start_pos) { + ZnWarning("Bogus map block, it has been discarded\n"); + return; + } - if (in_text) { - in_text = in_mod_text = False; - while (text[text_size - 1] == ' ') { - text_size--; - } - text[text_size] = (char) 0; - MapInfoAddText(map, MapInfoNumTexts(map), NULL, MapInfoNormalText, - MapInfoLineSimple, text_x, text_y, text); + if (in_text) { + in_text = in_mod_text = False; + while (text[text_size - 1] == ' ') { + text_size--; } + text[text_size] = (char) 0; + ZnMapInfoAddText(map, ZnMapInfoNumTexts(map), NULL, ZnMapInfoNormalText, + ZnMapInfoLineSimple, text_x, text_y, text); + } - if (vm->dashed) { - MapInfoAddLine(map, MapInfoNumLines(map), NULL, MapInfoLineDashed, 0, + if (vm->dashed) { + ZnMapInfoAddLine(map, ZnMapInfoNumLines(map), NULL, ZnMapInfoLineDashed, 0, x_cur, y_cur, (int) (short) vm->x[i], (int) (short) vm->y[i]); - } - else if (vm->marked) { - MapInfoAddLine(map, MapInfoNumLines(map), NULL, MapInfoLineMarked, 0, + } + else if (vm->marked) { + ZnMapInfoAddLine(map, ZnMapInfoNumLines(map), NULL, ZnMapInfoLineMarked, 0, x_cur, y_cur, (int) (short) vm->x[i], (int) (short) vm->y[i]); - } - else { - MapInfoAddLine(map, MapInfoNumLines(map), NULL, MapInfoLineSimple, 0, + } + else { + ZnMapInfoAddLine(map, ZnMapInfoNumLines(map), NULL, ZnMapInfoLineSimple, 0, x_cur, y_cur, (int) (short) vm->x[i], (int) (short) vm->y[i]); - } + } - x_cur = (int) (short) vm->x[i]; - y_cur = (int) (short) vm->y[i]; + x_cur = (int) (short) vm->x[i]; + y_cur = (int) (short) vm->y[i]; - if (vm->symbol[i]) { - MapInfoAddSymbol(map, MapInfoNumSymbols(map), NULL, x_cur, y_cur, vm->symbol[i]); - } - break; + if (vm->symbol[i]) { + ZnMapInfoAddSymbol(map, ZnMapInfoNumSymbols(map), NULL, x_cur, y_cur, (char) vm->symbol[i]); } + break; + } } if (in_text) { @@ -1164,15 +1168,15 @@ FillMap(MapInfoId map, VideoMap *vm) text_size--; } text[text_size] = (char) 0; - MapInfoAddText(map, MapInfoNumTexts(map), NULL, MapInfoNormalText, - MapInfoLineSimple, text_x, text_y, text); + ZnMapInfoAddText(map, ZnMapInfoNumTexts(map), NULL, ZnMapInfoNormalText, + ZnMapInfoLineSimple, text_x, text_y, text); } } /* *----------------------------------------------------------------------- * - * MapInfoGetVideomap - Load a mapinfo with the content of a videomap + * ZnMapInfoGetVideomap - Load a mapinfo with the content of a videomap * file named 'filename'. Only the sub map 'index' will be loaded. * If successful a new mapinfo is returned, NULL otherwise. The * index is zero based. @@ -1180,35 +1184,39 @@ FillMap(MapInfoId map, VideoMap *vm) *----------------------------------------------------------------------- */ static int -MapInfoGetVideomap(MapInfoId map, - char *filename, - int index) +ZnMapInfoGetVideomap(ZnMapInfoId map, + char *filename, + unsigned int index) { VideoMap current_vm; FILE *file; - int cur_index, cur_id; + unsigned int cur_index, cur_id; /* Open the specified map file. */ +#ifdef _WIN32 + file = fopen(filename, "rb"); +#else file = fopen(filename, "r"); +#endif if (file == NULL) { - return ZN_ERROR; + return TCL_ERROR; } /* Load the map */ /* First skip the leading maps up to index. */ cur_index = 0; - if (fread(¤t_vm, sizeof(VideoMap), 1, file) < 0) { + if (fread(¤t_vm, sizeof(VideoMap), 1, file) != 1) { goto error; } - cur_id = ntohi(current_vm.id); + cur_id = ntohi((unsigned int) current_vm.id); while (cur_index != index) { - if (fread(¤t_vm, sizeof(VideoMap), 1, file) < 0) { + if (fread(¤t_vm, sizeof(VideoMap), 1, file) != 1) { goto error; } - if (cur_id != ntohi(current_vm.id)) { + if (cur_id != ntohi((unsigned int) current_vm.id)) { cur_index++; - cur_id = ntohi(current_vm.id); + cur_id = ntohi((unsigned int) current_vm.id); } }; @@ -1220,20 +1228,20 @@ MapInfoGetVideomap(MapInfoId map, goto error; } } - while ((cur_id == ntohi(current_vm.id)) && !feof(file)); + while ((cur_id == ntohi((unsigned int) current_vm.id)) && !feof(file)); fclose(file); - return ZN_OK; + return TCL_OK; -error: + error: fclose(file); - return ZN_ERROR; + return TCL_ERROR; } /* *----------------------------------------------------------------------- * - * MapInfoVideomapIds - Return the list of sub map ids contained in a + * ZnMapInfoVideomapIds - Return the list of sub map ids contained in a * videomap file. This makes it possible to iterate through such * a file without stumbling on an error, to know how much maps * are there and to sort them according to their ids. @@ -1242,33 +1250,40 @@ error: */ static ZnList -MapInfoVideomapIds(char *filename) +ZnMapInfoVideomapIds(char *filename) { FILE *file; VideoMap current_vm; - int cur_id; + unsigned int cur_id; ZnList ids; /* Open the specified map file. */ +#ifdef _WIN32 + file = fopen(filename, "rb"); +#else file = fopen(filename, "r"); +#endif if (file == NULL) { return NULL; } - if (fread(¤t_vm, sizeof(VideoMap), 1, file) < 0) { - goto error; + if (fread(¤t_vm, sizeof(VideoMap), 1, file) != 1) { + error: + fclose(file); + return NULL; } - cur_id = ntohi(current_vm.id); + cur_id = ntohi((unsigned int) current_vm.id); ids = ZnListNew(16, sizeof(int)); /*printf("id %d\n", cur_id);*/ ZnListAdd(ids, &cur_id, ZnListTail); do { - if (fread(¤t_vm, sizeof(VideoMap), 1, file) < 0) { + if (fread(¤t_vm, sizeof(VideoMap), 1, file) != 1) { + ZnListFree(ids); goto error; } - if (cur_id != ntohi(current_vm.id)) { - cur_id = ntohi(current_vm.id); + if (cur_id != ntohi((unsigned int) current_vm.id)) { + cur_id = ntohi((unsigned int) current_vm.id); /*printf("id %d\n", cur_id);*/ ZnListAdd(ids, &cur_id, ZnListTail); } @@ -1277,18 +1292,13 @@ MapInfoVideomapIds(char *filename) fclose(file); return ids; - -error: - fclose(file); - ZnListFree(ids); - return NULL; } /* *-------------------------------------------------------------------------- * - * MapInfo and Videomapstuff that should go eventually in its own file. + * ZnMapInfo and Videomapstuff that should go eventually in its own file. * *-------------------------------------------------------------------------- */ @@ -1298,17 +1308,17 @@ static ZnBool map_info_inited = False; typedef struct { ClientData client_data; - MapInfoChangeProc proc; -} MapInfoClient; + ZnMapInfoChangeProc proc; +} ZnMapInfoClient; typedef struct { - MapInfoId map_info; + ZnMapInfoId map_info; ZnBool deleted; ZnList clients; -} MapInfoMaster; +} ZnMapInfoMaster; static void -MapInfoInit() +ZnMapInfoInit() { Tcl_InitHashTable(&mapInfoTable, TCL_ONE_WORD_KEYS); @@ -1316,30 +1326,30 @@ MapInfoInit() } static void -UpdateMapInfoClients(MapInfoMaster *master) +UpdateMapInfoClients(ZnMapInfoMaster *master) { - int i, num; - MapInfoClient *client; + int i, num; + ZnMapInfoClient *client; num = ZnListSize(master->clients); - client = (MapInfoClient *) ZnListArray(master->clients); + client = (ZnMapInfoClient *) ZnListArray(master->clients); for (i = 0; i < num; i++, client++) { (*client->proc)(client->client_data, master->map_info); } } static int -ZnCreateMapInfo(Tcl_Interp *interp, +ZnCreateMapInfo(Tcl_Interp *interp __unused, char *name, - MapInfoId *map_info) + ZnMapInfoId *map_info) { - Tk_Uid uid = Tk_GetUid(name); - Tcl_HashEntry *entry; - int new; - MapInfoMaster *master; + Tk_Uid uid = Tk_GetUid(name); + Tcl_HashEntry *entry; + int new; + ZnMapInfoMaster *master; if (!map_info_inited) { - MapInfoInit(); + ZnMapInfoInit(); } entry = Tcl_CreateHashEntry(&mapInfoTable, uid, &new); @@ -1347,20 +1357,20 @@ ZnCreateMapInfo(Tcl_Interp *interp, /* * Empty the map info if it is not. */ - master = (MapInfoMaster *) Tcl_GetHashValue(entry); + master = (ZnMapInfoMaster *) Tcl_GetHashValue(entry); if (master->deleted) { master->deleted = False; } else { - MapInfoEmpty(master->map_info); + ZnMapInfoEmpty(master->map_info); UpdateMapInfoClients(master); } } else { - master = (MapInfoMaster *) ZnMalloc(sizeof(MapInfoMaster)); - master->map_info = MapInfoCreate(name); + master = (ZnMapInfoMaster *) ZnMalloc(sizeof(ZnMapInfoMaster)); + master->map_info = ZnMapInfoCreate(name); master->deleted = False; - master->clients = ZnListNew(1, sizeof(MapInfoClient)); + master->clients = ZnListNew(1, sizeof(ZnMapInfoClient)); Tcl_SetHashValue(entry, master); } if (map_info) { @@ -1370,43 +1380,43 @@ ZnCreateMapInfo(Tcl_Interp *interp, } static int -ZnDuplicateMapInfo(Tcl_Interp *interp, - char *name, - MapInfoId map_info) +ZnDuplicateZnMapInfo(Tcl_Interp *interp, + char *name, + ZnMapInfoId map_info) { - Tk_Uid uid = Tk_GetUid(name); - Tcl_HashEntry *entry; - int new; - MapInfoMaster *master; + Tk_Uid uid = Tk_GetUid(name); + Tcl_HashEntry *entry; + int new; + ZnMapInfoMaster *master; if (!map_info_inited) { - MapInfoInit(); + ZnMapInfoInit(); } entry = Tcl_CreateHashEntry(&mapInfoTable, uid, &new); if (!new) { Tcl_AppendResult(interp, "duplicate mapinfo \"", name, "\" already exists", NULL); - return ZN_ERROR; + return TCL_ERROR; } - master = (MapInfoMaster *) ZnMalloc(sizeof(MapInfoMaster)); - master->map_info = MapInfoDuplicate(map_info); + master = (ZnMapInfoMaster *) ZnMalloc(sizeof(ZnMapInfoMaster)); + master->map_info = ZnMapInfoDuplicate(map_info); master->deleted = False; - master->clients = ZnListNew(1, sizeof(MapInfoClient)); + master->clients = ZnListNew(1, sizeof(ZnMapInfoClient)); Tcl_SetHashValue(entry, master); return TCL_OK; } -static MapInfoMaster * +static ZnMapInfoMaster * LookupMapInfoMaster(Tcl_Interp *interp, char *name) { - Tk_Uid uid = Tk_GetUid(name); - Tcl_HashEntry *entry; - MapInfoMaster *master; + Tk_Uid uid = Tk_GetUid(name); + Tcl_HashEntry *entry; + ZnMapInfoMaster *master; if (!map_info_inited) { - MapInfoInit(); + ZnMapInfoInit(); } entry = Tcl_FindHashEntry(&mapInfoTable, uid); @@ -1415,7 +1425,7 @@ LookupMapInfoMaster(Tcl_Interp *interp, Tcl_AppendResult(interp, "mapinfo \"", name, "\" doesn't exist", NULL); return NULL; } - master = (MapInfoMaster *) Tcl_GetHashValue(entry); + master = (ZnMapInfoMaster *) Tcl_GetHashValue(entry); if (master->deleted) { goto mp_error; } @@ -1423,30 +1433,30 @@ LookupMapInfoMaster(Tcl_Interp *interp, } static int -ZnDeleteMapInfo(Tcl_Interp *interp, +ZnDeleteMapInfo(Tcl_Interp *interp __unused, char *name) { - MapInfoMaster *master; - Tk_Uid uid = Tk_GetUid(name); - Tcl_HashEntry *entry; + ZnMapInfoMaster *master; + Tk_Uid uid = Tk_GetUid(name); + Tcl_HashEntry *entry; if (!map_info_inited) { - MapInfoInit(); + ZnMapInfoInit(); } entry = Tcl_FindHashEntry(&mapInfoTable, uid); if (entry == NULL) { - return ZN_ERROR; + return TCL_ERROR; } - master = (MapInfoMaster *) Tcl_GetHashValue(entry); + master = (ZnMapInfoMaster *) Tcl_GetHashValue(entry); if (ZnListSize(master->clients) != 0) { master->deleted = True; - MapInfoEmpty(master->map_info); + ZnMapInfoEmpty(master->map_info); UpdateMapInfoClients(master); } else { - MapInfoDelete(master->map_info); + ZnMapInfoDelete(master->map_info); ZnListFree(master->clients); Tcl_DeleteHashEntry(entry); ZnFree(master); @@ -1455,14 +1465,14 @@ ZnDeleteMapInfo(Tcl_Interp *interp, return TCL_OK; } -MapInfoId +ZnMapInfoId ZnGetMapInfo(Tcl_Interp *interp, char *name, - MapInfoChangeProc proc, + ZnMapInfoChangeProc proc, ClientData client_data) { - MapInfoMaster *master; - MapInfoClient client; + ZnMapInfoMaster *master; + ZnMapInfoClient client; master = LookupMapInfoMaster(interp, name); if (master == NULL) { @@ -1476,26 +1486,26 @@ ZnGetMapInfo(Tcl_Interp *interp, } void -ZnFreeMapInfo(MapInfoId map_info, - MapInfoChangeProc proc, +ZnFreeMapInfo(ZnMapInfoId map_info, + ZnMapInfoChangeProc proc, ClientData client_data) { - Tk_Uid uid = Tk_GetUid(MapInfoName(map_info)); + Tk_Uid uid = Tk_GetUid(ZnMapInfoName(map_info)); Tcl_HashEntry *entry; - MapInfoMaster *master; - MapInfoClient *client; - int num, i; + ZnMapInfoMaster *master; + ZnMapInfoClient *client; + unsigned int num, i; if (!map_info_inited) { - MapInfoInit(); + ZnMapInfoInit(); } entry = Tcl_FindHashEntry(&mapInfoTable, uid); if (entry == NULL) { return; } - master = (MapInfoMaster *) Tcl_GetHashValue(entry); - client = (MapInfoClient *) ZnListArray(master->clients); + master = (ZnMapInfoMaster *) Tcl_GetHashValue(entry); + client = (ZnMapInfoClient *) ZnListArray(master->clients); num = ZnListSize(master->clients); for (i = 0; i < num; i++, client++) { if ((client->client_data == client_data) && @@ -1507,28 +1517,28 @@ ZnFreeMapInfo(MapInfoId map_info, } static void -ZnUpdateMapInfoClients(MapInfoId map_info) +ZnUpdateMapInfoClients(ZnMapInfoId map_info) { - Tk_Uid uid = Tk_GetUid(MapInfoName(map_info)); - Tcl_HashEntry *entry; - MapInfoMaster *master; + Tk_Uid uid = Tk_GetUid(ZnMapInfoName(map_info)); + Tcl_HashEntry *entry; + ZnMapInfoMaster *master; if (!map_info_inited) { - MapInfoInit(); + ZnMapInfoInit(); } entry = Tcl_FindHashEntry(&mapInfoTable, uid); if (entry == NULL) { return; } - master = (MapInfoMaster *) Tcl_GetHashValue(entry); + master = (ZnMapInfoMaster *) Tcl_GetHashValue(entry); UpdateMapInfoClients(master); } /* - * These arrays must be kept in sync with the MapInfoLineStyle - * and MapInfoTextStyle enums. + * These arrays must be kept in sync with the ZnMapInfoLineStyle + * and ZnMapInfoTextStyle enums. */ static char *line_style_strings[] = { "simple", @@ -1544,15 +1554,15 @@ static char *text_style_strings[] = { }; static char * -MapInfoLineStyleToString(MapInfoLineStyle line_style) +ZnMapInfoLineStyleToString(ZnMapInfoLineStyle line_style) { return line_style_strings[line_style]; } static int -MapInfoLineStyleFromString(Tcl_Interp *interp, - char *str, - MapInfoLineStyle *line_style) +ZnMapInfoLineStyleFromString(Tcl_Interp *interp, + char *str, + ZnMapInfoLineStyle *line_style) { int i, num = sizeof(line_style_strings)/sizeof(char *); @@ -1564,19 +1574,19 @@ MapInfoLineStyleFromString(Tcl_Interp *interp, } Tcl_AppendResult(interp, " incorrect mapinfo line style \"", str,"\"", NULL); - return ZN_ERROR; + return TCL_ERROR; } static char * -MapInfoTextStyleToString(MapInfoTextStyle text_style) +ZnMapInfoTextStyleToString(ZnMapInfoTextStyle text_style) { return text_style_strings[text_style]; } static int -MapInfoTextStyleFromString(Tcl_Interp *interp, - char *str, - MapInfoTextStyle *text_style) +ZnMapInfoTextStyleFromString(Tcl_Interp *interp, + char *str, + ZnMapInfoTextStyle *text_style) { int i, num = sizeof(text_style_strings)/sizeof(char *); @@ -1588,23 +1598,31 @@ MapInfoTextStyleFromString(Tcl_Interp *interp, } Tcl_AppendResult(interp, " incorrect mapinfo text style \"", str,"\"", NULL); - return ZN_ERROR; + return TCL_ERROR; } int -MapInfoObjCmd(ClientData client_data, - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - Tcl_Obj *CONST args[]) +ZnMapInfoObjCmd(ClientData client_data __unused, + Tcl_Interp *interp, /* Current interpreter. */ + int argc, /* Number of arguments. */ + Tcl_Obj *CONST args[]) { - int index, index2, result; - MapInfoMaster *master; - Tcl_Obj *l; + int index, index2, result; + ZnMapInfoMaster *master; + Tcl_Obj *l; +#ifdef PTK + static char *sub_cmd_strings[] = { +#else static CONST char *sub_cmd_strings[] = { +#endif "add", "count", "create", "delete", "duplicate", "get", "remove", "replace", "scale", "translate", NULL }; +#ifdef PTK + static char *e_type_strings[] = { +#else static CONST char *e_type_strings[] = { +#endif "arc", "line", "symbol", "text", NULL }; enum sub_cmds { @@ -1618,12 +1636,12 @@ MapInfoObjCmd(ClientData client_data, if (argc < 3) { Tcl_WrongNumArgs(interp, 1, args, "mapInfo/name subCmd ?args?"); - return ZN_ERROR; + return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, args[2], sub_cmd_strings, - "subCmd", 0, &index) != ZN_OK) { - return ZN_ERROR; + "subCmd", 0, &index) != TCL_OK) { + return TCL_ERROR; } result = TCL_OK; /*printf("mapinfo command \"%s\", argc=%d\n", @@ -1637,10 +1655,10 @@ MapInfoObjCmd(ClientData client_data, { if (argc != 3) { Tcl_WrongNumArgs(interp, 1, args, "name create"); - return ZN_ERROR; + return TCL_ERROR; } - if (ZnCreateMapInfo(interp, Tcl_GetString(args[1]), NULL) == ZN_ERROR) { - return ZN_ERROR; + if (ZnCreateMapInfo(interp, Tcl_GetString(args[1]), NULL) == TCL_ERROR) { + return TCL_ERROR; } } break; @@ -1651,10 +1669,10 @@ MapInfoObjCmd(ClientData client_data, { if (argc != 3) { Tcl_WrongNumArgs(interp, 1, args, "mapInfo delete"); - return ZN_ERROR; + return TCL_ERROR; } - if (ZnDeleteMapInfo(interp, Tcl_GetString(args[1])) == ZN_ERROR) { - return ZN_ERROR; + if (ZnDeleteMapInfo(interp, Tcl_GetString(args[1])) == TCL_ERROR) { + return TCL_ERROR; } } break; @@ -1665,15 +1683,15 @@ MapInfoObjCmd(ClientData client_data, { if (argc != 4) { Tcl_WrongNumArgs(interp, 1, args, "mapInfo duplicate name"); - return ZN_ERROR; + return TCL_ERROR; } master = LookupMapInfoMaster(interp, Tcl_GetString(args[1])); if (master == NULL) { - return ZN_ERROR; + return TCL_ERROR; } - if (ZnDuplicateMapInfo(interp, Tcl_GetString(args[3]), - master->map_info) == ZN_ERROR) { - return ZN_ERROR; + if (ZnDuplicateZnMapInfo(interp, Tcl_GetString(args[3]), + master->map_info) == TCL_ERROR) { + return TCL_ERROR; } } break; @@ -1683,33 +1701,30 @@ MapInfoObjCmd(ClientData client_data, case ZN_MI_ADD: case ZN_MI_REPLACE: { - MapInfoLineStyle line_style; - MapInfoTextStyle text_style; - int i, insert; - int coords[6]; - ZnBool add_cmd = (enum sub_cmds) index == ZN_MI_ADD; - int num_param = add_cmd ? 4 : 5; + ZnMapInfoLineStyle line_style; + ZnMapInfoTextStyle text_style; + int i, insert; + int coords[6]; + ZnBool add_cmd = (enum sub_cmds) index == ZN_MI_ADD; + int num_param = add_cmd ? 4 : 5; if (argc < num_param) { Tcl_WrongNumArgs(interp, 3, args, add_cmd ? "elementType ?args?" : "elementType index ?args?"); - return ZN_ERROR; + return TCL_ERROR; } master = LookupMapInfoMaster(interp, Tcl_GetString(args[1])); if (master == NULL) { - return ZN_ERROR; + return TCL_ERROR; } if (!add_cmd) { - if (Tcl_GetIntFromObj(interp, args[4], &insert) == ZN_ERROR) { - return ZN_ERROR; - } - if (insert < 0) { - insert = 0; + if (Tcl_GetIntFromObj(interp, args[4], &insert) == TCL_ERROR) { + return TCL_ERROR; } } if (Tcl_GetIndexFromObj(interp, args[3], e_type_strings, - "elementType", 0, &index2) != ZN_OK) { - return ZN_ERROR; + "elementType", 0, &index2) != TCL_OK) { + return TCL_ERROR; } switch ((enum e_types) index2) { case ZN_E_LINE: @@ -1717,27 +1732,27 @@ MapInfoObjCmd(ClientData client_data, if (argc != (num_param+6)) { Tcl_WrongNumArgs(interp, 4, args, add_cmd ? "style width x1 y1 x2 y2" : "index style width x1 y1 x2 y2"); - return ZN_ERROR; + return TCL_ERROR; } - if (MapInfoLineStyleFromString(interp, Tcl_GetString(args[num_param]), - &line_style) == ZN_ERROR) { - return ZN_ERROR; + if (ZnMapInfoLineStyleFromString(interp, Tcl_GetString(args[num_param]), + &line_style) == TCL_ERROR) { + return TCL_ERROR; } for (i = 0; i < 5; i++) { - if (Tcl_GetIntFromObj(interp, args[num_param+i+1], &coords[i]) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[num_param+i+1], &coords[i]) == TCL_ERROR) { + return TCL_ERROR; } } if (coords[0] < 0) { coords[0] = 0; } if (add_cmd) { - MapInfoAddLine(master->map_info, ZnListTail, NULL, line_style, - coords[0], coords[1], coords[2], coords[3], coords[4]); + ZnMapInfoAddLine(master->map_info, ZnListTail, NULL, line_style, + coords[0], coords[1], coords[2], coords[3], coords[4]); } else { - MapInfoReplaceLine(master->map_info, insert, NULL, line_style, - coords[0], coords[1], coords[2], coords[3], coords[4]); + ZnMapInfoReplaceLine(master->map_info, insert, NULL, line_style, + coords[0], coords[1], coords[2], coords[3], coords[4]); } } break; @@ -1746,23 +1761,23 @@ MapInfoObjCmd(ClientData client_data, if (argc != (num_param+3)) { Tcl_WrongNumArgs(interp, 4, args, add_cmd ? "x y intVal" : "index x y intVal"); - return ZN_ERROR; + return TCL_ERROR; } for (i = 0; i < 3; i++) { - if (Tcl_GetIntFromObj(interp, args[num_param+i], &coords[i]) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[num_param+i], &coords[i]) == TCL_ERROR) { + return TCL_ERROR; } } if (coords[2] < 0) { coords[2] = 0; } if (add_cmd) { - MapInfoAddSymbol(master->map_info, ZnListTail, NULL, coords[0], - coords[1], coords[2]); + ZnMapInfoAddSymbol(master->map_info, ZnListTail, NULL, coords[0], + coords[1], (char) coords[2]); } else { - MapInfoReplaceSymbol(master->map_info, insert, NULL, coords[0], - coords[1], coords[2]); + ZnMapInfoReplaceSymbol(master->map_info, insert, NULL, coords[0], + coords[1], (char) coords[2]); } } break; @@ -1771,32 +1786,32 @@ MapInfoObjCmd(ClientData client_data, if (argc != (num_param+5)) { Tcl_WrongNumArgs(interp, 4, args, add_cmd ? "textStyle lineStyle x y string" : "index textStyle lineStyle x y string"); - return ZN_ERROR; + return TCL_ERROR; } - if (MapInfoTextStyleFromString(interp, Tcl_GetString(args[num_param]), - &text_style) == ZN_ERROR) { - return ZN_ERROR; + if (ZnMapInfoTextStyleFromString(interp, Tcl_GetString(args[num_param]), + &text_style) == TCL_ERROR) { + return TCL_ERROR; } - if (MapInfoLineStyleFromString(interp, Tcl_GetString(args[num_param+1]), - &line_style) == ZN_ERROR) { - return ZN_ERROR; + if (ZnMapInfoLineStyleFromString(interp, Tcl_GetString(args[num_param+1]), + &line_style) == TCL_ERROR) { + return TCL_ERROR; } for (i = 0; i < 2; i++) { - if (Tcl_GetIntFromObj(interp, args[num_param+i+2], &coords[i]) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[num_param+i+2], &coords[i]) == TCL_ERROR) { + return TCL_ERROR; } } if (add_cmd) { - MapInfoAddText(master->map_info, ZnListTail, NULL, text_style, - line_style, coords[0], coords[1], - Tcl_GetString(args[num_param+4])); + ZnMapInfoAddText(master->map_info, ZnListTail, NULL, text_style, + line_style, coords[0], coords[1], + Tcl_GetString(args[num_param+4])); } else { /*printf("replace text ts %d ls %d %d %d %s\n", text_style, line_style, coords[0], coords[1], Tcl_GetString(args[num_param+4]));*/ - MapInfoReplaceText(master->map_info, insert, NULL, text_style, - line_style, coords[0], coords[1], - Tcl_GetString(args[num_param+4])); + ZnMapInfoReplaceText(master->map_info, insert, NULL, text_style, + line_style, coords[0], coords[1], + Tcl_GetString(args[num_param+4])); } } break; @@ -1805,28 +1820,27 @@ MapInfoObjCmd(ClientData client_data, if (argc != (num_param+7)) { Tcl_WrongNumArgs(interp, 4, args, add_cmd ? "style width cx cy radius start extent" : "index style width cx cy radius start extent"); - return ZN_ERROR; + return TCL_ERROR; } - if (MapInfoLineStyleFromString(interp, Tcl_GetString(args[num_param]), - &line_style) == ZN_ERROR) { - return ZN_ERROR; + if (ZnMapInfoLineStyleFromString(interp, Tcl_GetString(args[num_param]), + &line_style) == TCL_ERROR) { + return TCL_ERROR; } for (i = 0; i < 6; i++) { - if (Tcl_GetIntFromObj(interp, args[num_param+i+1], &coords[i]) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[num_param+i+1], &coords[i]) == TCL_ERROR) { + return TCL_ERROR; } } if (coords[0] < 0) { coords[0] = 0; } if (add_cmd) { - MapInfoAddArc(master->map_info, ZnListTail, NULL, line_style, - coords[0], coords[1], coords[2], coords[3], coords[4], - coords[5]); + ZnMapInfoAddArc(master->map_info, ZnListTail, NULL, line_style, coords[0], + coords[1], coords[2], (unsigned int) coords[3], coords[4], coords[5]); } else { - MapInfoReplaceArc(master->map_info, insert, NULL, line_style, coords[0], - coords[1], coords[2], coords[3], coords[4], coords[5]); + ZnMapInfoReplaceArc(master->map_info, insert, NULL, line_style, coords[0], + coords[1], coords[2], (unsigned int) coords[3], coords[4], coords[5]); } } break; @@ -1842,28 +1856,28 @@ MapInfoObjCmd(ClientData client_data, int count = 0; if (argc != 4) { Tcl_WrongNumArgs(interp, 1, args, "mapInfo count type"); - return ZN_ERROR; + return TCL_ERROR; } master = LookupMapInfoMaster(interp, Tcl_GetString(args[1])); if (master == NULL) { - return ZN_ERROR; + return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, args[3], e_type_strings, - "elementType", 0, &index2) != ZN_OK) { - return ZN_ERROR; + "elementType", 0, &index2) != TCL_OK) { + return TCL_ERROR; } switch ((enum e_types) index2) { case ZN_E_LINE: - count = MapInfoNumLines(master->map_info); + count = ZnMapInfoNumLines(master->map_info); break; case ZN_E_SYMBOL: - count = MapInfoNumSymbols(master->map_info); + count = ZnMapInfoNumSymbols(master->map_info); break; case ZN_E_TEXT: - count = MapInfoNumTexts(master->map_info); + count = ZnMapInfoNumTexts(master->map_info); break; case ZN_E_ARC: - count = MapInfoNumArcs(master->map_info); + count = ZnMapInfoNumArcs(master->map_info); break; } l = Tcl_NewIntObj(count); @@ -1875,35 +1889,35 @@ MapInfoObjCmd(ClientData client_data, */ case ZN_MI_GET: { - int insert; + int insert; if (argc != 5) { Tcl_WrongNumArgs(interp, 1, args, "mapInfo get type index"); - return ZN_ERROR; + return TCL_ERROR; } master = LookupMapInfoMaster(interp, Tcl_GetString(args[1])); if (master == NULL) { - return ZN_ERROR; + return TCL_ERROR; } - if (Tcl_GetIntFromObj(interp, args[4], &insert) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[4], &insert) == TCL_ERROR) { + return TCL_ERROR; } if (insert < 0) { insert = 0; } if (Tcl_GetIndexFromObj(interp, args[3], e_type_strings, - "elementType", 0, &index2) != ZN_OK) { - return ZN_ERROR; + "elementType", 0, &index2) != TCL_OK) { + return TCL_ERROR; } switch ((enum e_types) index2) { case ZN_E_LINE: { - MapInfoLineStyle line_style; + ZnMapInfoLineStyle line_style; int line_width; int x_from, y_from, x_to, y_to; - MapInfoGetLine(master->map_info, insert, NULL, &line_style, - &line_width, &x_from, &y_from, &x_to, &y_to); + ZnMapInfoGetLine(master->map_info, insert, NULL, &line_style, + &line_width, &x_from, &y_from, &x_to, &y_to); l = Tcl_GetObjResult(interp); - Tcl_ListObjAppendElement(interp, l, NewStringObj(MapInfoLineStyleToString(line_style))); + Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj(ZnMapInfoLineStyleToString(line_style), -1)); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(line_width)); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(x_from)); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(y_from)); @@ -1915,7 +1929,7 @@ MapInfoObjCmd(ClientData client_data, { int x, y; char symbol; - MapInfoGetSymbol(master->map_info, insert, NULL, &x, &y, &symbol); + ZnMapInfoGetSymbol(master->map_info, insert, NULL, &x, &y, &symbol); l = Tcl_GetObjResult(interp); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(x)); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(y)); @@ -1926,28 +1940,27 @@ MapInfoObjCmd(ClientData client_data, { int x, y; char *text; - MapInfoTextStyle text_style; - MapInfoLineStyle line_style; - MapInfoGetText(master->map_info, insert, NULL, &text_style, &line_style, - &x, &y, &text); + ZnMapInfoTextStyle text_style; + ZnMapInfoLineStyle line_style; + ZnMapInfoGetText(master->map_info, insert, NULL, &text_style, &line_style, + &x, &y, &text); l = Tcl_GetObjResult(interp); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(x)); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(y)); - Tcl_ListObjAppendElement(interp, l, NewStringObj(MapInfoTextStyleToString(text_style))); - Tcl_ListObjAppendElement(interp, l, NewStringObj(MapInfoLineStyleToString(line_style))); - Tcl_ListObjAppendElement(interp, l, NewStringObj(text)); + Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj(ZnMapInfoTextStyleToString(text_style), -1)); + Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj(ZnMapInfoLineStyleToString(line_style), -1)); + Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj(text, -1)); } break; case ZN_E_ARC: { - MapInfoLineStyle line_style; - int line_width; - int center_x, center_y, start, extent; - unsigned int radius; - MapInfoGetArc(master->map_info, insert, NULL, &line_style, &line_width, - ¢er_x, ¢er_y, &radius, &start, &extent); + ZnMapInfoLineStyle line_style; + int line_width, radius; + int center_x, center_y, start, extent; + ZnMapInfoGetArc(master->map_info, insert, NULL, &line_style, &line_width, + ¢er_x, ¢er_y, &radius, &start, &extent); l = Tcl_GetObjResult(interp); - Tcl_ListObjAppendElement(interp, l, NewStringObj(MapInfoLineStyleToString(line_style))); + Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj(ZnMapInfoLineStyleToString(line_style), -1)); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(line_width)); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(center_x)); Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(center_y)); @@ -1964,37 +1977,37 @@ MapInfoObjCmd(ClientData client_data, */ case ZN_MI_REMOVE: { - int insert; + int insert; if (argc != 5) { Tcl_WrongNumArgs(interp, 1, args, "mapInfo remove type index"); - return ZN_ERROR; + return TCL_ERROR; } master = LookupMapInfoMaster(interp, Tcl_GetString(args[1])); if (master == NULL) { - return ZN_ERROR; + return TCL_ERROR; } - if (Tcl_GetIntFromObj(interp, args[4], &insert) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[4], &insert) == TCL_ERROR) { + return TCL_ERROR; } if (insert < 0) { insert = 0; } if (Tcl_GetIndexFromObj(interp, args[3], e_type_strings, - "elementType", 0, &index2) != ZN_OK) { - return ZN_ERROR; + "elementType", 0, &index2) != TCL_OK) { + return TCL_ERROR; } switch ((enum e_types) index2) { case ZN_E_LINE: - MapInfoRemoveLine(master->map_info, insert); + ZnMapInfoRemoveLine(master->map_info, insert); break; case ZN_E_SYMBOL: - MapInfoRemoveSymbol(master->map_info, insert); + ZnMapInfoRemoveSymbol(master->map_info, insert); break; case ZN_E_TEXT: - MapInfoRemoveText(master->map_info, insert); + ZnMapInfoRemoveText(master->map_info, insert); break; case ZN_E_ARC: - MapInfoRemoveArc(master->map_info, insert); + ZnMapInfoRemoveArc(master->map_info, insert); break; } UpdateMapInfoClients(master); @@ -2009,16 +2022,16 @@ MapInfoObjCmd(ClientData client_data, if (argc != 4) { Tcl_WrongNumArgs(interp, 1, args, "mapInfo scale factor"); - return ZN_ERROR; + return TCL_ERROR; } master = LookupMapInfoMaster(interp, Tcl_GetString(args[1])); if (master == NULL) { - return ZN_ERROR; + return TCL_ERROR; } - if (Tcl_GetDoubleFromObj(interp, args[3], &factor) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetDoubleFromObj(interp, args[3], &factor) == TCL_ERROR) { + return TCL_ERROR; } - MapInfoScale(master->map_info, factor); + ZnMapInfoScale(master->map_info, factor); UpdateMapInfoClients(master); } break; @@ -2031,19 +2044,19 @@ MapInfoObjCmd(ClientData client_data, if (argc != 5) { Tcl_WrongNumArgs(interp, 1, args, "mapInfo translate xAmount yAmount"); - return ZN_ERROR; + return TCL_ERROR; } master = LookupMapInfoMaster(interp, Tcl_GetString(args[1])); if (master == NULL) { - return ZN_ERROR; + return TCL_ERROR; } - if (Tcl_GetIntFromObj(interp, args[3], &x) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[3], &x) == TCL_ERROR) { + return TCL_ERROR; } - if (Tcl_GetIntFromObj(interp, args[4], &y) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[4], &y) == TCL_ERROR) { + return TCL_ERROR; } - MapInfoTranslate(master->map_info, x, y); + ZnMapInfoTranslate(master->map_info, x, y); UpdateMapInfoClients(master); } break; @@ -2062,16 +2075,20 @@ MapInfoObjCmd(ClientData client_data, *---------------------------------------------------------------------- */ int -VideomapObjCmd(ClientData client_data, - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - Tcl_Obj *CONST args[]) +ZnVideomapObjCmd(ClientData client_data __unused, + Tcl_Interp *interp, /* Current interpreter. */ + int argc, /* Number of arguments. */ + Tcl_Obj *CONST args[]) { ZnList ids; int index; int *id_array, id_num, i; Tcl_Obj *l; +#ifdef PTK + static char *sub_cmd_strings[] = { +#else static CONST char *sub_cmd_strings[] = { +#endif "ids", "load", NULL }; enum sub_cmds { @@ -2081,12 +2098,12 @@ VideomapObjCmd(ClientData client_data, if (argc < 2) { Tcl_WrongNumArgs(interp, 1, args, "?subCmd? filename $args?"); - return ZN_ERROR; + return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, args[1], sub_cmd_strings, - "subCmd", 0, &index) != ZN_OK) { - return ZN_ERROR; + "subCmd", 0, &index) != TCL_OK) { + return TCL_ERROR; } switch((enum sub_cmds) index) { @@ -2097,13 +2114,13 @@ VideomapObjCmd(ClientData client_data, { if (argc != 3) { Tcl_WrongNumArgs(interp, 1, args,"ids filename"); - return ZN_ERROR; + return TCL_ERROR; } - ids = MapInfoVideomapIds(Tcl_GetString(args[2])); + ids = ZnMapInfoVideomapIds(Tcl_GetString(args[2])); if (ids == NULL) { Tcl_AppendResult(interp, "unable to look at videomap file \"", Tcl_GetString(args[2]), "\"", NULL); - return ZN_ERROR; + return TCL_ERROR; } id_array = (int *) ZnListArray(ids); id_num = ZnListSize(ids); @@ -2119,27 +2136,27 @@ VideomapObjCmd(ClientData client_data, */ case ZN_V_LOAD: { - MapInfoId map_info; - int insert; + ZnMapInfoId map_info; + int insert; if (argc != 5) { Tcl_WrongNumArgs(interp, 1, args, "load filename index mapInfo"); - return ZN_ERROR; + return TCL_ERROR; } - if (Tcl_GetIntFromObj(interp, args[3], &insert) == ZN_ERROR) { - return ZN_ERROR; + if (Tcl_GetIntFromObj(interp, args[3], &insert) == TCL_ERROR) { + return TCL_ERROR; } if (insert < 0) { insert = 0; } - if (ZnCreateMapInfo(interp, Tcl_GetString(args[4]), &map_info) == ZN_ERROR) { - return ZN_ERROR; + if (ZnCreateMapInfo(interp, Tcl_GetString(args[4]), &map_info) == TCL_ERROR) { + return TCL_ERROR; } - if (MapInfoGetVideomap(map_info, Tcl_GetString(args[2]), insert) == ZN_ERROR) { + if (ZnMapInfoGetVideomap(map_info, Tcl_GetString(args[2]), insert) == TCL_ERROR) { Tcl_AppendResult(interp, "unable to load videomap file \"", Tcl_GetString(args[2]), ":", Tcl_GetString(args[3]), "\"", NULL); - return ZN_ERROR; + return TCL_ERROR; } ZnUpdateMapInfoClients(map_info); } -- cgit v1.1