//*****************************************************************************
//
//! initDriver
//!
//!  @param  None
//!
//!  @return none
//!
//!  @brief  The function initializes a CC3000 device and triggers it to 
//!          start operation
//
//*****************************************************************************
int
initDriver(void)
{
	
	// Init GPIO's
	pio_init();
	
	//Init Spi
	init_spi();
	
	DispatcherUARTConfigure();
	
	// WLAN On API Implementation
	wlan_init( CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin);
	
	// Trigger a WLAN device
	wlan_start(0);
	
	// Turn on the LED 5 to indicate that we are active and initiated WLAN successfully
	turnLedOn(5);
	
	// Mask out all non-required events from CC3000
	wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT);
	
	// Generate the event to CLI: send a version string
	{
		char cc3000IP[50];
		char *ccPtr;
		unsigned short ccLen;
		
		DispatcherUartSendPacket((unsigned char*)pucUARTExampleAppString, sizeof(pucUARTExampleAppString));
		
		
		ccPtr = &cc3000IP[0];
		ccLen = my_itoa(PALTFORM_VERSION, ccPtr);
		ccPtr += ccLen;
		*ccPtr++ = '.';
		ccLen = my_itoa(APPLICATION_VERSION, ccPtr);
		ccPtr += ccLen;
		*ccPtr++ = '.';
		ccLen = my_itoa(SPI_VERSION_NUMBER, ccPtr);
		ccPtr += ccLen;
		*ccPtr++ = '.';
		ccLen = my_itoa(DRIVER_VERSION_NUMBER, ccPtr);
		ccPtr += ccLen;
		*ccPtr++ = '\f';
		*ccPtr++ = '\r';
		*ccPtr++ = '\0';
		
		DispatcherUartSendPacket((unsigned char*)cc3000IP, strlen(cc3000IP));
	}
	
	wakeup_timer_init();
	
	ucStopSmartConfig   = 0;
	
	return(0);
}
Пример #2
0
// Test: variable argument lists
void myprintf(const char *fmt, ...)
{
    const char *p;
    va_list argp;     // va_list is like FILE* type
    int i;
    char *s;
    char fmtbuf[256];

    va_start(argp, fmt);   // va_start is like fopen

    for(p = fmt; *p != '\0'; p++)
    {
        if(*p != '%')
        {
            putchar(*p);
            continue;
        }

        switch(*++p)
        {
            case 'c':
                i = va_arg(argp, int);
                putchar(i);
                break;

            case 'd':
                i = va_arg(argp, int);
                s = my_itoa(i, fmtbuf, sizeof(fmtbuf));
                fputs(s, stdout);
                break;

            case 's':
                s = va_arg(argp, char *);
                fputs(s, stdout);
                break;

            case 'x':
                i = va_arg(argp, int);
                s = my_itoa(i, fmtbuf, sizeof(fmtbuf));
                fputs(s, stdout);
                break;

            case '%':
                putchar('%');
                break;
        }
    }

    va_end(argp);
}
Пример #3
0
void drawMainMenu(uint8_t menuPosition){
	char *mainMenuStrings[MAIN_MENU_ITEMS] = {"Last swim", "New Swim"};
	uint8_t i, h;
	u8g_uint_t w, d;
	u8g_SetFont(&u8g, u8g_font_6x13);
	u8g_SetFontRefHeightText(&u8g);
	u8g_SetFontPosTop(&u8g);
	h = u8g_GetFontAscent(&u8g) - u8g_GetFontDescent(&u8g);
	w = u8g_GetWidth(&u8g);
	
	char vccChar[10];
	my_itoa(vcc, vccChar, 10);

	// Doing the actual drawing
	u8g_FirstPage(&u8g);
	do{
		
		for (i = 0; i < MAIN_MENU_ITEMS; i++){
			d = (w - u8g_GetStrWidth(&u8g, mainMenuStrings[i])) / 2;
			u8g_SetDefaultForegroundColor(&u8g);
			if (i == menuPosition){
				u8g_DrawBox(&u8g, 0, i*h+1, w, h);
				u8g_SetDefaultBackgroundColor(&u8g);
			}
			u8g_DrawStr(&u8g, d, i*h, mainMenuStrings[i]);
		}
		u8g_SetDefaultForegroundColor(&u8g);
		u8g_DrawFrame(&u8g, 0, 0, 128, 64);
		
		u8g_DrawStr(&u8g, 5, 50, vccChar);
	} while (u8g_NextPage(&u8g));
}
Пример #4
0
void my_assert (const char *msg, const char *file, int line) {
	char ls[10];
	my_itoa(line,ls);
	printf("%s in %s at %s\n",msg,file,ls);
	asm(" ESTOP0 ");
	while(1);
}
Пример #5
0
/*********************************************************************
* Function:         void PrintDec(BYTE toPrint)
*
* PreCondition:     none
*
* Input:		    toPrint - character to be printed. Range is 0-99
*
* Output:		    none
*
* Side Effects:	    toPrint is printed to the console in decimal
*                   
*
* Overview:		    This function will print the inputed BYTE to 
*                   the console in decimal form
*
* Note:			    Do not power down the microcontroller until 
*                   the transmission is complete or the last 
*                   transmission of the string can be corrupted.  
********************************************************************/
void PrintDec(BYTE toPrint)
{
#if defined(ENABLE_CONSOLE)
	const char* temp = my_itoa(toPrint);
	ConsolePutROMString(temp);
#endif
}
Пример #6
0
//插入sql语句字符串
char* get_query_str(int insert_size, int isReplaceInto, int pos)
{
    //printf("insert size: %d\n", insert_size);
    char *query = (char *)malloc(insert_size + 50);
    if(isReplaceInto == 0)
    {
        strcpy(query, "insert into tbl2(data) values(\"");
        int i, query_tmp_len = strlen(query);
        for(i = query_tmp_len; i < query_tmp_len + insert_size; i++)
        {
            query[i] = 't';
        }
        query[i] = '"';
        query[i + 1] = ')';
        query[i + 2] = ';';
        query[i + 3] = 0;
    }
    else
    {
        strcpy(query, "replace into tbl4 values(\"");
        char *num_str = my_itoa(pos);
        //printf("%d %s\n", pos, num_str);
        strcat(query, num_str);
        strcat(query, "\",\"");
        int i, query_tmp_len = strlen(query);
        for(i = query_tmp_len; i < query_tmp_len + insert_size; i++)
            query[i] = 't';
        query[i] = '"';
        query[i + 1] = ')';
        query[i + 2] = ';';
        query[i + 3] = 0;
    }
    return query;
}
Пример #7
0
//引数で渡ってきた数値を数字に変換し、3桁ごとにコンマを挿入
void num_conma(char* string, int num) {
	char tmp[33];

	int i;
	int length;
	int max_length;
	int tmp_i;

	//数値を数字へ
	my_itoa(tmp, num);

	//コンマを含んだ文字数を計算
	for (length = 0; tmp[length] != '\0'; length++)
		;
	max_length = length;
	max_length += (length / 3);

	if (length % 3 == 0) {
		max_length--;
	}

	//コンマなしの文字列を後ろから結果用の文字列に代入
	//3つごとにコンマを挿入する
	for (i = max_length, tmp_i = length; tmp_i >= 0; tmp_i--) {
		string[i--] = tmp[tmp_i];
		if ((length - tmp_i) % 3 == 0 && (length - tmp_i) != 0) {
			string[i--] = ',';
		}
	}
	string[max_length] = '\0';
}
Пример #8
0
/*
** fin empilage, on depile et calcul
 */
