コード例 #1
0
ファイル: testEx.c プロジェクト: naglalakk/Ctables
int
main(int argc, char **argv)
{
	char            p[] = "hello";
	int             size = 50;
	int             hx = 0x23;

	int             ops[MAX_OPS] = {STRICT, COLORFUL, CENTER, ENUMERATE};
	table_t        *tabl = initialize_table(ops, 2, 3);

	add(tabl, "Memory Address");
	color_me(tabl, 0, 0, RED);

	add(tabl, "Size");
	color_me(tabl, 0, 1, GREEN);

	add(tabl, "Difference");
	color_me(tabl, 0, 2, BLUE);


	/* Memory Address */
	add(tabl, cnvrtPtr(&p[0]));

	/* Size of header/pointer */
	add(tabl, cnvrtInt(size));

	/* Test Hex Values */
	add(tabl, cnvrtHex(hx));

	print(tabl);
	free_table(tabl);

	return (0);
}
コード例 #2
0
ファイル: main.c プロジェクト: adnank/RTOS
int main()
{
	int i;
	printf("Starting.....!\n");



	time_initialize();

	initialize_table();
//	printf("Initialization Table created and initialised!\n");

	init_env();
	init_timeout_Q();
	init_blkOnRsc_Q();
	init_blkOnEnv_Q();
//	printf("All Queues and Envelope Queues Initialized!\n");
    init_TraceArrays();
    init_helperprocess();
	init_ioBuffers();
	init_signals();
    printf("Initializing Signals!\n");



	init_processes();
//	printf("Initialising Processes!\n");




//	printf("KBD and CRT Processes initialized and forked!\n");

	return 0;
}
コード例 #3
0
ファイル: mp_v3.cpp プロジェクト: AT-GROUP/SatellitePackage
// Construct engine id table
v3MP::EngineIdTable::EngineIdTable(int initial_size)
{
  if (initial_size < 1)
    initial_size = 10;

  if (!initialize_table(initial_size))
  {
    LOG_BEGIN(loggerModuleName, ERROR_LOG | 0);
    LOG("v3MP::EngineIdTable: Error creating empty table.");
    LOG_END;
  }
}
コード例 #4
0
ファイル: hash_quad.c プロジェクト: XianB/DS_Algorithm
hash_table
rehash(hash_table h)
{
	int new_size = h->size * 2;
	int i = 0;
	hash_table new_ht = initialize_table(new_size);

	for (i = 0; i < h->size; i++) {
		if (h->entrys[i].status == legitimate) {
			insert(h->entrys[i].data, new_ht);
		}
	}

	return new_ht;

}
コード例 #5
0
ファイル: hash_quad_test.c プロジェクト: XianB/DS_Algorithm
int
main(int argc, char *argv[])
{
	hash_table h = initialize_table(10);
	int i = 0;
	for (i = 0; i < sizeof (datas) / sizeof (int); i++) {
		insert(datas[i], h);
	}

	for (i = 0; i < h->size; i++) {
//      printf("%d\n", h->entrys[i].data);
	}

	h = rehash(h);
	for (i = 0; i < h->size; i++) {
		printf("%d\n", h->entrys[i].data);
	}
	return 0;

}
コード例 #6
0
ファイル: main.cpp プロジェクト: phillipells/database-project
int main() {	
	
	initialize_table(); // creates the needed tables
	print_out_ui();

	char program[256];
	string str;
	while (true) {
		while (str.substr(0,1) != "0") { // skip the UI to test the engine
			cout<<"> ";
			cin.getline(program,256);
			pick_a_number(program);
			str = program;
		}
		while (true) { // skip the engine to test the UI
			cout<<"> ";
			cin.getline(program,256);
			parse(program);
			str = program;
		}
	}
}
コード例 #7
0
ファイル: SourceCodeScript.cpp プロジェクト: CQiao/DSL
//--------------------------------------------------------------------------------------
inline ActionForSourceCodeScript::ActionForSourceCodeScript(SlkToken &scanner, Dsl::DslFile& dataFile) :mScanner(&scanner), BaseType(dataFile)
{
    initialize_table();
    setEnvironmentObjRef(*this);
}
コード例 #8
0
ファイル: main.c プロジェクト: adnank/RTX
int main()
{
	jmp_buf temp;
	initialize_table();
}
コード例 #9
0
ファイル: host.c プロジェクト: rajath26/daisyFailureDetection
/*****************************************************************
 * NAME: main 
 *
 * DESCRIPTION: Main function of the leader host i.e. the contact 
 *              host that approves other hosts to join the
 *              network and the member host. This binary is 
 *              invoked via a start up script. The parameters are
 *              port no and ip address and node type.
 *              
 * PARAMETERS: 
 *            (int) argc - number of command line arguments
 *            (char *) argv - two command line arguments apart 
 *                            from argv[0] namely:
 *                            i) Port No
 *                            ii) Ip Address of host
 *                            iii) Host Type 
 *                                 "leader" -> Leader Node
 *                                 "member" -> Member Node
 *                            iv) Host ID
 * 
 * RETURN:
 * (int) ZERO if success
 *       ERROR otherwise
 * 
 ****************************************************************/
int main(int argc, char *argv[])
{

    int rc = SUCCESS,              // Return code
        i_rc;                            // Intermittent return code
        
    char leaderIpAddress[SMALL_BUF_SZ],  // Buffer to hold leader ip
         leaderPortNo[SMALL_BUF_SZ];     // Buffer to hold leader port no

    /*
     * Init log file 
     */
    i_rc = logFileCreate();
    if ( i_rc != SUCCESS )
    {
        printf("\nLog file won't be created. There was an error\n");
        rc = ERROR;
        goto rtn;
    }

    funcEntry(logF, "I am starting", "host::main");

    /*
     * Command line arguments check
     */
    i_rc = CLA_checker(argc, argv);
    if ( i_rc != SUCCESS )
    {
        rc = ERROR;
        goto rtn;
    }
       
    /*
     * Copy ip address and port no to local buffer
     */
    memset(ipAddress, '\0', SMALL_BUF_SZ);
    sprintf(ipAddress, "%s", argv[2]);
    memset(portNo, '\0', SMALL_BUF_SZ);
    sprintf(portNo, "%s", argv[1]);
    host_no = atoi(argv[4]);

    /*
     * Init local host heart beat table
     */
    initialize_table(portNo, ipAddress, host_no);
    printToLog(logF, ipAddress, "Initialized my table");

    /* 
     * Get the node type based on third argument. By default it
     * is always member node.
     */
    if ( SUCCESS == strcmp(argv[3], LEADER_STRING) )
    {
        isLeader = true;
        printToLog(logF, ipAddress, "I am the leader node");
    }
    else 
    {
        printToLog(logF, ipAddress, "I am a member node");
    }

    /* 
     * Set up UDP 
     */
    i_rc = setUpUDP(portNo, ipAddress); 
    if ( i_rc != SUCCESS )
    {
        rc = ERROR;
        printToLog(logF, ipAddress, "UDP setup failure");
        goto rtn;
    }

    // Log current status 
    printToLog(logF, ipAddress, "UDP setup successfully");

    /*
     * If current host is a LEADER then log that this host has
     * joined the distributed system
     */
    if ( isLeader )
    {
        printToLog(logF, ipAddress, "I, THE LEADER have joined the Daisy Distributed System");
    }

    /*
     * Display the CLI UI if this host is a MEMBER host which 
     * asks member if he wants to send join message to leader node
     * and calls the function requestMembershipToLeader() which
     * does the job
     */
    if ( !isLeader )
    {
        i_rc = CLI_UI();
        if ( i_rc != SUCCESS )
        {
            rc = ERROR;
            goto rtn;
        }
    }
    /* 
     * If leader ask if this a new incarnation or a 
     * reincarnation
     */
    else
    {
        i_rc = askLeaderIfRejoinOrNew();
        if ( i_rc != SUCCESS )
        {
            rc = ERROR;
            goto rtn;
        }
    }

    /* 
     * Set up infrastructure for node to leave
     * voluntarily
     */
    signal(SIGABRT, leaveSystem);
    if ( errno != SUCCESS )
    {
        printf("SIGINT set error %d \n", errno);
    }

    /*
     * Spawn the helper threads
     */
    i_rc = spawnHelperThreads();
    if ( i_rc != SUCCESS )
    {
        rc = ERROR;
        goto rtn;
    }


  rtn:
    funcExit(logF, ipAddress, "Host::main", rc);

    /*
     * Close the log
     */ 
    if ( logF != NULL )
    {
        logFileClose(logF);
    }

    return rc;

} // End of main
コード例 #10
0
ファイル: bin_table.c プロジェクト: theepot/esc64
int bin_table_new(bin_table* table, bin_table_collumn_description* collumn_descriptions, int collumns, int rows, int max_total_width, int print_on_error, int exit_on_error)
{
	table->print_on_error = print_on_error;
	table->exit_on_error = exit_on_error;
	if(rows < 1 || collumns < 1)
	{
		ERROR(table, "rows or collumns is less than 1");
		return 0;
	}
	table->rows = rows;
	table->collumns = collumns;

	size_t col_descrs_size = collumns*sizeof(bin_table_collumn_description);
	table->collumn_descriptions = malloc(col_descrs_size);
	memcpy(table->collumn_descriptions, collumn_descriptions, col_descrs_size);

	size_t cells_size = sizeof(bin_table_cell)*collumns*rows;
	table->cells = malloc(cells_size);
	if(table->cells == NULL)
	{
		ERROR(table, "could not allocate %zu bytes for table", cells_size); return 0;
	}
	
	if(max_total_width < 0)
	{
		ERROR(table, "max_total_width can not be less than zero. zero means no maximum."); return 0;
	}

	int n;
	int padding_collumn = -1;
	int total_width = 0;
	for(n = 0; n < collumns; ++n)
	{
		if(table->collumn_descriptions[n].width == -1)
		{
			if(padding_collumn == -1)
			{
				if(max_total_width != 0)
				{
					padding_collumn = n;
				}
				else
				{
					ERROR(table, "table has padding collumn but no max total width is specified"); return 0;
				}
			}
			else
			{
				ERROR(table, "table can only have one padding collumn"); return 0;
			}
		}
		else if(table->collumn_descriptions[n].width <= 0)
		{
			ERROR(table, "width of collumn can only be -1 of greater than zero"); return 0;
		}
		else
		{
			total_width += table->collumn_descriptions[n].width;
		}

		if(total_width > max_total_width)
		{
			ERROR(table, "total width of collumns is greater than the maximum total width"); return 0;
		}
	}

	if(padding_collumn != -1)
	{
		table->collumn_descriptions[padding_collumn].width = max_total_width - total_width;
	}

	//set_collumn_indices(collumn_descriptions, collumns);
	initialize_table(table);
	
	return 1;
}