Ejemplo n.º 1
0
Archivo: ab.c Proyecto: tfarina/rsc
static void load_contacts(void) {
  while (sqlite3_step(select_stmt) == SQLITE_ROW) {
    ab_contact_t *contact = ab_contact_alloc();
    contact->id = sqlite3_column_int(select_stmt, 0);
    contact->fname = f_strdup((const char *)sqlite3_column_text(select_stmt, 1));
    contact->lname = f_strdup((const char *)sqlite3_column_text(select_stmt, 2));
    contact->email = f_strdup((const char *)sqlite3_column_text(select_stmt, 3));
    contact_list = alpm_list_add(contact_list, contact);
  }
}
Ejemplo n.º 2
0
void STC_FLASHMEM IP::configureStatic(WiFi::Network network, char const *IP, char const *netmask, char const *gateway) {
  ip_info info;
  info.ip.addr = ipaddr_addr(APtr<char>(f_strdup(IP)).get());
  info.netmask.addr = ipaddr_addr(APtr<char>(f_strdup(netmask)).get());
  info.gw.addr = ipaddr_addr(APtr<char>(f_strdup(gateway)).get());

  Critical critical;
  wifi_station_dhcpc_stop();
  wifi_softap_dhcps_stop();
  wifi_set_ip_info(network, &info);
}
Ejemplo n.º 3
0
Archivo: type.c Proyecto: kahrs/cda
void
f_type(char *s)
{
	int loop;
	Type *t, *tt;

	BLANK(s);
	if(loop = *s == '{')
		s = f_inline();
	t = NEW(Type);
	t->tt = f_strdup("");
	t->comment = "";
	do {
		if(*s == '}') break;
		switch((int)f_keymap(keys, &s))
		{
		case 1:
			t->name = f_strdup(s);
			break;
		case 2:
			t->pkgname = f_strdup(s);
			break;
		case 3:
			t->tt = f_strdup(s);
			break;
		case 4:
			t->code = f_strdup(s);
			break;
		case 5:
			t->value = f_strdup(s);
			break;
		case 6:
			t->part = f_strdup(s);
			break;
		case 7:
			t->comment = f_strdup(s);
			break;
		case 8:
			t->family = f_strdup(s);
			break;
		default:
			f_major("Type: unknown field: '%s'", s);
			break;
		}
	} while(loop && (s = f_inline()));
	if(t->name == 0){
		f_major("type with no name");
		return;
	}
	if(tt = (Type *)symlook(t->name, S_TYPE, (void *)0)){ /* test for DUP */
#define	CHK(x)	if(t->x)if(tt->x)f_minor("type %s: dup field x", t->name);else tt->x = t->x
#define	TCHK(x)	if(*t->x)if(*tt->x)f_minor("type %s: dup field x", t->name);else tt->x = t->x
		/* not name*/ CHK(pkgname); TCHK(tt);
		CHK(code); CHK(value); CHK(part);
	} else
		(void)symlook(t->name, S_TYPE, (void *)t);
}
Ejemplo n.º 4
0
 // warn: each IP in the range requires memory!
 void STC_FLASHMEM DHCPServer::configure(char const* startIP, char const* endIP, uint32_t maxLeases)
 {		
     //udhcpd_stop();
     dhcp_info info = {0};
     info.start_ip      = ipaddr_addr(APtr<char>(f_strdup(startIP)).get());
     info.end_ip        = ipaddr_addr(APtr<char>(f_strdup(endIP)).get());
     info.max_leases    = maxLeases;
     info.auto_time     = 60;
     info.decline_time  = 60;
     info.conflict_time = 60;
     info.offer_time    = 60;
     info.min_lease_sec = 60;
     dhcp_set_info(&info);
     udhcpd_start();			
 }
Ejemplo n.º 5
0
 void MTD_FLASHMEM IPAddress::operator=(char const* str)
 {
     if (!str || f_strlen(str) == 0)
         *this = IPAddress(0, 0, 0, 0);
     else
         *this = IPAddress(ipaddr_addr(APtr<char>(f_strdup(str)).get()));
 }