int	depile_all(t_list *op, t_list *nb)
{
  char	*operator;
  char	*nb1;
  char	*nb2;
  char	*newval;
  int	inew_val;
  
  if (my_list_size(op) > 0)
    {
      my_rev_list(&op);
      my_rev_list(&nb);
    }
  while (my_list_size(op) > 0)
    {
      nb1 = nb->data;
      depile(&nb);
      nb2=nb->data;
      depile(&nb);
      operator = op->data;
      depile(&op);
      inew_val = eval(my_getnbr(nb1), *operator, my_getnbr(nb2));
      newval = malloc(sizeof(*newval) * (digit_len(inew_val) + 1));
      my_itoa(inew_val, newval);
      my_put_in_list(&nb, newval);
      free(newval);
    }
  return (my_getnbr(nb->data));
}
Пример #9
0
int main()
{
    int n, m, cur, clen;
    char dig[16];

    scanf("%d", &n);
    while(n > 0)
    {
        printf("Original number was %d\n", n);
        
        clen = 0;
        cur = n;
        while(is_appeared(cur, clen) == FALSE)
        {
            chain[clen] = cur;

            my_itoa(cur, dig);

            qsort(dig, strlen(dig), sizeof(dig[0]), dcmp);
            n = atoi(dig);
            
            str_rev(dig);
            m = atoi(dig);

            cur = n - m;

            printf("%d - %d = %d\n", n, m, cur);
            clen++;
        }
        printf("Chain length %d\n\n", clen);
        scanf("%d", &n);
    }
    return 0;
}
Пример #10
0
void		resolv(int *i, char **tabstring, t_list **op, t_list **nb)
  {
    char	*save;
    int		new_val;
    char	*str;
    my_put_in_list(op, tabstring[*i]);
    *i =*i + 1;
    if  (is_operator(tabstring[*i]) == 0)
      my_put_in_list(nb, tabstring[*i]);
    if (is_operator(tabstring[*i]) == 3) 
      my_put_in_list(nb, parenthesis_mode(i, tabstring));
    //if (is_operator(tabstring[*i]) == 1)
    //{
    //save = malloc(sizeof(*save) * (my_strlen((*nb)->data) + 1));
    //save = (*nb)->data;
    //*i = *i + 1;
    //my_strncat(save,(*nb)->data,my_strlen((*nb)->data));
    // }
    //else 
    //{
	save = malloc(sizeof(*save) * (my_strlen((*nb)->data) + 1));
	save =(*nb)->data;
	//}
    depile(nb);
    if (my_list_size(*(nb)) == 0)
      my_put_in_list(nb, "0");
    new_val = eval(my_getnbr((*nb)->data), *(*op)->data, my_getnbr(save));
    depile(op);
    depile(nb);
    str = malloc(sizeof(*str) * (digit_len(new_val) + 1));
    my_itoa(new_val, str);
    my_put_in_list(nb, str);
    free(save);
  }
