本文整理汇总了C++中send_int函数的典型用法代码示例。如果您正苦于以下问题:C++ send_int函数的具体用法?C++ send_int怎么用?C++ send_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: issue_spadcommand
/* issue a AXIOM command to the buffer associated with a page */
void
issue_spadcommand(HyperDocPage *page, TextNode *command, int immediate,
int type)
{
char *buf;
int ret_val;
ret_val = connect_spad();
if (ret_val == NotConnected || ret_val == SpadBusy)
return;
if (page->sock == NULL)
start_user_buffer(page);
ret_val = send_int(page->sock, TestLine);
if (ret_val == -1) {
page->sock = NULL;
clear_execution_marks(page->depend_hash);
issue_spadcommand(page, command, immediate, type);
return;
}
issue_dependent_commands(page, command, type);
ret_val = send_int(page->sock, ReceiveInputLine);
buf = print_to_string(command);
if (immediate) {
buf[strlen(buf) + 1] = '\0';
buf[strlen(buf)] = '\n';
}
if (type == Spadsrc)
send_pile(page->sock, buf);
else
send_string(page->sock, buf);
mark_as_executed(page, command, type);
gIsEndOfOutput = 0;
}
示例2: process_execute
/*
* Send execute messae. "conn" should at the point right after the message
* kind was read.
*/
void
process_execute(char *buf, PGconn *conn)
{
int len;
char *portal;
int maxrows;
char *bufp;
SKIP_TABS(buf);
len = sizeof(int);
portal = buffer_read_string(buf, &bufp);
buf = bufp;
len += strlen(portal) + 1;
SKIP_TABS(buf);
fprintf(stderr, "FE=> Execute(portal=\"%s\")\n", portal);
SKIP_TABS(buf);
maxrows = buffer_read_int(buf, &bufp);
len += sizeof(int);
send_char('E', conn);
send_int(len, conn);
send_string(portal, conn);
send_int(maxrows, conn);
}
示例3: connect_to_local_server
Sock *
connect_to_local_server(char *server_name, int purpose, int time_out)
{
int max_con=(time_out == 0 ? 1000000 : time_out), i, code=-1;
Sock *sock;
char name[256];
make_server_name(name, server_name);
sock = (Sock *) calloc(sizeof(Sock), 1);
if (sock == NULL) {
perror("allocating socket space");
return NULL;
}
sock->purpose = purpose;
/* create the socket */
sock->socket = fricas_communication_link(FRICAS_AF_LOCAL);
if (is_invalid_socket(sock)) {
perror("opening client socket");
free(sock);
return NULL;
}
/* connect socket using name specified in command line */
memset(server[1].addr.u_addr.sa_data, 0,
sizeof(server[1].addr.u_addr.sa_data));
sock->addr.u_addr.sa_family = FRICAS_AF_LOCAL;
strcpy(sock->addr.u_addr.sa_data, name);
for(i=0; i<max_con; i++) {
code = connect(sock->socket, &sock->addr.u_addr,
sizeof(sock->addr.u_addr));
if (code == -1) {
if (
/* @@@ Why we need this */
errno != ENOENT &&
/* Needed on Cygwin, on Linux this should never happen. */
errno != EBADF &&
!fricas_connection_refused()) {
perror("connecting server stream socket");
return NULL;
} else {
if (i != max_con - 1)
fricas_sleep(40);
continue;
}
} else break;
}
if (code == -1) {
return NULL;
}
send_int(sock, getpid());
send_int(sock, sock->purpose);
send_int(sock, sock->socket);
sock->pid = get_int(sock);
/* fprintf(stderr, "Got int form socket\n"); */
sock->remote = get_int(sock);
return sock;
}
示例4: send_data_int
/* Send EV_DATA and the integer value. Return 0 on error. */
static int send_data_int (const struct client *cli, const int data)
{
assert (cli->socket != -1);
if (!send_int(cli->socket, EV_DATA) || !send_int(cli->socket, data))
return 0;
return 1;
}
示例5: decimate_header
void decimate_header() /* includefile */
{
/* go no further here if not interested in header parameters */
if (headerless) return;
/* broadcast the header parameters to the output stream */
send_string("HEADER_START");
if (!strings_equal(source_name,"")) {
send_string("source_name");
send_string(source_name);
}
send_int("telescope_id",telescope_id);
send_int("machine_id",machine_id);
send_coords(src_raj,src_dej,az_start,za_start);
if (nchans/naddc==1) {
send_int("data_type",2);
// send_double("refdm",0.0);
send_double("refdm",refdm);
/*== MKEITH: A hack to stop the dminfo being lost when decimating after dedisperse! ==*/
} else {
send_int("data_type",1);
}
send_double("fch1",fch1);
send_double("foff",foff*(double)naddc);
send_int("nchans",nchans/naddc);
send_int("nbits",obits);
send_double ("tstart",tstart);
send_double("tsamp",tsamp*(double)naddt);
send_int("nifs",nifs);
send_int("barycentric",barycentric);
send_string("HEADER_END");
}
示例6: windows_kodi_load
static void windows_kodi_load(Window *window){
// Create title TextLayer
s_title_info_layer = text_layer_create(GRect(0, 10, 144, 25));
text_layer_set_background_color(s_title_info_layer, GColorClear);
text_layer_set_text_color(s_title_info_layer, GColorRed);
text_layer_set_text(s_title_info_layer, "Kodi");
// s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_20));
// text_layer_set_font(s_title_info_layer, s_weather_font);
// Add it as a child layer to the Window's root layer
layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_title_info_layer));
// Create Movie TextLayer
s_album_info_layer = text_layer_create(GRect(0, 60, 144, 25));
text_layer_set_background_color(s_album_info_layer, GColorClear);
text_layer_set_text_color(s_album_info_layer, GColorRed);
text_layer_set_text(s_album_info_layer, "Movie");
// s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_20));
// text_layer_set_font(s_album_info_layer, s_weather_font);
// Add it as a child layer to the Window's root layer
layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_album_info_layer));
//Load action bar
action_bar_nav_h_kodi(window);
//Request info
send_int("kodi", "init");
}
示例7: vsend_int
int vsend_int(int val, int nr_of_roles, ...)
{
int rc = 0;
int i;
role *r;
va_list roles;
#ifdef __DEBUG__
fprintf(stderr, " --> %s(%d)@%d ", __FUNCTION__, val, nr_of_roles);
#endif
va_start(roles, nr_of_roles);
for (i=0; i<nr_of_roles; i++) {
r = va_arg(roles, role *);
#ifdef __DEBUG__
fprintf(stderr, " +");
#endif
rc |= send_int(val, r, NULL);
if (rc != 0) perror(__FUNCTION__);
}
va_end(roles);
#ifdef __DEBUG__
fprintf(stderr, ".\n");
#endif
return rc;
}
示例8: menu_select_callback
void menu_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) {
switch (cell_index->section) {
case 0:
switch (cell_index->row) {
case 0:
if (loading==0) carga_calendario();
break;
case 1:
if (loading==0) carga_fpp();
break;
}
break;
case 1:
switch (cell_index->row) {
case 0:
if (loading==0){
send_int(5,5);
char version[20];
time_t now = time(NULL);
struct tm *tick_time = localtime(&now);
snprintf(version, 20, "Versión: %i-%i-%i",tick_time->tm_mday,(tick_time->tm_mon)+1,(tick_time->tm_year)-100);
vibes_short_pulse();
loading = 0;
layer_mark_dirty(menu_layer_get_layer(menu_layer));
}
break;
}
break;
}
}
示例9: sock_send_int
int
sock_send_int(int purpose,int val)
{
if (accept_if_needed(purpose) != -1)
return send_int(purpose_table[purpose], val);
return -1;
}
示例10: get_client_plist
/* Handle CMD_GET_PLIST. Return 0 on error. */
static int get_client_plist (struct client *cli)
{
int first;
debug ("Client with fd %d requests the playlist", cli->socket);
/* Find the first connected client, and ask it to send the playlist.
* Here, send 1 if there is a client with the playlist, or 0 if there
* isn't. */
cli->requests_plist = 1;
first = find_sending_plist ();
if (first == -1) {
debug ("No clients with the playlist");
cli->requests_plist = 0;
if (!send_data_int(cli, 0))
return 0;
return 1;
}
if (!send_data_int(cli, 1))
return 0;
if (!send_int(clients[first].socket, EV_SEND_PLIST))
return 0;
return 1;
}
示例11: qPrintable
// send header
long NetThread::sendHeader(SOCKET sock, const char *buf, long size)
{
// 0123456789ABCDEF
char key[ENCRYPTION_KEY_LENGTH + 1] = {"@@@@@@@@@@@@@@@@"};
// copy encryption key
#if 1 // simple description
const char *encryption_key = qPrintable(settings->getPassword());
#else
const char *encryption_key = settings->getPassword().toUtf8().constData();
#endif
for (int i = 0;i < ENCRYPTION_KEY_LENGTH; i++){
if (encryption_key[i] == '\0')
break;
key[i] = encryption_key[i];
}
COM_DATA *com_data = (COM_DATA*)buf;
long data_long = com_data->data_type + (com_data->data_size & 0x0000ffff);
com_data->encryption = ENCRYPTION_OFF;
com_data->check_digit = ~data_long;
for (int i = 0; i < ENCRYPTION_KEY_LENGTH; i++){
char key_char = ~key[i];
key_char += (char)((long)i * ~com_data->check_digit);
com_data->check_digit_enc[i] = key_char;
}
//saveHeader("sentHeader.dat");
// send
return send_int(sock, buf, size, 0);
}
示例12: get_block
static int get_block(int conn, int fd, int max_size, int encrypt)
{
char *data;
long len;
int n_read, n, i, code;
recv_string(conn, &data, &len);
if (encrypt)
{
#ifdef HAVE_KRB4
char *unenc = malloc(len);
if (!unenc)
{
send_int(conn, ENOMEM);
return -1;
}
des_pcbc_encrypt((des_cblock *)data, (des_cblock *)unenc, len, sched, &ivec, 1);
for (i = 0; i < 8; i++)
ivec[i] = data[len - 8 + i] ^ unenc[len - 8 + i];
free(data);
data = unenc;
#endif
}
n_read = MIN(len, max_size);
n = 0;
while (n < n_read)
{
int n_wrote;
n_wrote = write(fd, data + n, n_read - n);
if (n_wrote == -1)
{
code = errno;
com_err(whoami, errno, "writing file (get_file)");
send_int(conn, code);
free(data);
close(fd);
return -1;
}
n += n_wrote;
}
free(data);
return n;
}
示例13: tick_callback
void tick_callback(struct tm *tick_time, TimeUnits units_changed) {
//Every five minutes
if(tick_time->tm_min % 1 == 0)
{
//Send an arbitrary message, the response will be handled by in_received_handler()
send_int(1, 1);
}
}
示例14: send_str
/*** send_str *********************************************************
Send a character string through a socket.
Input: socket - the socket to send on.
str - the string to send
Output: none.
**********************************************************************/
void send_str( int socket, char str[] )
{
int len;
len = strlen( str );
send_int( socket, len );
send_data( socket, str, len );
}
示例15: emergency_conf_select_click_callback
void emergency_conf_select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *callback_context)
{
switch(cell_index->row)
{
case 0:
send_int(0);
init();
//remove this window frmo the stack
window_stack_remove(window, false);
break;
case 1:
send_int(4);
emergency_init();
//remove this window frmo the stack
window_stack_remove(window, false);
break;
}
}