int h_put_data ( pfi char_out, int a[], int nx, int ny, char *format ) { /* void pr_format_message(); */ /* static int put_raw(); */ /* static int put_fits(); */ if ( streq( format, "raw" ) || streq( format, "hhh" ) ) { PR_CHECK( put_raw( char_out, a, nx, ny, FALSE ) ); } else if ( streq( format, "net") ) { PR_CHECK( put_raw( char_out, a, nx, ny, TRUE ) ); } else if (streq( format, "fits" ) ) { PR_CHECK( put_fits( char_out, a, nx, ny ) ); } else { pr_format_message( PR_E_FORMAT ); return( PR_E_FORMAT ); } return( PR_SUCCESS ); }
void SslSocket::connect(const std::string& host, uint16_t port) const { std::stringstream namestream; namestream << host << ":" << port; connectname = namestream.str(); void* arg = SslOptions::global.certName.empty() ? 0 : const_cast<char*>(SslOptions::global.certName.c_str()); NSS_CHECK(SSL_GetClientAuthDataHook(socket, NSS_GetClientAuthData, arg)); NSS_CHECK(SSL_SetURL(socket, host.data())); char hostBuffer[PR_NETDB_BUF_SIZE]; PRHostEnt hostEntry; PR_CHECK(PR_GetHostByName(host.data(), hostBuffer, PR_NETDB_BUF_SIZE, &hostEntry)); PRNetAddr address; int value = PR_EnumerateHostEnt(0, &hostEntry, port, &address); if (value < 0) { throw Exception(QPID_MSG("Error getting address for host: " << ErrorString())); } else if (value == 0) { throw Exception(QPID_MSG("Could not resolve address for host.")); } PR_CHECK(PR_Connect(socket, &address, PR_INTERVAL_NO_TIMEOUT)); }
static int put_fits ( pfi char_out, int a[], int nx, int ny ) { void pr_foramt_message(); int n; short *sa; int status; /* * write data with swapping */ PR_CHECK( put_raw( char_out, a, nx, ny, TRUE) ); /* * add zeroes to get up to multiple of 2880 bytes * number of padding short ints to write is between 0 and 1439 */ n = 1439 - ( ( nx * ny - 1 ) % 1440 ); status = PR_SUCCESS; if ( n > 0 ) { /* * allocate a block of zeros */ PR_CHECK_NULL( sa = (short *) calloc( n , sizeof( short ) ) ); status = char_out( sa, n * sizeof( short ) ); gen_free( sa ); } return( status ); }
static int put_raw ( pfi char_out, int a[], int nx, int ny, boolean swap ) { void h_swap_bytes(); boolean test_swap(); int i; int j; int k; short *sa; /* Working array for swaped data. */ boolean tswap; /* is byte swaping required? */ int v; /* * see if byte-swapping will be needed */ if (swap) { tswap = test_swap(); } else { tswap = 0; } /* * write a row at a time to minimize page faulting problems */ PR_CHECK_NULL( sa = short_alloc( ny ) ); for ( i = 0; i < nx ; i++ ) { k = i * ny; for ( j = 0; j < ny; j++) { /* * force value into 16-bit integer range */ v = a[k++]; if (v < -32768) { sa[j] = -32768; } else if (v > 32767) { sa[j] = 32767; } else { sa[j] = v; } } if ( tswap ) { h_swap_bytes( sa, ny * sizeof( short ) ); } PR_CHECK( char_out( sa, ny * sizeof( short ) ) ); } gen_free(sa); return( PR_SUCCESS ); }