Exemplo n.º 1
0
void ajout_info_liste(int fd) {
	while (lecture("entete_ref") == 1) write(fd,get_message(),size_message());
	while (liste_fichiers(".")) {
		write(fd,get_message(),size_message());
	}
	close(fd);
}
Exemplo n.º 2
0
static MuMsg*
get_message (MuMsgIter *iter, time_t after)
{
	MuMsg *msg;

	if (mu_msg_iter_is_done (iter))
		return NULL;

	msg = mu_msg_iter_get_msg_floating (iter);
	if (!msg)
		return NULL; /* error */

	if (!mu_msg_is_readable (msg)) {
		mu_msg_iter_next (iter);
		return get_message (iter, after);
	}


	if (after != 0 && after > mu_msg_get_timestamp (msg)) {
		mu_msg_iter_next (iter);
		return get_message (iter, after);
	}

	return msg;
}
Exemplo n.º 3
0
creation_message_erreur(char nom[]) {
	int fd = creation_fichier_liste("erreur.txt");
	set_message("le fichier suivant n'existe pas : "******"\n\n");
	write(fd,get_message(),size_message());
	ajout_info_liste(fd);
}
Exemplo n.º 4
0
Arquivo: BA.c Projeto: kaisert/kilobot
static void compute_rseed()
{
    int16_t seed = 0;
    seed = (get_ambient_light() + measure_voltage()) * get_ambient_light();
    srand(seed);
    message_out(rand(), rand(), rand());
    get_message();
    seed += message_rx[0] + message_rx[1] * message_rx[2] + (message_rx[3] << 2);
    srand(seed);
    message_out(rand(), rand(), rand());
    get_message();
    seed += message_rx[0] - message_rx[1] * message_rx[2] + (message_rx[3] << 2);
    srand(seed);
}
Exemplo n.º 5
0
static int
queue_ram_envelope_update(uint64_t evpid, const char *buf, size_t len)
{
	struct qr_envelope	*evp;
	struct qr_message	*msg;
	void			*tmp;

	if ((msg = get_message(evpid_to_msgid(evpid))) == NULL)
		return (0);

	if ((evp = tree_get(&msg->envelopes, evpid)) == NULL) {
		log_warn("warn: queue-ram: not found");
		return (0);
	}
	tmp = malloc(len);
	if (tmp == NULL) {
		log_warn("warn: queue-ram: malloc");
		return (0);
	}
	memmove(tmp, buf, len);
	free(evp->buf);
	evp->len = len;
	evp->buf = tmp;
	stat_decrement("queue.ram.envelope.size", evp->len);
	stat_increment("queue.ram.envelope.size", len);
	return (1);
}
Exemplo n.º 6
0
file_dialog::file_dialog(display &disp, const std::string& file_path,
		const std::string& title, bool show_directory_buttons) :
	gui::dialog(disp, title, file_path, gui::OK_CANCEL),
	show_directory_buttons_(show_directory_buttons),
	files_list_(NULL),
	last_selection_(-1),
	last_textbox_text_(),
	chosen_file_(".."),
    autocomplete_(true)
{
	files_list_ = new gui::file_menu(disp.video(), file_path);
	const unsigned file_list_height = (disp.h() / 2);
	const unsigned file_list_width = std::min<unsigned>(files_list_->width(), (disp.w() / 4));
	files_list_->set_measurements(file_list_width, file_list_height);
	files_list_->set_max_height(file_list_height);
	set_menu(files_list_);
	get_message().set_text(format_dirname(files_list_->get_directory()));
	set_textbox(_("File: "), format_filename(file_path), 100);
	if (show_directory_buttons_)
	{
		add_button( new gui::dialog_button(disp.video(), _("Delete File"),
					gui::button::TYPE_PRESS, gui::DELETE_ITEM), dialog::BUTTON_EXTRA);
		add_button( new gui::dialog_button(disp.video(), _("New Folder"),
					gui::button::TYPE_PRESS, gui::CREATE_ITEM), dialog::BUTTON_EXTRA_LEFT);
	}
}
Exemplo n.º 7
0
void py_msg_list_cb (struct tgl_state *TLSR, void *cb_extra, int success, int num, struct tgl_message *M[]) {
    assert (TLSR == TLS);
    PyObject *callable = cb_extra;
    PyObject *arglist = NULL;
    PyObject *msgs = NULL;
    PyObject *result = NULL;

    if(PyCallable_Check(callable)) {
        msgs = PyList_New(0);
        if (success) {
            int i;
            for (i = 0; i < num; i++) {
                PyList_Append(msgs, get_message (M[i]));
            }
        }

        arglist = Py_BuildValue("(OO)", success ? Py_True : Py_False, msgs);
        result = PyEval_CallObject(callable, arglist);
        Py_DECREF(arglist);

        if(result == NULL)
            PyErr_Print();

        Py_XDECREF(result);
    }

    Py_XDECREF(callable);
}
Exemplo n.º 8
0
void py_new_msg (struct tgl_message *M) {
    if (!python_loaded) {
        return;
    }
    PyObject *msg;
    PyObject *arglist, *result;

    if(_py_new_msg == NULL) {
        logprintf("Callback not set for on_new_msg");
        return;
    }

    msg = get_message (M);

    arglist = Py_BuildValue("(O)", msg);
    result = PyEval_CallObject(_py_new_msg, arglist);
    Py_DECREF(arglist);

    if(result == NULL)
        PyErr_Print();
    else if(PyUnicode_Check(result))
        logprintf ("python: %s\n", PyBytes_AsString(PyUnicode_AsASCIIString(result)));

    Py_XDECREF(result);
}
Exemplo n.º 9
0
static PyObject* python_get_message(PyObject* self, PyObject* args) {
	int arg_message_index;
	if(PyArg_ParseTuple(args, "i", &arg_message_index) == 0) return NULL;

	struct message* retval = get_message(arg_message_index);
	return Py_BuildValue("O", py_mapper_message(retval));
}
Exemplo n.º 10
0
Arquivo: ft.c Projeto: Oxyoptia/x3270
/* Process an abort from no longer being in 3270 mode. */
static void
ft_in3270(bool ignored _is_unused)
{
    if (!IN_3270 && ft_state != FT_NONE) {
	ft_complete(get_message("ftNot3270"));
    }
}
Exemplo n.º 11
0
Arquivo: ft.c Projeto: Oxyoptia/x3270
/* Process a disconnect abort. */
static void
ft_connected(bool ignored _is_unused)
{
    if (!CONNECTED && ft_state != FT_NONE) {
	ft_complete(get_message("ftDisconnected"));
    }
}
Exemplo n.º 12
0
void   
test_1(UNSIGNED argc, VOID *argv)
{
    STATUS    status;
	int ch;
	unsigned char lbuf[2048];

    /* Access argc and argv just to avoid compilation warnings.  */
    status =  (STATUS) argc + (STATUS) argv;
	
	for(;;){
		if ( ttyE_poll() == 0) {
			ch = ttyE_in();
			switch(ch){
			case 'R':
				get_message();
				break;
			}
		}
		
		NU_Sleep(10);
#if 0
	status = nflash_read_page(lbuf, 0);
#endif
	}
}
Exemplo n.º 13
0
static void on_receive (int socket_fd)
{
	printf ("enter on receive...\n");

	struct message msg;
	
	while (1)
	{
		ssize_t len = get_message (socket_fd, &msg);
		if (len < 0)
		{
			break;
		}
		/*  用户掉线或者主动退出游戏 */
		else if (len == 0)
		{
			user_offline (socket_fd);
			break;
		}
		else 
		{
			services[msg.type] (socket_fd, &msg);
		}
	}

	printf ("exit on receive...\n");
}
Exemplo n.º 14
0
Arquivo: dpid.c Projeto: epitron/dillo
/*!
 * Send socket port that matches dpi_id to client
 */
void send_sockport(int sock_fd, char *dpi_tag, struct dp *dpi_attr_list)
{
   int i;
   char *dpi_id, *d_cmd, port_str[16];
   struct service *serv;

   dReturn_if_fail((dpi_id = get_message(sock_fd, dpi_tag)) != NULL);

   serv = dList_find_custom(services_list,dpi_id,(dCompareFunc)service_match);

   if (serv == NULL || (i = serv->dp_index) == -1)
      for (i = 0; i < numdpis; i++)
         if (!strncmp(dpi_attr_list[i].id, dpi_id,
                      dpi_attr_list[i].id - strchr(dpi_attr_list[i].id, '.')))
            break;

   if (i < numdpis) {
      /* found */
      snprintf(port_str, 8, "%d", dpi_attr_list[i].port);
      d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s", "send_data", port_str);
      (void) CKD_WRITE(sock_fd, d_cmd);
      dFree(d_cmd);
   }

   dFree(dpi_id);
}
Exemplo n.º 15
0
void make_udp_action(int sock_fd, struct sockaddr_in from, int fromlen){
    printf("UDP request received\n");
    char* message = get_message();
    n = sendto(sock_fd, message, strlen(message), 0, (struct sockaddr *)&from, fromlen);
    if (n  < 0) 
	error("ERROR sendto");
}
Exemplo n.º 16
0
void clear_all_message(play_para_t *para)
{
    player_cmd_t *cmd;
    while ((cmd = get_message(para)) != NULL) {
        message_free(cmd);
    }
}
Exemplo n.º 17
0
Monitor::DisplayType PowerBookMonitor::poll() {
Monitor::DisplayType rc = None;
struct pbb_message msg;

	if (_serverPort < 0 || _clientPort < 0)
		return Error;

	// Drain the queue, send the last message
	while (0 == get_message(_clientPort, 0, &msg)) {
		switch (msg.code) {
			case DISPLAYVOLUME:
				rc = Monitor::Volume;
				_progress = msg.value;
				break;
			case DISPLAYMUTE:
				rc = Monitor::Mute;
				_progress = msg.value;
				break;
			case DISPLAYBRIGHTNESS:
				rc = Monitor::Brightness;
				_progress = msg.value*100/15;
				break;
			case REGFAILED:
			case CLIENTEXIT:
				rc = Monitor::Error;
				break;
			default:
				break;
		}
	}

return rc;
}
Exemplo n.º 18
0
Arquivo: client.c Projeto: Sconso/Irc
void				be_client(char *ip, int port)
{
	t_socket		sock;
	fd_set			rdfs;
	char			*ask;
	char			*prompt;

	sock = init_connection(ip, port);
	while (1)
	{
		init_socks(sock, &rdfs);
		if (FD_ISSET(STDIN_FILENO, &rdfs))
			client_in(sock);
		else if (FD_ISSET(sock, &rdfs))
		{
			client_out(sock);
			ask = ft_strdup("/gp\n");
			ft_send(sock, ask);
			free(ask);
			prompt = get_message(sock);
			ft_putstr("\n");
			ft_putstr(prompt);
			free(prompt);
		}
	}
}
Exemplo n.º 19
0
void parser_exception::to_stream(std::ostream& out) const {
  out << "Parse error: ";
  if (d_line != -1) {
    out << get_filename() << ":" << get_line() << ":" << get_position() << ": ";
  }
  out << get_message();
}
Exemplo n.º 20
0
void py_msg_cb (struct tgl_state *TLSR, void *cb_extra, int success, struct tgl_message *M) {
    assert (TLSR == TLS);
    PyObject *callable = cb_extra;
    PyObject *arglist = NULL;
    PyObject *msg = NULL;
    PyObject *result = NULL;

    if(PyCallable_Check(callable)) {
        if (success && M && (M->flags & TGLMF_CREATED)) {
            msg = get_message(M);
        } else {
            Py_INCREF(Py_None);
            msg = Py_None;
        }

        arglist = Py_BuildValue("(OO)", success ? Py_True : Py_False, msg);
        result = PyEval_CallObject(callable, arglist);
        Py_DECREF(arglist);

        if(result == NULL)
            PyErr_Print();

        Py_XDECREF(result);
    }

    Py_XDECREF(callable);
}
Exemplo n.º 21
0
void RecordChannel::push_frame(uint8_t *frame)
{
    RecordSamplesMessage *message;
    ASSERT(_frame_bytes == FRAME_SIZE * 4);
    if (!(message = get_message())) {
        DBG(0, "blocked");
        return;
    }
    uint8_t celt_buf[CELT_COMPRESSED_FRAME_BYTES];
    int n;

    if (_mode == SPICE_AUDIO_DATA_MODE_CELT_0_5_1) {
        n = celt051_encode(_celt_encoder, (celt_int16_t *)frame, NULL, celt_buf,
                           CELT_COMPRESSED_FRAME_BYTES);
        if (n < 0) {
            THROW("celt encode failed");
        }
        frame = celt_buf;
    } else {
        n = _frame_bytes;
    }
    RedPeer::OutMessage& peer_message = message->peer_message();
    peer_message.reset(SPICE_MSGC_RECORD_DATA);
    SpiceMsgcRecordPacket packet;
    packet.time = get_mm_time();
    _marshallers->msgc_record_data(peer_message.marshaller(), &packet);
    spice_marshaller_add(peer_message.marshaller(), frame, n);
    post_message(message);
}
Exemplo n.º 22
0
int list_properties(DBusConnection *connection, char *function,
			char *service_name)
{
	DBusMessage *message;

	message = get_message(connection, function);
	if (message == NULL)
		return -ENOMEM;

	if (strcmp(function, "GetProperties") == 0)
		extract_manager_properties(message);

	else if (strcmp(function, "GetServices") == 0 && service_name != NULL)
		extract_services(message, service_name);

	else if (strcmp(function, "GetServices") == 0 && service_name == NULL)
		get_services(message);

	else if (strcmp(function, "GetTechnologies") == 0)
		extract_tech(message);

	dbus_message_unref(message);

	return 0;
}
Exemplo n.º 23
0
//c'est le vrai main. le coeur du service
void lancement_service(int ta_socket) {

	int n;
	int choix;
	choix = 1;
	char mMessage[TLIM] = "";
	char reponse[TLIM] = "";
	char nom[TLIM] = "";
	if ((n=read(ta_socket, nom, TLIM-1))>0);
	else strcpy(nom,"sombre inconnu");
	liste_referentiel(ta_socket);
	while (choix) {
		n = lecture_s(ta_socket);
		if (sscanf(get_message(),"%s",mMessage)>0) {
			while ((n=lecture(mMessage))==1) {
				ecriture_s(ta_socket);
			}
			if (n<0) {
				creation_message_erreur(mMessage);
				diffusion_erreur(ta_socket);
				//while (lecture("erreur.txt") == 1) ecriture_s(ta_socket);
			}
		}
		if (!strcmp(mMessage,"q") || !strcmp(mMessage,"Q")) {
			choix = 0;
			quitter(ta_socket);
		}
	}
}
Exemplo n.º 24
0
static int
queue_ram_envelope_create(uint32_t msgid, const char *buf, size_t len,
    uint64_t *evpid)
{
	struct qr_envelope	*evp;
	struct qr_message	*msg;

	if ((msg = get_message(msgid)) == NULL)
		return (0);

	do {
		*evpid = queue_generate_evpid(msgid);
	} while (tree_check(&msg->envelopes, *evpid));
	evp = calloc(1, sizeof *evp);
	if (evp == NULL) {
		log_warn("warn: queue-ram: calloc");
		return (0);
	}
	evp->len = len;
	evp->buf = malloc(len);
	if (evp->buf == NULL) {
		log_warn("warn: queue-ram: malloc");
		free(evp);
		return (0);
	}
	memmove(evp->buf, buf, len);
	tree_xset(&msg->envelopes, *evpid, evp);
	stat_increment("queue.ram.envelope.size", len);
	return (1);
}
Exemplo n.º 25
0
void on_receive (int fd)
{
	struct message msg;

	while (1)
	{
		ssize_t len = get_message (&msg);
		if (len < 0)
		{
			break;
		}
		else if (len == 0)
		{
			show_message_dialog (GTK_MESSAGE_ERROR, "服务器掉线了\n");
			exit (-1);
		}
		else
		{
			g_print ("on_recive: msgtype = %d\n",msg.type);
			gdk_threads_enter ();
			services[msg.type] (fd, &msg);
			gdk_threads_leave ();
		}
	}
}
Exemplo n.º 26
0
/**************************************************************************
...
**************************************************************************/
static void meswin_row_activated_callback(GtkTreeView *view,
					  GtkTreePath *path,
					  GtkTreeViewColumn *col,
					  gpointer data)
{
  struct message *pmsg;
  GtkTreeModel *model;
  GtkTreeIter iter;
  gint row;

  model = gtk_tree_view_get_model(view);
  if (!gtk_tree_model_get_iter(model, &iter, path)) {
    return;
  }

  gtk_tree_model_get(model, &iter, 2, &row, -1);
  pmsg = get_message(row);

  meswin_double_click(row);
  meswin_set_visited(&iter, TRUE);

  gui_dialog_set_response_sensitive(meswin_shell, CMD_GOTO,
                                    pmsg->location_ok);
  gui_dialog_set_response_sensitive(meswin_shell, CMD_POPCITY,
                                    pmsg->city_ok);
}
DLL_EXPORT int Iterate(void *client, int max_messages) {
    CConceptClient *CC = (CConceptClient *)client;
    if (CC) {
        int messages = 0;
        TParameters PARAM;
        CC->SendPending();
        while ((max_messages) && (!CC->IsEOF())) {
            PARAM.Owner = CC;
            PARAM.UserData = 0;
            PARAM.Flags = 0;
            int res = get_message(CC, &PARAM, (PROGRESS_API)CC->notify);
            if (res == -2)
                return messages;
            if (res <= 0)
                return -1;
            if (CC->NON_OPAQUE_CONCEPT_CALLBACK)
                CC->NON_OPAQUE_CONCEPT_CALLBACK(&PARAM);
            else
            if (CC->CONCEPT_CALLBACK)
                CC->CONCEPT_CALLBACK(client, PARAM.Sender.c_str(), PARAM.Sender.Length(), PARAM.ID, PARAM.Target.c_str(), PARAM.Target.Length(), PARAM.Value.c_str(), PARAM.Value.Length());
            CC->SendPending();
            messages++;
            max_messages--;
        }
        return messages;
    }
    return -1;
}
Exemplo n.º 28
0
int main(int argc, char *argv[])
{
    char *msg;
    size_t msglen;
    int operation;

    switch (argc) {
    case 1:
        operation = OP_COMPRESS;
        break;
    case 2:
        if (strcmp(argv[1], "-d") == 0) {
            operation = OP_DECOMPRESS;
            break;
        }
    default:
        err_use(argv[0]);
    }

    msglen = get_message(&msg);

    if (operation == OP_COMPRESS)
        b64pack_compress(msg, &msglen);
    else
        b64pack_decompress(msg, &msglen);

    put_message(msg, msglen);

    exit(EXIT_SUCCESS);
}
Exemplo n.º 29
0
Arquivo: main.cpp Projeto: CCJY/coliru
cat >main.cpp <<EOF
#include "message.h"
#include <iostream>

              int main()
{
    std::cout << get_message() << std::endl;
}
Exemplo n.º 30
0
void dy_despatch_thread(jd_var *arg) {
  dy_info("Starting despatcher");
  for (;;) scope {
    JD_VAR(msg);
    get_message(msg);
    dy_despatch_message(msg);
  }
}