Buff size argument added to get_plant_select function

parent 8d7bcd2f
......@@ -100,7 +100,7 @@ static void nav_sel_convert_cb( GtkWidget *w, GtkSelectionData *selection_data,
strcpy( name, "");
}
else {
sts = nav->get_plant_select_cb( nav->parent_ctx, name);
sts = nav->get_plant_select_cb( nav->parent_ctx, name, sizeof(name));
if ( EVEN(sts)) {
strcpy( name, "");
}
......
......@@ -123,7 +123,7 @@ static Boolean nav_sel_convert_cb(
if ( !nav->get_plant_select_cb)
return FALSE;
sts = nav->get_plant_select_cb( nav->parent_ctx, name);
sts = nav->get_plant_select_cb( nav->parent_ctx, name, sizeof(name));
if ( EVEN(sts)) return FALSE;
*value_return = XtNewString(name);
*length_return = strlen(name) + 1;
......
......@@ -68,7 +68,7 @@ class Nav {
flow_sAnnotPixmap *pixmap_attrarray;
flow_sAnnotPixmap *pixmap_attrarrayelem;
flow_sAnnotPixmap *pixmap_attrobject;
int (*get_plant_select_cb)( void *, char *);
int (*get_plant_select_cb)( void *, char *, int);
int (*set_focus_cb)( void *, void *);
int (*traverse_focus_cb)( void *, void *);
int displayed;
......
......@@ -269,7 +269,7 @@ void GeGtk::change_value_cb( void *ge_ctx, void *value_object, char *text)
gectx->current_value_object = value_object;
}
int GeGtk::get_plant_select( char *select_name)
int GeGtk::get_plant_select( char *select_name, int size)
{
#ifdef LDH
pwr_sAttrRef attrref;
......@@ -296,17 +296,17 @@ int GeGtk::get_plant_select( char *select_name)
0, 1, 1, buff))
return 0;
strcpy( select_name, buff);
strncpy( select_name, buff, size);
return 1;
}
else {
sts = CoWowGtk::GetSelection( toplevel, str, sizeof(str), graph_atom);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
else {
sts = CoWowGtk::GetSelection( toplevel, str, sizeof(str), GDK_TARGET_STRING);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
}
return sts;
}
......@@ -316,11 +316,11 @@ int GeGtk::get_plant_select( char *select_name)
sts = CoWowGtk::GetSelection( toplevel, str, sizeof(str), graph_atom);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
else {
sts = CoWowGtk::GetSelection( toplevel, str, sizeof(str), GDK_ATOM_STRING);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
}
return sts;
#endif
......
......@@ -86,7 +86,7 @@ class GeGtk : public Ge {
virtual void set_prompt( const char *prompt);
virtual void subgraphs_new();
virtual void update();
virtual int get_plant_select( char *name);
virtual int get_plant_select( char *name, int size);
virtual void create_list( const char *title, const char *texts,
void (action_cb)( void *, char *), void *ctx);
virtual int create_modal_dialog( const char *title, const char *text, const char *button1,
......
......@@ -256,7 +256,7 @@ void GeMotif::change_value_cb( void *ge_ctx, void *value_object, char *text)
gectx->current_value_object = value_object;
}
int GeMotif::get_plant_select( char *select_name)
int GeMotif::get_plant_select( char *select_name, int size)
{
#if LDH
pwr_sAttrRef attrref;
......@@ -268,11 +268,11 @@ int GeMotif::get_plant_select( char *select_name)
if ( !ldhses) {
sts = CoWowMotif::GetSelection( toplevel, str, sizeof(str), graph_atom);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
else {
sts = CoWowMotif::GetSelection( toplevel, str, sizeof(str), XA_STRING);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
}
return sts;
}
......@@ -283,17 +283,17 @@ int GeMotif::get_plant_select( char *select_name)
0, 1, 1, buff))
return 0;
strcpy( select_name, buff);
strncpy( select_name, buff, size);
return 1;
}
else {
sts = CoWowMotif::GetSelection( toplevel, str, sizeof(str), graph_atom);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
else {
sts = CoWowMotif::GetSelection( toplevel, str, sizeof(str), XA_STRING);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
}
return sts;
}
......@@ -303,11 +303,11 @@ int GeMotif::get_plant_select( char *select_name)
sts = CoWowMotif::GetSelection( toplevel, str, sizeof(str), graph_atom);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
else {
sts = CoWowMotif::GetSelection( toplevel, str, sizeof(str), XA_STRING);
if ( ODD(sts))
strcpy( select_name, str);
strncpy( select_name, str, size);
}
return sts;
#endif
......
......@@ -82,7 +82,7 @@ class GeMotif : public Ge {
virtual void set_prompt( const char *prompt);
virtual void subgraphs_new();
virtual void update();
virtual int get_plant_select( char *name);
virtual int get_plant_select( char *name, int size);
virtual void create_list( const char *title, const char *texts,
void (action_cb)( void *, char *), void *ctx);
virtual void plant_del( void *plantctx);
......
......@@ -926,7 +926,7 @@ void Ge::activate_connect()
message( 'E', "More than one object is selected");
return;
}
sts = Ge::get_plant_select_cb( (void *)this, name);
sts = Ge::get_plant_select_cb( (void *)this, name, sizeof(name));
if ( EVEN(sts)) {
message( 'E', "Select an object in the plant hierarchy");
return;
......@@ -952,7 +952,7 @@ void Ge::activate_connectsecond()
message( 'E', "More than one object is selected");
return;
}
sts = Ge::get_plant_select_cb( (void *)this, name);
sts = Ge::get_plant_select_cb( (void *)this, name, sizeof(name));
if ( EVEN(sts)) {
message( 'E', "Select an object in the plant hierarchy");
return;
......@@ -994,9 +994,9 @@ void Ge::activate_command()
{
}
int Ge::get_plant_select_cb( void *ge_ctx, char *select_name)
int Ge::get_plant_select_cb( void *ge_ctx, char *select_name, int size)
{
return ((Ge *)ge_ctx)->get_plant_select( select_name);
return ((Ge *)ge_ctx)->get_plant_select( select_name, size);
}
void Ge::activate_exit()
......
......@@ -114,7 +114,7 @@ class Ge {
virtual void set_prompt( const char *prompt) {}
virtual void subgraphs_new() {}
virtual void update() {}
virtual int get_plant_select( char *name) { return 0;}
virtual int get_plant_select( char *name, int size) { return 0;}
virtual void create_list( const char *title, const char *texts,
void (action_cb)( void *, char *), void *ctx) {}
virtual int create_modal_dialog( const char *title, const char *text, const char *button1,
......@@ -257,7 +257,7 @@ class Ge {
void activate_confirm_ok();
void activate_confirm_cancel();
static int get_plant_select_cb( void *ge_ctx, char *select_name);
static int get_plant_select_cb( void *ge_ctx, char *select_name, int size);
static void load_graph_cb( void *ge_ctx, char *name);
static void save_graph( Ge *gectx, char *name);
static void save_graph_and_close( Ge *gectx, char *name);
......
......@@ -120,11 +120,11 @@ void Attr::recall_prev()
}
}
int Attr::get_plant_select_c( void *attr_ctx, char *value)
int Attr::get_plant_select_c( void *attr_ctx, char *value, int size)
{
Attr *attr = (Attr *) attr_ctx;
if ( attr->get_plant_select_cb)
return attr->get_plant_select_cb( attr->parent_ctx, value);
return attr->get_plant_select_cb( attr->parent_ctx, value, size);
return 0;
}
......
......@@ -70,7 +70,7 @@ class Attr {
void (*store_cb) (void *, void *);
int (*recall_cb) (void *, void *, int, GeDyn **);
int (*set_data_cb) (void *, void *, GeDyn *);
int (*get_plant_select_cb) (void *, char *);
int (*get_plant_select_cb) (void *, char *, int);
int (*get_current_colors_cb)( void *, glow_eDrawType *, glow_eDrawType *,
glow_eDrawType *);
void *client_data;
......@@ -84,7 +84,7 @@ class Attr {
virtual void store();
virtual void recall_next();
virtual void recall_prev();
static int get_plant_select_c( void *attr_ctx, char *value);
static int get_plant_select_c( void *attr_ctx, char *value, int size);
static int get_current_colors_c( void *attr_ctx, glow_eDrawType *fill_color,
glow_eDrawType *border_color,
glow_eDrawType *text_color);
......
......@@ -1061,25 +1061,25 @@ void attrnav_attrvalue_to_string( int type_id, void *value_ptr,
case glow_eType_Boolean:
{
if ( !format)
*len = sprintf( str, "%d", *(pwr_tBoolean *)value_ptr);
*len = snprintf( str, size, "%d", *(pwr_tBoolean *)value_ptr);
else
*len = sprintf( str, format, *(pwr_tBoolean *)value_ptr);
*len = snprintf( str, size, format, *(pwr_tBoolean *)value_ptr);
break;
}
case glow_eType_Double:
{
if ( !format)
*len = sprintf( str, "%f", *(double *)value_ptr);
*len = snprintf( str, size, "%g", *(double *)value_ptr);
else
*len = sprintf( str, format, *(double *)value_ptr);
*len = snprintf( str, size, format, *(double *)value_ptr);
break;
}
case glow_eType_Int:
{
if ( !format)
*len = sprintf( str, "%d", *(int *)value_ptr);
*len = snprintf( str, size, "%d", *(int *)value_ptr);
else
*len = sprintf( str, format, *(int *)value_ptr);
*len = snprintf( str, size, format, *(int *)value_ptr);
break;
}
case glow_eType_String:
......@@ -1159,7 +1159,7 @@ void attrnav_attrvalue_to_string( int type_id, void *value_ptr,
str[size-1] = 0;
*len = strlen( str);
#if 0
*len = sprintf( str, "%u", *(unsigned int *)value_ptr);
*len = snprintf( str, size, "%u", *(unsigned int *)value_ptr);
#endif
break;
}
......@@ -1639,7 +1639,7 @@ static int attrnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
if ( ! attrnav->get_plant_select_cb)
break;
sts = (attrnav->get_plant_select_cb) (attrnav->parent_ctx, attr_name);
sts = (attrnav->get_plant_select_cb) (attrnav->parent_ctx, attr_name, sizeof(attr_name));
if ( EVEN(sts)) break;
strncpy( (char *)item->value_p, attr_name, item->size);
......@@ -1892,7 +1892,7 @@ void AttrNavBrow::create_nodeclasses()
brow_AddAnnot( nc_object, 11, 0.6, 2,
flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine,
1);
brow_AddFrame( nc_object, 0, 0, 20, 0.8, flow_eDrawType_LineGray, -1, 1);
brow_AddFrame( nc_object, 0, 0, 20, 0.83, flow_eDrawType_LineGray, -1, 1);
// Create attribute nodeclass
......@@ -1905,7 +1905,7 @@ void AttrNavBrow::create_nodeclasses()
brow_AddAnnot( nc_attr, 8, 0.6, 1,
flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine,
1);
brow_AddFrame( nc_attr, 0, 0, 20, 0.8, flow_eDrawType_LineGray, -1, 1);
brow_AddFrame( nc_attr, 0, 0, 20, 0.83, flow_eDrawType_LineGray, -1, 1);
// Create multiline attribute nodeclass
......@@ -1918,7 +1918,7 @@ void AttrNavBrow::create_nodeclasses()
brow_AddAnnot( nc_attr_multiline, 8, 0.6, 1,
flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_MultiLine,
1);
brow_AddFrame( nc_attr_multiline, 0, 0, 20, 0.8, flow_eDrawType_LineGray, -1, 1);
brow_AddFrame( nc_attr_multiline, 0, 0, 20, 0.83, flow_eDrawType_LineGray, -1, 1);
// Create attribute nodeclass
......@@ -1929,7 +1929,7 @@ void AttrNavBrow::create_nodeclasses()
brow_AddAnnot( nc_enum, 2, 0.6, 0,
flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine,
0);
brow_AddFrame( nc_enum, 0, 0, 20, 0.8, flow_eDrawType_LineGray, -1, 1);
brow_AddFrame( nc_enum, 0, 0, 20, 0.83, flow_eDrawType_LineGray, -1, 1);
// Create table nodeclass
......@@ -1967,7 +1967,7 @@ void AttrNavBrow::create_nodeclasses()
brow_AddAnnot( nc_table, 38, 0.6, 9,
flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine,
1);
brow_AddFrame( nc_table, 0, 0, 20, 0.8, flow_eDrawType_LineGray, -1, 1);
brow_AddFrame( nc_table, 0, 0, 20, 0.83, flow_eDrawType_LineGray, -1, 1);
// Create Header
......@@ -1980,7 +1980,7 @@ void AttrNavBrow::create_nodeclasses()
brow_AddAnnot( nc_header, 8, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
1);
brow_AddFrame( nc_header, 0, 0, 20, 0.8, flow_eDrawType_LineGray, 2, 1);
brow_AddFrame( nc_header, 0, 0, 20, 0.83, flow_eDrawType_LineGray, 2, 1);
// Create TableHeader
......@@ -2017,7 +2017,7 @@ void AttrNavBrow::create_nodeclasses()
brow_AddAnnot( nc_table_header, 38, 0.6, 9,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddFrame( nc_table_header, 0, 0, 20, 0.8, flow_eDrawType_LineGray, 2, 1);
brow_AddFrame( nc_table_header, 0, 0, 20, 0.83, flow_eDrawType_LineGray, 2, 1);
}
......
......@@ -139,7 +139,7 @@ class AttrNav {
int (*get_subgraph_info_cb)( void *, char *, attr_sItem **, int *);
int (*get_dyn_info_cb)( void *, GeDyn *, attr_sItem **, int *);
int (*reconfigure_attr_cb)( void *);
int (*get_plant_select_cb)( void *, char *);
int (*get_plant_select_cb)( void *, char *, int);
int (*get_current_colors_cb)( void *, glow_eDrawType *, glow_eDrawType *,
glow_eDrawType *);
......
......@@ -103,7 +103,7 @@ static int graph_get_dyn_info_cb( void *g, GeDyn *dyn,
attr_sItem **itemlist, int *itemlist_cnt);
static int graph_reconfigure_attr_cb( void *g, grow_tObject object,
attr_sItem **itemlist, int *itemlist_cnt, void **client_data);
static int graph_get_plant_select_cb( void *g, char *value);
static int graph_get_plant_select_cb( void *g, char *value, int size);
static int graph_get_current_colors_cb( void *g, glow_eDrawType *fill_color,
glow_eDrawType *border_color, glow_eDrawType *text_color);
static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event);
......@@ -1698,11 +1698,11 @@ int Graph::edit_attributes( grow_tObject object)
}
static int graph_get_plant_select_cb( void *g, char *value)
static int graph_get_plant_select_cb( void *g, char *value, int size)
{
Graph *graph = (Graph *)g;
if ( graph->get_plant_select_cb)
return (graph->get_plant_select_cb) (graph->parent_ctx, value);
return (graph->get_plant_select_cb) (graph->parent_ctx, value, size);
return 0;
}
......@@ -2641,7 +2641,7 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
if ( ! graph->get_plant_select_cb)
break;
sts = (graph->get_plant_select_cb) (graph->parent_ctx, attr_name);
sts = (graph->get_plant_select_cb) (graph->parent_ctx, attr_name, sizeof(attr_name));
if ( EVEN(sts)) {
graph->message( 'E', "Select an object in the Plant palette");
break;
......
......@@ -439,7 +439,7 @@ class Graph {
void (*confirm_cb)( void *, void *, char *);
int (*command_cb)( void *, char *);
void (*load_graph_cb)( void *, char *);
int (*get_plant_select_cb)( void *, char *attr_name);
int (*get_plant_select_cb)( void *, char *attr_name, int size);
void (*display_in_xnav_cb)( void *, pwr_sAttrRef *arp);
void (*message_dialog_cb)( void *, const char *);
int (*is_authorized_cb)( void *, unsigned int);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment