void Init_tokyo_messenger(){
  mTokyoMessenger = rb_define_module("TokyoMessenger");
  eTokyoMessengerError = rb_define_class("TokyoMessengerError", rb_eStandardError);
  init_mod();

  cDB = rb_define_class_under(mTokyoMessenger, "DB", rb_cObject);
  rb_include_module(cDB, mTokyoMessenger);
  init_db();

  cTable = rb_define_class_under(mTokyoMessenger, "Table", rb_cObject);
  rb_include_module(cTable, mTokyoMessenger);
  init_table();

  cQuery = rb_define_class_under(mTokyoMessenger, "Query", rb_cObject);
  init_query();
}
/* Generate a query string from a collection and query parameters. */
GString*
xmms_collection_get_query (xmms_coll_dag_t *dag, xmmsv_coll_t *coll,
                           guint limit_start, guint limit_len,
                           xmmsv_t *order, xmmsv_t *fetch, xmmsv_t *group)
{
	GString *qstring;
	coll_query_t *query;
	coll_query_params_t params = { limit_start, limit_len, order, fetch, group };

	query = init_query (&params);
	xmms_collection_append_to_query (dag, coll, query);
	add_fetch_group_aliases (query, &params);

	qstring = xmms_collection_gen_query (query);

	destroy_query (query);

	return qstring;
}
int mca_topo_base_find_available(bool enable_progress_threads,
                                 bool enable_mpi_threads)
{
    opal_list_item_t *item, *next;
    mca_base_component_list_item_t *cli;

    /* The list of components which we should check is already present 
       in ompi_topo_base_framework.framework_components, which was established in 
       mca_topo_base_open */

    item = opal_list_get_first(&ompi_topo_base_framework.framework_components);
    while (item != opal_list_get_end(&ompi_topo_base_framework.framework_components)) {
        next = opal_list_get_next(item);
         cli = (mca_base_component_list_item_t*)item;

         /* Now for this entry, we have to determine the thread level. Call 
            a subroutine to do the job for us */

         if (OMPI_SUCCESS != init_query(cli->cli_component, cli,
                                        enable_progress_threads,
                                        enable_mpi_threads)) {
             /* The component does not want to run, so close it. Its close()
                has already been invoked. Close it out of the DSO repository
                (if it is there in the repository) */
             mca_base_component_repository_release(cli->cli_component);
             opal_list_remove_item(&ompi_topo_base_framework.framework_components, item);
             OBJ_RELEASE(item);
         }
         item = next;
     }

     /* There should at least be one topo component available */
    if (0 == opal_list_get_size(&ompi_topo_base_framework.framework_components)) {
         opal_output_verbose (10, ompi_topo_base_framework.framework_output,
                              "topo:find_available: no topo components available!");
         return OMPI_ERROR;
     }

    /* All done */
    return OMPI_SUCCESS;
}
Beispiel #4
0
void init_subsystems(){
 init_cal();
 init_cli_macro();
 init_clipboard();
 init_commandline();
 init_evilloop();
 init_exec_cmd();
 init_expanded();
 init_file();
 init_file_ascii();
 init_file_help();
 init_file_hnb();
 init_file_html();
 init_file_opml();
 init_file_ps();
 init_file_xml();
 init_go();
 init_insertbelow();
 init_keepstate();
 init_mem();
 init_movenode();
 init_nodetest();
 init_outdent_indent();
 init_prefs();
 init_query();
 init_quit();
 init_remove();
 init_search();
 init_sort();
 init_spell();
 init_stats();
 init_tree_todo();
 init_ui_binding();
 init_ui_cli();
 init_ui_draw();
 init_ui_edit();
 init_ui_menu();
 init_ui_overlay();
 init_ui_style();
}
/*
 * Scan down the list of successfully opened components and query each of
 * them (the opened list will be one or more components.  If the user
 * requested a specific component, it will be the only component in the
 * opened list).  Create and populate the available list of all
 * components who indicate that they want to be considered for selection.
 * Close all components who do not want to be considered for selection,
 * and destroy the opened list.
 *
 * Also find the basic component while we're doing all of this, and save
 * it in a global variable so that we can find it easily later (e.g.,
 * during scope selection).
 */
int mca_coll_base_find_available(bool enable_progress_threads,
                                 bool enable_mpi_threads)
{
  bool found = false;
  mca_base_component_priority_list_item_t *entry;
  opal_list_item_t *p;
  const mca_base_component_t *component;

  /* Initialize the list */

  OBJ_CONSTRUCT(&mca_coll_base_components_available, opal_list_t);
  mca_coll_base_components_available_valid = true;

  /* The list of components that we should check has already been
     established in mca_coll_base_open. */
  
  for (found = false, 
         p = opal_list_remove_first(&mca_coll_base_components_opened);
       p != NULL;
       p = opal_list_remove_first(&mca_coll_base_components_opened)) {
    component = ((mca_base_component_list_item_t *) p)->cli_component;

    /* Call a subroutine to do the work, because the component may
       represent different versions of the coll MCA. */
    
    entry = OBJ_NEW(mca_base_component_priority_list_item_t);
    entry->super.cli_component = component;
    entry->cpli_priority = 0;
    if (OMPI_SUCCESS == init_query(component, entry, 
                                   enable_progress_threads,
                                   enable_mpi_threads)) {
        opal_list_append(&mca_coll_base_components_available, 
                         (opal_list_item_t *) entry);
        found = true;
    } else {
      
      /* If the component doesn't want to run, then close it.  It's
         already had its close() method invoked; now close it out of
         the DSO repository (if it's there). */
      
      mca_base_component_repository_release(component);
      OBJ_RELEASE(entry);
    }

    /* Free the entry from the "opened" list */

    OBJ_RELEASE(p);
  }

  /* The opened list is now no longer useful and we can free it */
    
  OBJ_DESTRUCT(&mca_coll_base_components_opened);
  mca_coll_base_components_opened_valid = false;

  /* If we have no collective components available, it's an error.
     Thanks for playing! */
    
  if (!found) {
    /* Need to free all items in the list */
    OBJ_DESTRUCT(&mca_coll_base_components_available);
    mca_coll_base_components_available_valid = false;
    opal_output_verbose(10, mca_coll_base_output,
                       "coll:find_available: no coll components available!");
    orte_show_help("help-mca-base", "find-available:none-found", true,
                   "coll");
    return OMPI_ERROR;
  }

  /* All done */

  return OMPI_SUCCESS;
}
/*
 * Scan down the list of successfully opened components and query each of
 * them (the opened list will be one or more components.  If the user
 * requested a specific component, it will be the only component in the
 * opened list).  Create and populate the available list of all
 * components who indicate that they want to be considered for selection.
 * Close all components who do not want to be considered for selection,
 * and destroy the opened list.
 *
 * It is *not* an error if there are no io components available.
 * Appropriate run-time MPI exceptions will be invoked during
 * MPI_FILE_OPEN and MPI_FILE_DELETE.
 */
int mca_io_base_find_available(bool enable_progress_threads,
                               bool enable_mpi_threads)
{
    int err;
    mca_base_component_priority_list_item_t *entry;
    opal_list_item_t *p;
    const mca_base_component_t *component;

    /* Initialize the list */

    OBJ_CONSTRUCT(&mca_io_base_components_available, opal_list_t);
    mca_io_base_components_available_valid = true;

    /* The list of components that we should check has already been
       established in mca_io_base_open. */

    for (p = opal_list_remove_first(&mca_io_base_components_opened);
            p != NULL;
            p = opal_list_remove_first(&mca_io_base_components_opened)) {
        component = ((mca_base_component_list_item_t *) p)->cli_component;

        /* Call a subroutine to do the work, because the component may
           represent different versions of the io MCA. */

        entry = OBJ_NEW(mca_base_component_priority_list_item_t);
        entry->super.cli_component = component;
        entry->cpli_priority = 0;
        if (OMPI_SUCCESS == init_query(component, entry,
                                       enable_progress_threads,
                                       enable_mpi_threads)) {

            /* Save the results in the list.  The priority isn't
               relevant, because selection is decided at
               communicator-constructor time.  But we save the thread
               arguments (set in the init_query() function) so that
               the initial selection algorithm can negotiate the
               overall thread level for this process. */

            opal_list_append(&mca_io_base_components_available,
                             (opal_list_item_t *) entry);
        } else {

            /* If the component doesn't want to run, then close it.
               It's already had its close() method invoked; now close
               it out of the DSO repository (if it's there). */

            mca_base_component_repository_release(component);
            OBJ_RELEASE(entry);
        }

        /* Free the entry from the "opened" list */

        OBJ_RELEASE(p);
    }

    /* The opened list is now no longer useful and we can free it */

    OBJ_DESTRUCT(&mca_io_base_components_opened);
    mca_io_base_components_opened_valid = false;

    /* Setup the freelist */

    if (OMPI_SUCCESS != (err = mca_io_base_request_create_freelist())) {
        return err;
    }

    /* All done */

    return OMPI_SUCCESS;
}
Beispiel #7
0
int main(int argc, char** argv) {
	int tmpresult = 0,i=0,prlen=0,txtlen=0;
	char tmpbuf[50],tmpbuf2[50];

	DEBUG_flag = 1;
	init_structures();
	tmpresult = init_query(TRUE);
	if (!tmpresult) {
		sys.error = ERR_SYSINITIALIZE;
		printf("init_query fail\n");
		printf("FAIL\n");
	}
	memset(tmpbuf,0,50);
	memset(tmpbuf2,0,50);
	if (argc >= 2) {
		tmpresult = mode2_detect(argv[1]);
		if (!tmpresult) {
			sys.error = ERR_UNKNOWNMODE;
			printf("FAIL\n");
		}
	} else {
		sys.error = ERR_UNKNOWNMODE;
		printf("FAIL\n");
	}
	switch (sys.mode) {
		case MODE_TEST:
			printf("send BEEP request\n");
			tmpbuf[0] = CMD_BEEP;
			process_qmes(tmpbuf,1);
			break;
		case MODE_STOP:
			printf("send QMSG_ABORT_S request\n");
			send_qmessage(QMSG_ABORT_S, getpid(), 1, query.qbody.message);
			for (i=0;i<100;i++) {
				if (recv_qmessage(QMSG_ABORT_R)) break;
				usleep(1000);
			}
			break;
		case MODE_PTEST:
			printf("send PTESTPAGE request\n");
			tmpbuf[0] = CMD_TEST;
			process_qmes(tmpbuf,1);
			break;
		case MODE_OPENSMENA:
			printf("send OPEN_SMENA request\n");
			tmpbuf[0] = CMD_OPENSMENA;
			process_qmes(tmpbuf,1);
			break;
		case MODE_CLOSESMENA:
			printf("send CLOSE_SMENA request\n");
			tmpbuf[0] = CMD_CLOSESMENA;
			process_qmes(tmpbuf,1);
			break;
		case MODE_NEWPAYMENT:
			if (argc >= 4) {
				/*printf("send PRINTTITLE request\n");
				tmpbuf[0] = CMD_PRINTTITLE;
				tmpresult = process_qmes(tmpbuf,1);
				if (!tmpresult) break;*/

				printf("send OPEN_CHECK request\n");
				tmpbuf[0] = CMD_OPENCHECK;
				tmpresult = process_qmes(tmpbuf,1);
				if (!tmpresult) break;

				tmpresult = printfile();
				if (!tmpresult) break;

				printf("send SALE request\n");
				// FORMAT:
				// Price:50, text:MTS
				// <SALE>	<Price length>	<Price chars>		<Text length>	<Text chars>
				// 0		1				2...2+price length	price length+3	price length+4...price length+4+text length
				// [0]=SALE;[1]=2;[2]=5;[3]=0;[4]=3;[5]=M;[6]=T;[7]=S;
				tmpbuf[0] = CMD_SALE;
				prlen = strlen(argv[2]);
				tmpbuf[1] = prlen; //price length
				for (i=0;i<prlen;i++) {
					tmpbuf[2+i] = argv[2][i]; //price chars
				}
				txtlen = strlen(argv[3]);
				printf("text length: %d\n",txtlen);
				tmpbuf[2+prlen] = txtlen; // text message len
				for (i=0;i<txtlen;i++) {
					tmpbuf[3+prlen+i] = argv[3][i]; // text mesage
				}
				tmpresult = process_qmes(tmpbuf,3+prlen+txtlen);
				if (!tmpresult) break;
				printf("send CLOSE_CHECK request\n");
				memset(tmpbuf,0,50);
				tmpbuf[0] = CMD_CLOSECHECK;
				tmpbuf[1] = prlen;
				for (i=0;i<prlen;i++) {
					tmpbuf[2+i] = argv[2][i]; //price chars
				}
				txtlen = strlen(argv[3]);
				printf("text length: %d\n",txtlen);
				tmpbuf[2+prlen] = txtlen; // text message len
				for (i=0;i<txtlen;i++) {
					tmpbuf[3+prlen+i] = argv[3][i]; // text mesage
				}
				tmpresult = process_qmes(tmpbuf,3+prlen+txtlen);
			} else {
				sys.error = ERR_TOOSHORTPARAM;
				printf("unknown mode\n");
			}
			break;
		case MODE_SELFTEST:
			printf("send SELFTEST request\n");
			tmpbuf[0] = CMD_SELFTEST;
			process_qmes(tmpbuf,1);
			break;
		case MODE_GETMODE:
			printf("send GETMODE request\n");
			tmpbuf[0] = CMD_GETMODE;
			process_qmes(tmpbuf,1);
			if (query.qbody.message[0] != FALSE) {
				printf("MODE:%d;\n", query.qbody.message[0]);
				return 1;
			}
		case MODE_INCASS:
			printf("send INCASS request\n");
			tmpbuf[0] = CMD_INCASS;
			process_qmes(tmpbuf,1);
			break;
		case MODE_REPEAT:
			printf("send REPEAT request\n");
			tmpbuf[0] = CMD_REPEAT;
			process_qmes(tmpbuf,1);
			break;
		default:
			printf("unknown mode\n");
	}
	if (query.qbody.message[0] == TRUE) {
		printf("DONE\n");
	} else {
		printf("FAIL\n");
	}
	return 1;
}
int mca_topo_base_find_available(bool enable_progress_threads,
                                 bool enable_mpi_threads)
{
    bool found = false;
    mca_base_component_priority_list_item_t *entry;
    opal_list_item_t *p;

    /* Initialize the list */

    OBJ_CONSTRUCT(&mca_topo_base_components_available, opal_list_t);
    mca_topo_base_components_available_valid = true;

    /* The list of components which we should check is already present 
       in mca_topo_base_components_opened, which was established in 
       mca_topo_base_open */

     for (found = false, 
            p = opal_list_remove_first (&mca_topo_base_components_opened);
          NULL != p;
          p = opal_list_remove_first (&mca_topo_base_components_opened)) {
         entry = OBJ_NEW(mca_base_component_priority_list_item_t);
         entry->super.cli_component =
           ((mca_base_component_list_item_t *)p)->cli_component;

         /* Now for this entry, we have to determine the thread level. Call 
            a subroutine to do the job for us */

         if (OMPI_SUCCESS == init_query(entry->super.cli_component, entry,
                                        enable_progress_threads,
                                        enable_mpi_threads)) {
             /* Save the results in the list. The priority is not relvant at 
                this point in time. But we save the thread arguments so that
                the initial selection algorithm can negotiate overall thread
                level for this process */
             entry->cpli_priority = 0;
             opal_list_append (&mca_topo_base_components_available,
                               (opal_list_item_t *) entry);
             found = true;
         } else {
             /* The component does not want to run, so close it. Its close()
                has already been invoked. Close it out of the DSO repository
                (if it is there in the repository) */
             mca_base_component_repository_release(entry->super.cli_component);
             OBJ_RELEASE(entry);
         }
         /* Free entry from the "opened" list */
         OBJ_RELEASE(p);
     }

     /* The opened list is no longer necessary, so we can free it */
     OBJ_DESTRUCT (&mca_topo_base_components_opened);
     mca_topo_base_components_opened_valid = false;

     /* There should atleast be one topo component which was available */
     if (false == found) {
         /* Need to free all items in the list */
         OBJ_DESTRUCT(&mca_topo_base_components_available);
         mca_topo_base_components_available_valid = false;
         opal_output_verbose (10, mca_topo_base_output,
                              "topo:find_available: no topo components available!");
         return OMPI_ERROR;
     }

     /* All done */
     return OMPI_SUCCESS;
}