static COMMAND_FUNC( do_set_fmt ) { int i; if( ! fmt_names_inited ) init_print_fmt_names(); i = WHICH_ONE("format",N_PRINT_FORMATS,print_fmt_name); if( i < 0 ) return; set_integer_print_fmt(QSP_ARG (Number_Fmt)i); }
long _recv_img_file(QSP_ARG_DECL Port *mpp, /* char **bufp */ Packet *pkp ) { long len; Image_File *old_ifp, *new_ifp; char namebuf[LLEN]; Image_File imgf, *ifp; long code; ifp=(&imgf); len=get_port_int32(mpp); if( len <= 0 ) goto error_return; #ifdef QUIP_DEBUG if( debug & debug_data ){ sprintf(ERROR_STRING, "recv_file: want %ld name bytes",len); advise(ERROR_STRING); } #endif /* QUIP_DEBUG */ if( (ifp->if_nfrms = get_port_int32(mpp)) == BAD_PORT_LONG || (ifp->if_ftp = filetype_for_code( QSP_ARG (filetype_code) get_port_int32(mpp))) == NULL || (ifp->if_flags = (short) get_port_int32(mpp)) == (short)BAD_PORT_LONG ){ warn("error getting image file data"); goto error_return; } if( len > LLEN ){ warn("more than LLEN name chars!?"); goto error_return; } if( read_port(mpp,namebuf,len) != len ){ warn("recv_file: error reading data object name"); goto error_return; } /* where does the string get null-terminated? */ if( (long)strlen( namebuf ) != len-1 ){ u_int i; sprintf(ERROR_STRING,"name length %ld, expected %ld", (long)strlen(namebuf), len-1); advise(ERROR_STRING); sprintf(ERROR_STRING,"name: \"%s\"",namebuf); advise(ERROR_STRING); for(i=0;i<strlen(namebuf);i++){ sprintf(ERROR_STRING,"name[%d] = '%c' (0%o)", i,namebuf[i],namebuf[i]); advise(ERROR_STRING); } error1("choked"); } old_ifp=img_file_of(namebuf); if( old_ifp != NULL ){ del_img_file(old_ifp); rls_str((char *)old_ifp->if_name); // BUG? release name here or not? old_ifp = NULL; } new_ifp=new_img_file(namebuf); if( new_ifp==NULL ){ sprintf(ERROR_STRING, "recv_file: couldn't create file struct \"%s\"", namebuf); warn(ERROR_STRING); goto error_return; } new_ifp->if_nfrms = imgf.if_nfrms; new_ifp->if_ftp = filetype_for_code(QSP_ARG IFT_NETWORK); new_ifp->if_flags = imgf.if_flags; new_ifp->if_dp = NULL; /* BUG should receive? */ new_ifp->if_pathname = new_ifp->if_name; code = get_port_int32(mpp); if( code == -1 ) error1("error port code received!?"); if( code != P_DATA ){ sprintf(ERROR_STRING, "recv_file: expected data object packet to complete transmission of file %s!?", new_ifp->if_name); error1(ERROR_STRING); } // the cast generates a compiler warning??? if( recv_obj(mpp, pkp ) != sizeof(Data_Obj) ){ warn("Error receiving data object!?"); goto error_return; } // The packet returns the dp in pk_extra... return sizeof(*new_ifp); // BUG - what size should we return??? error_return: return -1; }