Ejemplo n.º 6
0
void create_ce_statistics (
    char *ce,
    char *c,
    char *file
    )
{
    file_stat *fs;
    char *fn;
    component_stat *cs;

    fn = clean_filename (file);
    cs = find_component (component);
    if (cs) {
	fs = find_filestat (cs, fn);
	if (fs == NULL) {
	    fs = malloc (sizeof (file_stat));
	    memset (fs, 0, sizeof (file_stat));
	    fs->name = f_strdup(fn);
	    if (cs->stat == NULL) {
		cs->stat = fs;
	    } else {
		fs->next = cs->stat;
		cs->stat = fs;
	    }
	}
    }
    sscanf (ce, "%f", &fs->ce);
    sscanf (c, "%d", &fs->c);
}
Ejemplo n.º 7
0
void register_missed_functions (
    char *file,
    int missed_functions
    )
{
    component_stat *cs;
    file_stat *fs;
    char *dot;

    dot = r_index (file, '.');
    if (dot) {
	*dot = '\0';
        dot = r_index (file, '.');
        if (dot) {
	    *dot = '\0';
	}
    }
    cs = find_component (component);
    if (cs) {
	fs = find_filestat (cs, file);
	if (fs == NULL) {
	    fs = malloc (sizeof (file_stat));
	    memset (fs, 0, sizeof (file_stat));
	    fs->name = f_strdup(file);
	    if (cs->stat == NULL) {
		cs->stat = fs;
	    } else {
		fs->next = cs->stat;
		cs->stat = fs;
	    }
	}
    }
    fs->mf = missed_functions;
}
Ejemplo n.º 8
0
Archivo: strdup.c Proyecto: tfarina/rsc
int main(int argc, char **argv) {
  const char *src = "hello, world";
  char *dst;

  dst = f_strdup(src);

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

  free(dst);

  return 0;
}
Ejemplo n.º 9
0
// returns IPAddress(0, 0, 0, 0) on fail
IPAddress MTD_FLASHMEM NSLookup::lookup(char const *hostname) {
  APtr<char> memHostName(f_strdup(hostname));
  addrinfo *addrinfo;
  if (lwip_getaddrinfo(memHostName.get(), NULL, NULL, &addrinfo) == 0 && addrinfo) {
    // according to lwip documentation uses only first item of "addrinfo"
    sockaddr_in *sa = (sockaddr_in *)(addrinfo->ai_addr);
    in_addr_t addr = sa->sin_addr.s_addr;
    lwip_freeaddrinfo(addrinfo);
    return IPAddress(addr);
  }
  return IPAddress(0, 0, 0, 0); // fail!
}
Ejemplo n.º 10
0
	void MTD_FLASHMEM ParameterReplacer::processInput()
	{
		char const* curc  = m_strStart;
		char const* start = curc;
		char const* curBlockKey      = NULL;
		char const* curBlockKeyEnd   = NULL;
		while (curc != m_strEnd)
		{
			char c0 = getChar(curc);
			if (c0 == '{')
			{
				char c1 = getChar(curc + 1);
				if (c1 == '{')
				{
					// found "{{"
					// push previous content
					m_result.addChunk(start, curc - start, false);
					// process parameter tag
					start = curc = replaceTag(curc);
					continue;
				}
				else if (c1 == '%')
				{
					// found "{%"
					// push previous content
					if (curBlockKey && curBlockKeyEnd)
					{
						m_result.addChunk(start, curc - start, false);
						m_blocks.add(curBlockKey, curBlockKeyEnd, m_result);
						m_result.clear();
					}
					// process block tag
					curBlockKey = extractTagStr(curc, &curBlockKeyEnd);
					start = curc = curBlockKeyEnd + 2;	// bypass "%}"
					// if this is the first block tag then this is the template file name
					if (m_template.get() == NULL)
					{
						m_template.reset(f_strdup(curBlockKey, curBlockKeyEnd));
						curBlockKey = NULL;
						curBlockKeyEnd = NULL;
					}
					continue;
				}
			}
			++curc;
		}
		m_result.addChunk(start, m_strEnd - start, false);
		if (curBlockKey && curBlockKeyEnd)
		{
			m_blocks.add(curBlockKey, curBlockKeyEnd, m_result);
			m_result.clear();
		}			
	}
Ejemplo n.º 11
0
void extract_set_component (
    char *line
    )
{
    char *ce;
    char *cs = &line[4];

    ce = strstr (line, "/bld/");
    if (ce) {
	*ce = '\0';
    }
    if ((component == NULL) || (strcmp (component, cs) != 0)) {
	component = f_strdup (cs);
	create_statistics (component);
    }
}
Ejemplo n.º 12
0
Archivo: csvget.c Proyecto: tfarina/rsc
int main(int argc, char *argv[])
{
  char *symbol;
  time_t now;
  time_t one_year_ago;
  struct tm* now_tm;
  char start_date_str[12];
  char end_date_str[12];
  buffer_t buf;
  char filename[255];

  if (argc != 2) {
    fputs("usage: csvget symbol\n", stderr);
    return 1;
  }

  symbol = f_strdup(argv[1]);

  now = time(NULL); /* get time right now */
  now_tm = localtime(&now);
  strftime(end_date_str, sizeof(end_date_str), "%F", now_tm);

  now_tm->tm_year = now_tm->tm_year - 1; /* Calculate 1 year ago date */
  strftime(start_date_str, sizeof(start_date_str), "%F", now_tm);
  one_year_ago = mktime(now_tm);

  /* TODO: Write this into a log file instead. So it can be inspected after the program ends. */
  printf("Start Date: %s\n", start_date_str);
  printf("End Date: %s\n", end_date_str);
  printf("Period: Daily\n\n");
  printf("Downloading file...\n\n");

  download_quotes_from_yahoo(symbol, one_year_ago, now, &buf);

  /* TODO: do not print this by default. */
  printf("%s\n", buf.data);

  sprintf(filename, "%s.csv", symbol);
  f_write_file(filename, buf.data, buf.length);

  return 0;
}
Ejemplo n.º 13
0
void create_be_statistics (
    char *be,
    char *b,
    char *file
    )
{
    file_stat *fs;
    char *fn;
    component_stat *cs;

    fn = clean_filename (file);
    cs = find_component (component);
    if (cs) {
	fs = find_filestat (cs, fn);
	if (fs == NULL) {
	    fs = malloc (sizeof (file_stat));
	    memset (fs, 0, sizeof (file_stat));
	    fs->name = f_strdup(fn);
	    if (cs->stat == NULL) {
		cs->stat = fs;
	    } else {
		fs->next = cs->stat;
		cs->stat = fs;
	    }
	}
    }
    sscanf (be, "%f", &fs->be);
    sscanf (b, "%d", &fs->b);
#if 0
    if ((fs->be < 80.0) && !(fs->be == 0.0 && fs->sle == 100.0)) {
	cs->files_fail_on_limit++;
    } else {
	cs->files_pass_on_limit++;
	if (missed_functions) {
	    cs->files_fail_untouched_functions++;
	}
    }
    fs->mf = missed_functions;
#endif
}