static void	show_mem_map()
{
  char		file[50];
  char		buf[BUF_SIZE];
  int		fd;
  int		ret;

  memset(&file[0], 0, 50);
  memset(&buf[0], 0, 512);
  strcpy(&file[0], "/proc/");
  my_itoa(getpid(), &file[strlen(&file[0])]);
  strcpy(&file[strlen(&file[0])], "/maps");
  fprintf(stderr, "%s\n", MEM_MAP);
  if ((fd = open(&file[0], O_RDONLY)) == FAIL
      && fprintf(stderr, EOPEN))
    return ;
  while ((ret = read(fd, &buf[0], BUF_SIZE)) > 0)
    {
      if (write(2, &buf[0], ret) < 0
	  && fprintf(stderr, "%s\n", EWRITE))
	return ;
      memset(&buf[0], 0, BUF_SIZE);
    }
  if (close(fd) == FAIL
      && fprintf(stderr, "%s\n", ECLOSE))
    return ;
}
Пример #12
0
/**
 * fpllstring: Floating point lat/lon to string.
 */
void fpllstring(float ll, int digits, char *s)
{
	long int ipart = ll;
	long int fpart = fabs((ll - ipart) * intpow(10, digits - 1));
	my_itoa(ipart, s);
	strcat(s, ".");
	my_itoa(fpart, temp_buff);
	// pad out if less than 10^d.
	int pad = digits - strlen(temp_buff);
	while(pad > 0)
	{
		strcat(s, "0");
		pad--;
	}
	strcat(s, temp_buff);
}
Пример #13
0
static char PhoneHandleSendcolormassage(char *msg)
{
	#if 1
	return(abeyant(NULL));
	#else
	char tempbuff[1024];
	char PhoneNumber[30],time[30],context[512];
	char atcmd[20]={"AT+CMGR="};
	static char k=1;
	char j;


	#ifdef DEBUG_PRINTF
	ReceiveMessageDecode("+CMGR: 1,,154\r0891683108705505F04405A10180F60008016002907294238A0500030002015C0A656C76845BA26237FF1A60A85F53524D5E1062374F59989D003100330034002E003700355143FF0C51764E2D57FA672C5E1062374F59989D003100320039002E003400385143FF0C8D6090015E1062374F59989D0035002E003200375143FF0C4E0B6B2167087ED365E54E3A0031003665E5FF0C67096548671F81F3003200300031\rOK",PhoneNumber,time,context,"+CMGL:");
	#endif


	my_itoa(&atcmd[8],k);k++;
	strcat(atcmd,"\r");
	memset(tempbuff,0,sizeof(tempbuff));
	memset(PhoneNumber,0,PhoneNumberSize);
	memset(time,0,sizeof(time));
	memset(context,0,sizeof(context));
	#ifdef DEBUG_PRINTF
	printf("atcmd=%s\n",atcmd);
	#endif
	send_at_cmd(atcmd);
	if(SendATReadDatasFromSIM300(fd_ttyS1,tempbuff,3,0)==OK){
		ReceiveMessageDecode(tempbuff,PhoneNumber,time,context,"+CMGR:");
	}
	#endif
}
Пример #14
0
int
write_new_value(uint32_t key, cl_object *key_o, cf_digest *d)
{
	uint64_t new_value_int;
	do {
		new_value_int = rand_64();
	} while (new_value_int == VALUE_UNINIT || new_value_int == VALUE_DELETED);
	
	g_config.values[key] = new_value_int;
	char new_value_str[g_config.value_len+1];
	my_itoa(new_value_str, new_value_int, g_config.value_len); 
	
	cl_bin values[1];
	strcpy(values[0].bin_name, g_config.bin);
	citrusleaf_object_init_str(&values[0].object, new_value_str);

	cl_write_parameters cl_w_p;	
	cl_write_parameters_set_default(&cl_w_p);
	cl_w_p.timeout_ms = g_config.timeout_ms;
	
	int rv;
	rv = citrusleaf_put(g_config.asc, g_config.ns, g_config.set, key_o, values, 1, &cl_w_p);
	if (rv != 0) {
		fprintf(stderr, "aerospike put returned error %d, fail digest %"PRIx64"\n",rv, *(uint64_t *)d);
		if (g_config.strict)
			return(-1);
	}
	
	citrusleaf_object_init(&values[0].object);
	
	rv = citrusleaf_verify(g_config.asc, g_config.ns, g_config.set, key_o, values, 1, g_config.timeout_ms, NULL);
	if (rv != 0) {
		fprintf(stderr, "aerospike get returned error %d digest %"PRIx64"\n",rv, *(uint64_t *)d);
		if (g_config.strict)
			return(-1);
	}

	// test!
	if (values[0].object.type != CL_STR) {
		fprintf(stderr, "read value has wrong type: expect string (3) got %d, fail digest %"PRIx64"\n",(int)values[0].object.type, *(uint64_t *)d);
		if (g_config.strict)
			return(-1);
	}
	if (strcmp(values[0].object.u.str, new_value_str) != 0) {
		fprintf(stderr, "read value does not match set value. digest %"PRIx64"\n", *(uint64_t *)d);
		fprintf(stderr, "  expecting: %s\n",new_value_str);
		fprintf(stderr, "  got: %s\n",values[0].object.u.str);
		if (g_config.strict)
			return( -1);
	}
	
	citrusleaf_object_free(&values[0].object);
	
	atomic_int_add(g_config.read_counter, 1);
	atomic_int_add(g_config.write_counter, 1);

	
	return(0);
}
Пример #15
0
int main() {
  int input = 123;
  char* output = my_itoa(input);
  printf("%d: %s\n", input, output);
  free(output);
  
  int input = -546;
  char* output = my_itoa(input);
  printf("%d: %s\n", input, output);
  free(output);
 
  input = 0;
  output = my_itoa(input);
  printf("%d: %s\n", input, output);
  free(output);

  return 0;
}
Пример #16
0
int main() {
	int x = 0x80000000;
	char s[100];
	my_itoa(x,s,22);

	printf ("s = %s\n", s);

	return 0;
}
Пример #17
0
void time_print(TIME time)
{
  char buf[17];

  my_itoa(buf,time.hour);
  print_zero(time.hour);
  lcd_printstr(buf);
  lcd_printch(':');

  my_itoa(buf,time.minute);
  print_zero(time.minute);
  lcd_printstr(buf);
  lcd_printch(':');

  my_itoa(buf,time.second);
  print_zero(time.second);
  lcd_printstr(buf);
}
Пример #18
0
static void InitialiseEditControls (HWND hwnd)
{
	INFOOFFSET infoIdx = GetSelectedStructure(hwnd);
	char szNumber[20];
	HLOCAL hmem = GetProp(hwnd, SZINFODEF);
	LPSTRUCTINFO lpinfo = LocalLock(hmem);

	bUserChangeEdit = FALSE;
	bInitEdit = TRUE;
	my_dwtoa(infoMin[infoIdx].dwRows, szNumber, 10);
	Edit_Enable(GetDlgItem(hwnd, IDC_ROWS), FALSE);
	Edit_SetText (GetDlgItem(hwnd, IDC_ROWS), szNumber);
	Edit_Enable(GetDlgItem(hwnd, IDC_ROWS), TRUE);

	my_itoa(infoMin[infoIdx].nRowWidth, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_ROWWIDTH), szNumber);

	my_dwtoa(infoMin[infoIdx].dwUniqueKeys, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_UNIQUEKEYS), szNumber);

	my_itoa(infoMin[infoIdx].nKeyWidth, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_KEYWIDTH), szNumber);

	if (lpinfo[infoIdx].fillFactors.nData != -1)
		my_itoa(lpinfo[infoIdx].fillFactors.nData, szNumber, 10);
	else
		my_itoa(infoMin[infoIdx].fillFactors.nData, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_DATA), szNumber);

	if (lpinfo[infoIdx].fillFactors.nIndex != -1)
		my_itoa(lpinfo[infoIdx].fillFactors.nIndex, szNumber, 10);
	else
		my_itoa(infoMin[infoIdx].fillFactors.nIndex, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_INDEX), szNumber);

	if (lpinfo[infoIdx].fillFactors.nLeaf != -1)
		my_itoa(lpinfo[infoIdx].fillFactors.nLeaf, szNumber, 10);
	else
		my_itoa(infoMin[infoIdx].fillFactors.nLeaf, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_LEAF), szNumber);

	if (lpinfo[infoIdx].fillFactors.nData != -1)
		SaveFillFactors.FillFactors.nData = lpinfo[infoIdx].fillFactors.nData;
	if (lpinfo[infoIdx].fillFactors.nIndex != -1)
		SaveFillFactors.FillFactors.nIndex = lpinfo[infoIdx].fillFactors.nIndex;
	if (lpinfo[infoIdx].fillFactors.nLeaf != -1)
		SaveFillFactors.FillFactors.nLeaf = lpinfo[infoIdx].fillFactors.nLeaf;

	bInitEdit = FALSE;

	LimitNumericEditControls(hwnd);

	LocalUnlock(hmem);
}
Пример #19
0
void	mksize(char size[], int isize)
{
  if (isize != 0)
    my_itoa(isize, size);
  else
    {
      size[0] = '0';
      size[1] = '\0';
    }
}
Пример #20
0
int main()
{
  char buf[20];

  itoa(INT_MIN, buf);
  printf("itoa(%d) = \"%s\"\n", INT_MIN, buf);

  my_itoa(INT_MIN, buf);
  printf("my_itoa(%d) = \"%s\"\n", INT_MIN, buf);
}
Пример #21
0
Файл: exe6.c Проект: Geovo/iCu
int main(int argc, char *argv[])
{
    // awesome code goes here:
    //printd(20);
    char nu[20];
    int p = 0;
    my_itoa(100, nu, p);
    printf("%s\n", nu);

    return 0;
}
Пример #22
0
int fill_group(t_finfo *f)
{
  struct group *grp;
  int gid;
  char *gr_name;

  gid = f->stats.st_gid;
  grp = getgrgid(gid);
  gr_name = (grp != NULL) ? grp->gr_name : my_itoa(gid);
  f->group = gr_name;
  return (my_strlen(gr_name));
}
Пример #23
0
void join_zd(t_main *main)
{
	char *number;
	int size;

	number = my_itoa((long long int)main->elem);
	size = ft_strlen(number);
	main->size += size;
	if(main->accurate != -1)
		accurate_d(size, main);
	main->print = ft_strjoin(main->print, number);
}
Пример #24
0
int fill_user(t_finfo *f)
{
  struct passwd *pwd;
  int uid;
  char *us_name;

  uid = f->stats.st_uid;
  pwd = getpwuid(uid);
  us_name = (pwd != NULL) ? pwd->pw_name : my_itoa(uid);
  f->user = us_name;
  return (my_strlen(us_name));
}
Пример #25
0
int numCmp(int left, int right)
{
	int left_size = getSize(left);
	int right_size = getSize(right);
	int result = 0;
	char *left_c = NULL, *right_c = NULL;
	char *left_tmp = my_itoa(left);
	char *right_tmp = my_itoa(right);
	left_c = malloc(sizeof(char)*(left_size + right_size + 1));
	right_c = malloc(sizeof(char)*(left_size + right_size + 1));

	strcpy_s(left_c, strlen(left_tmp) + 1, left_tmp);
	strcpy_s(right_c, strlen(right_tmp) + 1, right_tmp);
	strcat_s(left_c, left_size + right_size + 1, right_tmp);
	strcat_s(right_c, left_size + right_size + 1, left_tmp);
	result = strcmp(left_c, right_c);
	free(left_tmp);
	free(right_tmp);
	free(left_c);
	free(right_c);
	return result;
}
Пример #26
0
void showChargingScreen(void){
	char vccChar[10];
	my_itoa(vcc, vccChar, 10);
	
	u8g_FirstPage(&u8g);
	u8g_SetDefaultForegroundColor(&u8g);
	do {
		u8g_DrawFrame(&u8g, 0, 0, 128, 64);
		
		// Show the first length
		u8g_DrawStr(&u8g, (124 - u8g_GetStrWidth(&u8g, "Charging"))/2, 5, "Charging");
		u8g_DrawStr(&u8g, 60, 20, vccChar);
	} while (u8g_NextPage(&u8g));
}
Пример #27
0
char * 
printSequence (void *space, CharSequence *s, Uint cols)
{
    Uint i, c, k, pos=0, l=0, width=0;
	char *buf, *buf2;
    stringset_t *entries;

	entries=initStringset(space);	
	for (i=0; i < s->length; i++)
	{	    
	  	/*buf = ALLOCMEMORY(space, NULL, char, 32);
	    buf = my_itoa(s->sequence[i], buf, 10);*/	
		addString(space, entries, s->sequence[i], strlen(s->sequence[i]));
		if(SETSTRLEN(entries, i) > width) 
			width = SETSTRLEN(entries, i);		
	} 
	
	/*add spacer*/
	width++;
	c = cols / (width+1);
	l = (s->descrlen+2)+(s->namelen+2)+(s->length*(width+1))+((entries->noofstrings/c)*(5+1+1));
	
	buf = ALLOCMEMORY(space, NULL, char, l);
	memset(&buf[pos++], '>', 1);
	memmove(&buf[pos], s->url, s->urllen);
	pos+=s->urllen;
	memset(&buf[pos++], '\n', 1);
	memset(&buf[pos++], '>', 1);
	memmove(&buf[pos], s->alphabetname, s->namelen);
	pos+=s->namelen;
	memset(&buf[pos++], '\n', 1);
	for (i=0; i < entries->noofstrings; i++) {
		if((i%c) == 0) {
			memset(&buf[pos++], '\n', 1);	
	    	buf2 = ALLOCMEMORY(space, NULL, char, 5);
			buf2 = my_itoa(i, buf2, 10);
			memset(&buf[pos], ' ', 5-strlen(buf2));
			pos += 5-strlen(buf2);
			memmove(&buf[pos], buf2, strlen(buf2));
			pos += strlen(buf2);
			memset(&buf[pos++], '\t', 1);
			FREEMEMORY(space, buf2);
		}
	    k = (width-SETSTRLEN(entries,i));
		memset(&buf[pos], ' ', k);
		pos += k;

	  	memmove(&buf[pos], SETSTR(entries, i), SETSTRLEN(entries, i));
		pos += SETSTRLEN(entries, i);
	}
Пример #28
0
    size_t ReadsChopper::SummonButchers( size_t num )
    {
        for( size_t i = 0; i < num; i++ )
        {
            char series_num [ 10 ];
            //_itoa_s ( i , series_num , 10 );
            my_itoa( i , series_num );
            string tempname = original_file_name_ + "sub" + series_num + ".fastq";
            ofstream* temp_file_stream = new ofstream( ( dining_room_ + tempname ) );
            butchers_.push_back( temp_file_stream );
        }

        return 0;
    }
Пример #29
0
void stop_watch_print(TIME time)
{
  char buf[17];

  my_itoa(buf,time.hour);
  print_zero(time.hour);
  lcd_printstr(buf);
  lcd_printch(':');

  my_itoa(buf,time.minute);
  print_zero(time.minute);
  lcd_printstr(buf);
  lcd_printch(':');

  my_itoa(buf,time.second);
  print_zero(time.second);
  lcd_printstr(buf);

  my_itoa(buf,time.msec/10);
  lcd_printch('.');
  print_zero(time.msec/10);
  lcd_printstr(buf);
}
Пример #30
0
/**
 * Tests the coding exercises
 *
 * \param[in] argc - Command-line argument count
 * \param[in] argv - Command-line argument values array
 * \return Success/status of the program
 */
int main(int argc, char *argv[]) {
    printf("Running exercises\n");
    printf("=================\n");
    printf("\n");
    printf("arraysearch\n");
    printf("-----------\n");
    const char *array[5] = { "five", "four", "one", "three", "two" };
    test_assertion("null search string", arraysearch(array, 5, NULL) == 0);
    test_assertion("not found", arraysearch(array, 5, "six") == 0);
    test_assertion("found[5]", arraysearch(array, 5, "two") == 5);
    test_assertion("found[4]", arraysearch(array, 4, "three") == 4);
    test_assertion("found[3]", arraysearch(array, 3, "four") == 2);
    test_assertion("found[2]", arraysearch(array, 2, "five") == 1);
    test_assertion("found[1]", arraysearch(array, 1, "five") == 1);
    test_assertion("empty array", arraysearch(array, 0, NULL) == 0);
    printf("\n");
    printf("strspcmp\n");
    printf("--------\n");
    test_assertion("both null", strspcmp(NULL, NULL) == 0);
    test_assertion("s1 null", strspcmp(NULL, "foo") == -1);
    test_assertion("s2 null", strspcmp("foo", NULL) == 1);
    test_assertion("both empty", strspcmp("", "") == 0);
    test_assertion("s1 empty", strspcmp("", "foo") == -1);
    test_assertion("s2 empty", strspcmp("foo", "") == 1);
    test_assertion("s1 shorter", strspcmp("fo", "foo") == -1);
    test_assertion("s2 shorter", strspcmp("foo", "f") == 1);
    test_assertion("equal", strspcmp("a", "a") == 0);
    test_assertion("s1 first", strspcmp("a", "b") == -1);
    test_assertion("s2 first", strspcmp("b", "a") == 1);
    test_assertion("trailing space", strspcmp("a", "a ") == 0);
    test_assertion("embedded space", strspcmp("a", "a a") == -1);
    printf("\n");
    printf("my_itoa\n");
    printf("-------\n");
    test_assertion("null test", !my_itoa(7, NULL, 0));
    test_my_itoa(0, 1, "");
    test_my_itoa(0, 2, "0");
    test_my_itoa(7, 2, "7");
    test_my_itoa(21, 2, "2");
    test_my_itoa(321, 3, "32");
    test_my_itoa(321, 4, "321");
    test_my_itoa(321, 5, "321");
    test_my_itoa(321, 100, "321");
    test_my_itoa(87654321, 100, "87654321");
    printf("\n");
    printf("Done.\n");
    return 0;
}