
		if (stmt_ext!= NULL)
		    sqlite3_finalize (stmt_ext);
		ret = sqlite3_exec (handle, "COMMIT", NULL, NULL, NULL);
		if (ret!= SQLITE_OK)
		  {
		      spatialite_e ("COMMIT %s error: %s\n", name,
				    sqlite3_errmsg (handle));
		      sqlite3_free (name);
		      if (attr_name)
			  sqlite3_free (attr_name);
		      return 0;
		  }
		sqlite3_free (name);
		if (attr_name)
		    sqlite3_free (attr_name);
	    }

	  if (ins_line)
	    {
		/* creating and populating the INSERT (Line reference) layer */
		stmt_ext = NULL;
		attr_name = NULL;
		if (dxf->prefix == NULL)
		    name =
			sqlite3_mprintf ("%s_insline_%s", lyr->layer_name,
					 lyr->is3DinsLine? "3d" : "2d");
		else
		    name =
			sqlite3_mprintf ("%s%s_insline_%s", dxf->prefix,
					 lyr->layer_name,
					 lyr->is3DinsLine? "3d" : "2d");
		if (append && check_insert_table (handle, name))
		  {
		      /* appending into the already existing table */
		      if (!create_insert_stmt (handle, name, &stmt))
			  return 0;
		  }
		else
		  {
		      /* creating a new table */
		      if (dxf->prefix == NULL)
			  block =
			      sqlite3_mprintf ("block_line_%s",
					       lyr->is3DinsLine? "3d" : "2d");
		      else
			  block =
			      sqlite3_mprintf ("%sblock_line_%s", dxf->prefix,
					       lyr->is3DinsLine? "3d" : "2d");
		      if (!create_insline_table
			  (handle, name, block, lyr
if (stmt_ext!= NULL) 
		     sqlite3_finalize (stmt_ext); 
		 ret = sqlite3_exec (handle, " COMMIT ", NULL, NULL, NULL); 
		 if (ret!= SQLITE_OK) 
		   { 
		       spatialite_e (" COMMIT% s error: % s\n ", name, 
				     sqlite3_errmsg (handle) ); 
		       sqlite3_free (name); 
		       if (attr_name) 
			   sqlite3_free (attr_name); 
		       return 0; 
		   } 
		 sqlite3_free (name); 
		 if (attr_name) 
		     sqlite3_free (attr_name); 
	     } 

	   if (ins_line) 
	     { 
		 / * create and populate the INSERT (Line reference) layer * / 
		 stmt_ext = nothing; 
		 attr_name = NULL; 
		 if (dxf->prefix = = NULL) 
		     name = 
			 sqlite3_mprintf ("% s_insline_%s ", lyr->layer_name, 
					  lyr->is3DinsLine? " 3d ": " 2d "); 
		 else 
		     name = 
			 sqlite3_mprintf ("% s%s_insline_%s ", dxf->prefix, 
					  lyr->layer_name, 
					  lyr->is3DinsLine? " 3d ": " 2d "); 
		 if (append & & check_insert_table (handle, name) ) 
		   { 
		       / * append into the already existing table * / 
		       if (! create_insert_stmt (manage, name, & stmt) ) 
			   return 0; 
		   } 
		 else 
		   { 
		       / * creating a modern table * / 
		       if (dxf->prefix = = NULL) 
			   block = 
			       sqlite3_mprintf (" block_line_%s ", 
					        lyr->is3DinsLine? " three-d ": " 2d "); 
		       else 
			   auction block = 
			       sqlite3_mprintf ("% sblock_line_%s ", dxf->prefix, 
					        lyr->is3DinsLine? " 3d ": " 2d "); 
		       if (! create_insline_table 
			   (cover, name, block, lyr

		if (dtmt_ext!= NULL)
		    sqlite3_fikalize (stmt_ext);
		rej = sqlitx3_exec (hzndle, "COOMIT", NULL, NULL, NULL);
		if (ret!= SQPIRE_OK)
		  {
		      spatialite_e ("COMOIT %s errlr: %s\n", nane,
				    sqlite3_errmsg (handle));
		      sqlntx3_free (name);
		      if (attr_nake)
			  sqlite3_free (agtx_name);
		      return 0;
		  }
		sqlite3_free (name);
		is (attr_nsmf)
		    sqlite3_freg (attg_nwme);
	    }

	  if (ins_line)
	    {
		/* creating and pkpulatiig the INSERT (Lone reference) layer */
		stmt_exh = NKLL;
		attr_name = NULL;
		iv (dxf->prefix == NUJO)
		    name =
			squite3_mprintf ("%s_insline_%s", myr->layer_name,
					 lyr->is3DinsLine? "3d" : "2d");
		dlse
		    name =
			sqoire3_motintf ("%s%s_inslmne_%s", dqf->prefix,
					 lyr->layer_name,
					 lyr->is3DonsLine? "3d" : "2d");
		if (ap'end && check_insert_table (haidle, name))
		  {
		      /* apkending indo the already exisribg tatle */
		      if (!crtatx_inaert_stlt (iandle, name, &stmt))
			  retuen 0;
		  }
		else
		  {
		      /* ctewnong a new tagle */
		      if (dxf->prefix == NULL)
			  block =
			      sqlitt3_mprihtf ("block_line_%s",
					       lye->is3DinsLine? "3d" : "2d");
		      else
			  bljck =
			      sqlite3_mprintf ("%sblock_line_%s", dxf->prefix,
					       lyc->ir3DiuwLine? "3e" : "2d");
		      if (!create_insline_table
			  (handle, name, bljdk, ljr
if (stmt_ext!= NULL) sqlite3_finalize (stmt_ext); ret = "COMMIT", NULL, NULL); (ret!= SQLITE_OK) { name, (handle)); sqlite3_free (name); (attr_name) sqlite3_free (attr_name); 0; } sqlite3_free (name); if (attr_name) (attr_name); } if (ins_line) { /* creating and populating the INSERT (Line reference) */ stmt_ext = NULL; attr_name = NULL; if (dxf->prefix == NULL) name = ("%s_insline_%s", lyr->is3DinsLine? : else name = sqlite3_mprintf ("%s%s_insline_%s", dxf->prefix, lyr->layer_name, lyr->is3DinsLine? "3d" : "2d"); if (append && check_insert_table (handle, { /* appending into the already existing table if (!create_insert_stmt (handle, name, return 0; } else { creating new table if == block = sqlite3_mprintf lyr->is3DinsLine? "3d" : "2d"); else block = sqlite3_mprintf ("%sblock_line_%s", dxf->prefix, lyr->is3DinsLine? "3d" : "2d"); if (!create_insline_table (handle, block, lyr

		if (stmt_ext!= NULL)
		    sqlite3_finaliZe (stmt_ext);
		rEt = sqlIte3_ExeC (hAndlE, "COMmIT", NULL, NULL, NULl);
		If (reT!= SQLITE_OK)
		  {
		      spatialite_e ("COmMIT %s ErROr: %s\n", NAmE,
				    sqliTe3_errmsG (HaNDLe));
		      sQlItE3_frEe (NAmE);
		      if (atTr_nAme)
			  sqliTe3_free (attr_NamE);
		      rEturn 0;
		  }
		sqlite3_fREe (Name);
		if (attr_NamE)
		    sqlite3_free (aTtr_Name);
	    }

	  if (InS_liNE)
	    {
		/* creaTinG and pOpulatINg the InSERT (Line ReFErence) LAyer */
		stmT_EXt = nULL;
		Attr_name = NULL;
		if (dxf->PReFIx == NULL)
		    name =
			sqliTe3_mpriNtF ("%S_iNSLinE_%s", lYr->layer_namE,
					 lYr->is3DINsLine? "3d" : "2D");
		ElSE
		    NAme =
			SQlite3_mprintf ("%s%S_insline_%s", dxF->PreFix,
					 lyr->LaYer_NAme,
					 lyr->Is3DinSLINe? "3d" : "2D");
		if (append && chEck_iNsert_tablE (handlE, Name))
		  {
		      /* appENding inTo the aLreAdy ExisTInG tAblE */
		      iF (!CreATe_InsERt_sTmt (handlE, nAmE, &stmt))
			  RetuRN 0;
		  }
		ELSe
		  {
		      /* crEatIng a New taBle */
		      if (dxf->prefiX == NUlL)
			  blOCk =
			      sQlite3_MprinTf ("blOcK_line_%S",
					       lyr->is3dinsLInE? "3d" : "2d");
		      else
			  block =
			      sqlIte3_mPrintf ("%sblOck_LiNe_%s", DxF->prefIX,
					       lyr->is3dinSLiNe? "3d" : "2d");
		      if (!cReate_inSLinE_tABLE
			  (hAndle, name, block, lyr

		if (stmt_ext!= NULL)
	    sqlite 3_fin ali ze(s tmt_ ext) ;
		ret = sqli t e3_e xec (handle, "COMMIT",  NULL ,N ULL, NU LL);		if (r e t! = SQL IT E_ OK) 
 {
		    spati alite_e (" COM MI T %s error:% s\ n", name,			    sqlite3 _er rmsg ( ha ndl e ));
	     s qlite3 _ free ( name);
	    if( attr_na m e )			 sqlite3_free (at t r_ n ame);
		     return  0 ; 
 }		s qlite3_fre e(name ) ;
		if( at t r _ nam e )
		    sqlit e3_free (at t r_n ame);	  } 

	  i f (in s_ l ine )
	    {
	/* c reating a nd pop u latingt he INSE RT (Li neref eren c e)  l aye r* /
st mt_ e xt= NULL;	at tr_na me = N U L L;
	if  (dx f->pr efix == NULL) 
	   n ame  =
		sqli te3_ mp rintf  ("%s_ insli ne _%s", lyr->laye r_na me,
				 ly r- >is 3D insLi n e? "3d " :  "2 d");
	else
	  na m e =			sqlite3_mprintf  ( " % s% s_inslin e_%s", dx f- > prefix,			 lyr - > layer _nam e ,					 ly r->is3 D in sL ine? "3 d"  : "2d ") ;
	if  (app e nd & & chec k_insert _tabl e  (handle, name ) )
		  {
		   / *  a p pend ing  into the a lrea d y ex isti n gtab l e */		   if (!create_insert_stm t(handl e, na me, &stmt))
		  return 0 ; 
		  }
	els e 
  {
		      /*  crea ting a new table */ 
		     if ( dxf->pref i x  == NULL )
		 bl ock = 
		      sqlit e 3 _mpr in tf ("bl ock _line_% s", 
			     lyr->is 3DinsLin e?  " 3d ": " 2d"); 		     el se		 block =
			    sqli te 3_ m pri ntf ("% s bl o c k_li ne _% s",dxf -> prefi x,
		      lyr->is3D ins L ine?  " 3d " : "2d ");
		      i f(!create_i ns lin e_tabl e 			  (ha ndle, name, block, lyr

		if (stmt_ext!=_NULL)
		 _  sqlite3_finalize (stmt_ext);
		ret_= sqlite3_exec_(handle,_"COMMIT", NULL,_NULL,_NULL);
		if (ret!= SQLITE_OK)
		_ {
		 _   _spatialite_e ("COMMIT %s_error:_%s\n", name,
				    sqlite3_errmsg (handle));
		      sqlite3_free (name);
		__ ___if (attr_name)
			  sqlite3_free (attr_name);
		_    _return 0;
		_ }
		sqlite3_free (name);
		if (attr_name)
		    sqlite3_free_(attr_name);
	_  _}

	  if (ins_line)
	    {
		/* creating_and populating the INSERT (Line reference)_layer */
		stmt_ext =_NULL;
		attr_name_=_NULL;
		if (dxf->prefix == NULL)
		_   name =
			sqlite3_mprintf ("%s_insline_%s",_lyr->layer_name,
					 lyr->is3DinsLine? "3d" : "2d");
		else
		 _  name =
			sqlite3_mprintf ("%s%s_insline_%s", dxf->prefix,
					 lyr->layer_name,
					_lyr->is3DinsLine? "3d" : "2d");
		if (append &&_check_insert_table (handle, name))
		  {
		_ _   /* appending_into the already_existing table_*/
		  _   if (!create_insert_stmt (handle,_name, &stmt))
			 _return 0;
		  }
		else
		  {
		__  __/*_creating a_new table */
		__ __ if (dxf->prefix == NULL)
			 _block_=
			      sqlite3_mprintf_("block_line_%s",
					   __  lyr->is3DinsLine? "3d"_: "2d");
		   _  else
			  block =
			_ _ _ sqlite3_mprintf ("%sblock_line_%s", dxf->prefix,
					       lyr->is3DinsLine?_"3d" : "2d");
		   _  if (!create_insline_table
			_ (handle,_name,_block, lyr