static boolean reinit_results(TDSSOCKET * tds, size_t num_cols, const struct metadata_t meta[]) { TDSRESULTINFO *info; int i; assert(tds); assert(num_cols); assert(meta); tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; if ((info = alloc_results(num_cols)) == NULL) return false; tds_set_current_results(tds, info); if (tds->cur_cursor) { tds_free_results(tds->cur_cursor->res_info); tds->cur_cursor->res_info = info; tdsdump_log(TDS_DBG_INFO1, "set current_results to cursor->res_info\n"); } else { tds->res_info = info; tdsdump_log(TDS_DBG_INFO1, "set current_results (%u column%s) to tds->res_info\n", (unsigned) num_cols, (num_cols==1? "":"s")); } tdsdump_log(TDS_DBG_INFO1, "setting up %u columns\n", (unsigned) num_cols); for (i = 0; i < num_cols; i++) { set_result_column(tds, info->columns[i], meta[i].name, &meta[i].col); info->columns[i]->bcp_terminator = (char*) meta[i].pacross; /* overload available pointer */ } if (num_cols > 0) { static char dashes[31] = "------------------------------"; tdsdump_log(TDS_DBG_INFO1, " %-20s %-15s %-15s %-7s\n", "name", "size/wsize", "type/wtype", "utype"); tdsdump_log(TDS_DBG_INFO1, " %-20s %15s %15s %7s\n", dashes+10, dashes+30-15, dashes+30-15, dashes+30-7); } for (i = 0; i < num_cols; i++) { TDSCOLUMN *curcol = info->columns[i]; tdsdump_log(TDS_DBG_INFO1, " %-20s %7d/%-7d %7d/%-7d %7d\n", tds_dstr_cstr(&curcol->column_name), curcol->column_size, curcol->on_server.column_size, curcol->column_type, curcol->on_server.column_type, curcol->column_usertype); } #if 1 /* all done now allocate a row for tds_process_row to use */ if (TDS_FAILED(tds_alloc_row(info))) return false; #endif return true; }
int main (int argc, char *argv[]) { int i, j, pos ; double a,b,f, dx,dy ; long mat ; msgout = stderr ; fr = stdin ; if (argc > 1) { if ((fr = fopen(argv[1],"r")) == NULL) { fprintf(stderr,"Tensor Scale Analysis:\n Use: %s input_file output_file fea_file\n",argv[0]); exit (-1) ; } } if (read_data (fr) != 0) { exit (-1); } if ((y_div <24)&&(x_div<70)) { fprintf(msgout,"\ninput data:\n"); for (j=0; j<y_div; j++) { for (i=0; i<x_div; i++) { #if 1 fprintf(msgout," %li", m_fld[m_pos(i+1,j+1)]); #else fprintf(msgout," %li", m_pos(i+1,j+1)); #endif } fprintf(msgout,"\n"); } } if (alloc_big_data () != 0) { exit (-1); } if (alloc_line_coords () != 0) { exit (-1); } if (alloc_results () != 0) { exit (-1); } dx = x_siz / ((double) x_div) ; dy = y_siz / ((double) y_div) ; pos = 0 ; for (j=0; j<y_div; j++) { for (i=0; i<x_div; i++) { compute_abf( x_siz + 0.5*dx + ((double)i)*dx, y_siz + 0.5*dy + ((double)j)*dy, &ts_mat[pos], &ts_a[pos], &ts_b[pos], &ts_f[pos]); pos++ ; } } compute_abf(3*x_siz/2, 3*y_siz/2, &mat, &a, &b, &f); fprintf(msgout," A=%e B=%e Angle=%e\n",a,b,f); if (argc > 2) { if ((fw = fopen(argv[2],"w")) == NULL) { fw = stdout ; } printf("[[%s]] (%li)\n", argv[2], ts_len); } else { fw = stdout ; } comp_global(&ksi, &h, 0); printf("ksi = %e. h =%e\n", ksi, h); write_data(fw) ; if (argc > 3) { if ((fwe = fopen(argv[3],"w")) == NULL) { fwe = stdout ; } export_data_ufem(fwe); fclose(fwe); } printf("--------------------\n"); compute_g_abf(stdout) ; fclose(fw); fclose(fr); return(0); }