예제 #1
0
파일: mems.c 프로젝트: wtsync/mems
int main(int argc, char *argv[])
{
    unsigned char *mem = NULL;
    unsigned int page = 0, pos = 0;
    unsigned int offset = 0, data = 0;

    if(argc != 3) {
        printf("vocore command, used to set data to core.\n");
        printf("usage: mems offset [data: 32bits]\n");
        return 0;
    }

    // offset = atou(argv[1]) + 0x10000000;
    offset = atou(argv[1]);
    data = atou(argv[2]);

    printf("offset: 0x%08X, data: 0x%08X\n", offset, data);
    page = offset / PAGE_SIZE;
    pos = offset % PAGE_SIZE;

    mem = mmap_page(page);
    if(mem == NULL) {
        printf("can not map memory.\n");
        return -1;
    }

    printf("old: 0x%08X\n", *(unsigned int *)(mem + pos));
    *((unsigned int *)(mem + pos)) = data;
    printf("new: 0x%08X\n", *(unsigned int *)(mem + pos));

    munmap(mem, PAGE_SIZE);
    return 0;
}
예제 #2
0
/**
 * set current time by buffer hhmmss
 */
void set_time(uint8_t *buf){
	inline uint8_t atou(uint8_t *b){
		return (b[0]-'0')*10 + b[1]-'0';
	}
	uint8_t H = atou(buf) + TIMEZONE_GMT_PLUS;
	if(H > 23) H -= 24;
	current_time.H = H;
	current_time.M = atou(&buf[2]);
	current_time.S = atou(&buf[4]);
}
static void *get_salt(char *ciphertext)
{
	char *ctcopy = strdup(ciphertext);
	char *keeptr = ctcopy;
	int i;
	char *p;
	static struct custom_salt cs;
	memset(&cs, 0, sizeof(cs));
	ctcopy += 15;	/* skip over "$cloudkeychain$" */
	p = strtokm(ctcopy, "$");
	cs.saltlen = atoi(p);
	p = strtokm(NULL, "$");
	for (i = 0; i < cs.saltlen; i++)
		cs.salt[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16
			+ atoi16[ARCH_INDEX(p[i * 2 + 1])];
	p = strtokm(NULL, "$");
	cs.iterations = atou(p);
	p = strtokm(NULL, "$");
	cs.masterkeylen = atoi(p);
	p = strtokm(NULL, "$");
	for (i = 0; i < cs.masterkeylen; i++)
		cs.masterkey[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16
			+ atoi16[ARCH_INDEX(p[i * 2 + 1])];
	p = strtokm(NULL, "$");
	cs.plaintextlen = atou(p);
	p = strtokm(NULL, "$");
	cs.ivlen = atoi(p);
	p = strtokm(NULL, "$");
	for (i = 0; i < cs.ivlen; i++)
		cs.iv[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16
			+ atoi16[ARCH_INDEX(p[i * 2 + 1])];
	p = strtokm(NULL, "$");
	cs.cryptextlen = atoi(p);
	p = strtokm(NULL, "$");
	for (i = 0; i < cs.cryptextlen; i++)
		cs.cryptext[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16
			+ atoi16[ARCH_INDEX(p[i * 2 + 1])];
	p = strtokm(NULL, "$");
	cs.expectedhmaclen = atoi(p);
	p = strtokm(NULL, "$");
	for (i = 0; i < cs.expectedhmaclen; i++)
		cs.expectedhmac[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16
			+ atoi16[ARCH_INDEX(p[i * 2 + 1])];

	p = strtokm(NULL, "$");
		cs.hmacdatalen = atoi(p);
	p = strtokm(NULL, "$");
	for (i = 0; i < cs.hmacdatalen; i++)
		cs.hmacdata[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16
			+ atoi16[ARCH_INDEX(p[i * 2 + 1])];
	MEM_FREE(keeptr);
	return (void *)&cs;
}
예제 #4
0
Logger::Logger(std::ostream* stream) :
    mStream(stream),
    mCategory(~0u),
    mPriority(Error)
{
    // Set some defaults from the environment
    unsigned value = atou(std::getenv("OPENFDM_DEBUG_PRIORITY"));
    if (value)
        mPriority = value;

    value = atou(std::getenv("OPENFDM_DEBUG_CATEGORY"));
    if (value)
        mCategory = value;
}
예제 #5
0
int dictionarywordLineSplit(char line[], char word[], unsigned int *nr, char *acl_allow, char *acl_denied) {
	int splits;
	char **data;

	if ((splits = split(line, " ", &data)) < 3) {
		saafree(data);
		return 0;
	}

	strlcpy(word, data[0], maxWordlLen);
	free(data[0]);
	*nr = atou(data[1]);
	free(data[1]);
	strlcpy(acl_allow, data[2], DICT_ACL_LENGTH);
	free(data[2]);
	if (splits == 4) {
		strlcpy(acl_denied, data[3], DICT_ACL_LENGTH);
		free(data[3]);
	} else if (splits == 3) {
		acl_denied[0] = '\0';
	}

	free(data);
	
	return 1;
}
static void *get_salt(char *ciphertext)
{
	static salt_t cs;
	uint8_t salt[MAX_SALT_SIZE+1+4+1];
	char *p;
	int saltlen;
	char delim;

	if (!strncmp(ciphertext, FORMAT_TAG, sizeof(FORMAT_TAG) - 1))
		ciphertext += sizeof(FORMAT_TAG) - 1;
	else if (!strncmp(ciphertext, FORMAT_TAG2, sizeof(FORMAT_TAG2) - 1))
		ciphertext += sizeof(FORMAT_TAG2) - 1;
	else if (!strncmp(ciphertext, FORMAT_TAG3, sizeof(FORMAT_TAG3) - 1))
		ciphertext += sizeof(FORMAT_TAG3) - 1;
	else
		error(); /* Can't happen - caught in valid() */
	memset(&cs, 0, sizeof(cs));
	cs.rounds = atou(ciphertext);
	delim = strchr(ciphertext, '.') ? '.' : '$';
	ciphertext = strchr(ciphertext, delim) + 1;
	p = strchr(ciphertext, delim);
	saltlen = 0;
	while (ciphertext < p) {        /** extract salt **/
		salt[saltlen++] =
			atoi16[ARCH_INDEX(ciphertext[0])] * 16 +
			atoi16[ARCH_INDEX(ciphertext[1])];
		ciphertext += 2;
	}
	// we append the count and EOM here, one time.
	memcpy(&salt[saltlen], "\x0\x0\x0\x1\x80", 5);
	memcpy(cs.salt, salt, saltlen+5);
	cs.length = saltlen+5; // we include the x80 byte in our saltlen, but the .cl kernel knows to reduce saltlen by 1

	return (void *)&cs;
}
예제 #7
0
int __start(void)
{
    int whichfd = atou(__com32.cs_cmdline);
    static com32sys_t inreg, outreg;	/* In bss, so zeroed automatically */
    int retry;

    for (retry = 0; retry < 6; retry++) {
	printf(">");
	inreg.eax.w[0] = 0x0201;	/* Read one sector */
	inreg.ecx.w[0] = 0x0001;	/* Cyl 0 sector 1 */
	inreg.edx.b[1] = 0;	/* Head 0 */
	inreg.edx.b[0] = whichfd;	/* Drive number */
	inreg.es = SEG(__com32.cs_bounce);	/* Read into the bounce buffer */
	inreg.ebx.w[0] = OFFS(__com32.cs_bounce);
	__com32.cs_intcall(0x13, &inreg, &outreg);

	if ((outreg.eflags.l & 1) == 0)
	    break;
    }

    if ((outreg.eflags.l & 1) == 0) {
	printf("!\n");
	inreg.eax.w[0] = 0x000d;
	inreg.edx.w[0] = 0;
	inreg.edi.l = (uint32_t) __com32.cs_bounce;
	inreg.ecx.l = 512;
	inreg.ebx.l = whichfd & 0xff;
	inreg.esi.l = 0;	/* No partitions */
	inreg.ds = 0;		/* No partitions */
	__com32.cs_intcall(0x22, &inreg, NULL);
    }

    /* If we get here, badness happened */
    return 255;
}
예제 #8
0
파일: 7z_fmt_plug.c 프로젝트: mimaun/Rose
static int isdecu(char *q)
{
	char buf[24];
	unsigned int x = atou(q);
	sprintf(buf, "%u", x);
	return !strcmp(q,buf);
}
예제 #9
0
uint32_t JPWiFly::getoptInt(int opt, uint8_t base) {
	String buf;

	if (!getopt(opt, buf))
		return 0;

	if (base == DEC)
		return atou(buf.c_str());
	else
		return atoh(buf.c_str());
}
예제 #10
0
int *
scan_unsigned_list (string l)
{
    string map;
    unsigned length = 1;
    int *vector = xmalloc (sizeof (int));

    for (map = strtok (l, ","); map != NULL; map = strtok (NULL, ","))
    {
        length++;
        vector = xrealloc (vector, length * sizeof (int));
        vector[length - 2] = atou (map);
        if (vector[length - 2] < 0)
            WARNING1 ("Unsigned number %u is too large", vector[length - 2]);
    }

    vector[length - 1] = -1;
    return vector;
}
예제 #11
0
파일: 7z_fmt_plug.c 프로젝트: mimaun/Rose
static void *get_salt(char *ciphertext)
{
	char *ctcopy = strdup(ciphertext);
	char *keeptr = ctcopy;
	int i;
	char *p;

	static union {
		struct custom_salt _cs;
		ARCH_WORD_32 dummy;
	} un;
	struct custom_salt *cs = &(un._cs);

	memset(cs, 0, SALT_SIZE);

	ctcopy += 4;
	p = strtok(ctcopy, "$");
	cs->type = atoi(p);
	p = strtok(NULL, "$");
	cs->NumCyclesPower = atoi(p);
	p = strtok(NULL, "$");
	cs->SaltSize = atoi(p);
	p = strtok(NULL, "$"); /* salt */
	p = strtok(NULL, "$");
	cs->ivSize = atoi(p);
	p = strtok(NULL, "$"); /* iv */
	for (i = 0; i < cs->ivSize; i++)
		cs->iv[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16
			+ atoi16[ARCH_INDEX(p[i * 2 + 1])];
	p = strtok(NULL, "$"); /* crc */
	cs->crc = atou(p); /* unsigned function */
	p = strtok(NULL, "$");
	cs->length = atoi(p);
	p = strtok(NULL, "$");
	cs->unpacksize = atoi(p);
	p = strtok(NULL, "$"); /* crc */
	for (i = 0; i < cs->length; i++)
		cs->data[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16
			+ atoi16[ARCH_INDEX(p[i * 2 + 1])];
	MEM_FREE(keeptr);
	return (void *)cs;
}
// ============================================================
int main( const int nArg, const char *aArg[] )
{
    prime_t max = (nArg > 1)
        ? (prime_t) atou( aArg[ 1 ] )
//      :        6; // Test for 6i+1 > max
//      :    65536; // [  6,541] =    65,521 // Release:  0.006 secs
//      :   100000; // [  9,592] =    99,991 // Release:  0.010 secs
//      :   611953; // [ 49,999] =   611,953 // Release:  0.121 secs First 50,000 primes
//      :  1000000; // [ 78,497] =   999,983 // Release:  0.241 secs
        : 10000000; // [664,578] = 9,999,991 // Release:  6.21  secs
//      : 15485863; // one millionth prime   // Release: 11.57  secs One millionth prime

    AllocArray ( max );
    TimerStart ( max );
    BuildPrimes( max );
    TimerStop  ( max );
    getchar();
    PrintPrimes();
    DeleteArray();

    return 0;
}
예제 #13
0
파일: ixfr.c 프로젝트: corretgecom/mydns-ng
static taskexec_t
ixfr_purge_all_soas(TASK *t, void *data) {

  /*
   * Retrieve all zone id's that have deleted records.
   *
   * For each zone get the expire field and delete any records that have expired.
   *
   */

  SQL_RES	*res = NULL;
  SQL_ROW	row = NULL;

  size_t	querylen;
  const char	*QUERY0 =	"SELECT DISTINCT zone FROM %s WHERE active='%s'";
  const char	*QUERY1 = 	"SELECT origin FROM %s "
				"WHERE id=%u;";
  const char	*QUERY2 =	"DELETE FROM %s WHERE zone=%u AND active='%s' "
				" AND stamp < DATE_SUB(NOW(),INTERVAL %u SECOND);";
  char		*query = NULL;

  /*
   * Reset task timeout clock to some suitable value in the future
   */
  t->timeout = current_time + ixfr_gc_interval;	/* Try again e.g. tomorrow */

  querylen = sql_build_query(&query, QUERY0,
			     mydns_rr_table_name, mydns_rr_active_types[2]);

  if (!(res = sql_query(sql, query, querylen)))
    ErrSQL(sql, "%s: %s", desctask(t),
	   _("error loading zone id's for DELETED records"));

  RELEASE(query);

  while((row = sql_getrow(res, NULL))) {
    unsigned int	id = atou(row[0]);
    char		*origin = NULL;
    MYDNS_SOA		*soa = NULL;
    SQL_RES		*sres = NULL;

    querylen = sql_build_query(&query, QUERY1,
			       mydns_soa_table_name, id);

    if (!(res = sql_query(sql, query, querylen)))
      ErrSQL(sql, "%s: %s", desctask(t),
	     _("error loading zone from DELETED record zone id"));

    RELEASE(query);

    if (!(row = sql_getrow(res, NULL))) {
      Warnx(_("%s: no soa found for soa id %u"), desctask(t),
	    id);
      continue;
    }

    origin = row[0];

    if (mydns_soa_load(sql, &soa, origin) == 0) {
      querylen = sql_build_query(&query, QUERY2,
				 mydns_rr_table_name, soa->id, mydns_rr_active_types[2], soa->expire);

      if (sql_nrquery(sql, query, querylen) != 0)
	WarnSQL(sql, "%s: %s %s", desctask(t),
		_("error deleting expired records for zone "), soa->origin);

      RELEASE(query);

      sql_free(sres);
    }
  }

  sql_free(res);
  RELEASE(query);     

  return (TASK_CONTINUE);
}
예제 #14
0
////////////////////////////////////////////////////////////////////////////////////
// Interface function used when receiving a VCI command on the target port
// As the dated transactions on the VCI target port are used to update the local
// time when all DMA channels are IDLE, this component requires periodical
// NULL messages from the interconnect. 
////////////////////////////////////////////////////////////////////////////////////
tmpl(tlm::tlm_sync_enum)::nb_transport_fw ( tlm::tlm_generic_payload &payload,
                                            tlm::tlm_phase           &phase, 
                                            sc_core::sc_time         &time)   
{
    size_t  cell;
    size_t  reg;
    size_t  channel;

    soclib_payload_extension* extension_pointer;
    payload.get_extension(extension_pointer);
    
    // Compute global state
    bool all_idle = true;
    for( size_t k = 0 ; k < m_channels ; k++ )
    {
        if( m_state[k] != STATE_IDLE ) all_idle = false;
    }

    // update local time if all channels IDLE 
    if ( all_idle and  (m_pdes_local_time->get().value() < time.value()) )
    {
        m_pdes_local_time->set( time );
    }

    // No other action on NULL messages
    if ( extension_pointer->is_null_message() ) 
    {

#if SOCLIB_MODULE_DEBUG
std::cout << "[" << name() << "] time = "  << time.value() 
          << " Receive NULL message" << std::endl;
#endif
        return tlm::TLM_COMPLETED;
    }

    // address and length checking for a VCI command
    bool	one_flit = (payload.get_data_length() == 4);
    addr_t	address = payload.get_address();

    if ( m_segment.contains(address) && one_flit )
    {
        cell    = (size_t)((address - m_segment.baseAddress()) >> 2);
        reg     = cell % DMA_SPAN;
        channel = cell / DMA_SPAN;

        // checking channel overflow
        if ( channel < m_channels ) payload.set_response_status(tlm::TLM_OK_RESPONSE);
        else             payload.set_response_status(tlm::TLM_GENERIC_ERROR_RESPONSE);

        if ( extension_pointer->get_command() == VCI_READ_COMMAND )
        {

#if SOCLIB_MODULE_DEBUG
std::cout << "[" << name() << "] time = "  << time.value() 
          << " Receive VCI read command : address = " << std::hex << address
          << " / channel = " << std::dec << channel
          << " / reg = "  << reg << std::endl;
#endif
        
            if ( reg == DMA_SRC )
            {
                utoa( m_source[channel], payload.get_data_ptr(), 0 );
            }
            else if ( reg == DMA_DST )
            {
                utoa( m_destination[channel], payload.get_data_ptr(), 0 );
            }
            else if ( reg == DMA_LEN )
            {
                utoa( m_state[channel], payload.get_data_ptr(), 0 );
            }
            else if ( reg == DMA_IRQ_DISABLED ) 
            {
                utoa( (int)(m_irq_disabled[channel]), payload.get_data_ptr(), 0 );
            }
            else    payload.set_response_status(tlm::TLM_GENERIC_ERROR_RESPONSE);
        } // end read

        else if (extension_pointer->get_command() == VCI_WRITE_COMMAND)
        {
            uint32_t data = atou(payload.get_data_ptr(), 0);

#if SOCLIB_MODULE_DEBUG
std::cout << "[" << name() << "] time = "  << time.value() 
          << " Receive VCI write command : address = " << std::hex << address
          << " / channel = " << std::dec << channel
          << " / reg = "  << reg 
          << " / data = " << data << std::endl;
#endif
            // configuration command other than soft reset
            // are ignored when the DMA channel is active
            if ( reg == DMA_RESET )
            {
                m_stop[channel] = true;
            }
            else if ( m_state[channel] != STATE_IDLE )
            {
                if      ( reg == DMA_SRC )  m_source[channel]      = data;
                else if ( reg == DMA_DST )  m_destination[channel] = data;
                else if ( reg == DMA_LEN ) 
                {
                    m_length[channel] = data;
                    m_stop[channel]   = false;
                    m_event.notify();
                }
                else if ( cell == DMA_IRQ_DISABLED )  m_irq_disabled[channel] = (data != 0);
                else    payload.set_response_status(tlm::TLM_GENERIC_ERROR_RESPONSE);
            }
            else
            {
                std::cout << name() 
                << " warning: receiving a new command while busy, ignored" << std::endl;
            }
        } // end if write
        else // illegal command
        {
            payload.set_response_status(tlm::TLM_GENERIC_ERROR_RESPONSE);
        }
    } // end if legal address 
예제 #15
0
파일: conf.c 프로젝트: shangyanjin/mydns-ng
/**************************************************************************************************
	LOAD_CONFIG
	Load the configuration file.
**************************************************************************************************/
void
load_config(void) {
    int		n;
    struct passwd *pwd = NULL;
    struct group	*grp = NULL;

    /* Load config */
    conf_load(&Conf, opt_conf);

    /* Set defaults */
    for (n = 0; defConfig[n].name; n++) {
        if (defConfig[n].name[0] == '-' || !defConfig[n].value)
            continue;
        if (!conf_get(&Conf, defConfig[n].name, NULL))
            conf_set(&Conf, defConfig[n].name, defConfig[n].value, 1);
    }

    /* Support "mysql-user" etc. for backwards compatibility */
    if (conf_get(&Conf, "mysql-host", NULL))
        conf_set(&Conf, "db-host", conf_get(&Conf, "mysql-host", NULL), 0);
    if (conf_get(&Conf, "mysql-user", NULL))
        conf_set(&Conf, "db-user", conf_get(&Conf, "mysql-user", NULL), 0);
    if (conf_get(&Conf, "mysql-pass", NULL))
        conf_set(&Conf, "db-password", conf_get(&Conf, "mysql-pass", NULL), 0);
    if (conf_get(&Conf, "mysql-password", NULL))
        conf_set(&Conf, "db-password", conf_get(&Conf, "mysql-password", NULL), 0);

#if HAVE_GETPWUID
    /* Set default for database username to real username if none was provided */
    if (!conf_get(&Conf, "db-user", NULL)) {
        struct passwd *pwd2;

        if ((pwd2 = getpwuid(getuid())) && pwd2->pw_name) {
            conf_set(&Conf, "db-user", pwd2->pw_name, 0);
            memset(pwd2, 0, sizeof(struct passwd));
        }
    }
#endif

    /* Load user/group perms */
    if (!(pwd = getpwnam(conf_get(&Conf, "user", NULL))))
        Err(_("error loading uid for user `%s'"), conf_get(&Conf, "user", NULL));
    perms_uid = pwd->pw_uid;
    perms_gid = pwd->pw_gid;
    memset(pwd, 0, sizeof(struct passwd));

    if (!(grp = getgrnam(conf_get(&Conf, "group", NULL))) && !(grp = getgrnam("nobody"))) {
        Warnx(_("error loading gid for group `%s'"), conf_get(&Conf, "group", NULL));
        Warnx(_("using gid %lu from user `%s'"), (unsigned long)perms_gid, conf_get(&Conf, "user", NULL));
    } else {
        perms_gid = grp->gr_gid;
        memset(grp, 0, sizeof(struct group));
    }

    /* We call conf_set_logging() again after moving into background, but it's called here
       to report on errors. */
    conf_set_logging();

    /* Set global options */
    task_timeout = atou(conf_get(&Conf, "timeout", NULL));

    axfr_enabled = GETBOOL(conf_get(&Conf, "allow-axfr", NULL));
    Verbose(_("AXFR is %senabled"), (axfr_enabled)?"":_("not "));

    tcp_enabled = GETBOOL(conf_get(&Conf, "allow-tcp", NULL));
    Verbose(_("TCP ports are %senabled"), (tcp_enabled)?"":_("not "));

    dns_update_enabled = GETBOOL(conf_get(&Conf, "allow-update", NULL));
    Verbose(_("DNS UPDATE is %senabled"), (dns_update_enabled)?"":_("not "));

    mydns_soa_use_active = GETBOOL(conf_get(&Conf, "use-soa-active", NULL));
    mydns_rr_use_active = GETBOOL(conf_get(&Conf, "use-rr-active", NULL));

    dns_notify_enabled = dns_update_enabled && GETBOOL(conf_get(&Conf, "notify-enabled", NULL));
    Verbose(_("DNS NOTIFY is %senabled"), (dns_notify_enabled)?"":_("not "));
    notify_timeout = atou(conf_get(&Conf, "notify-timeout", NULL));
    notify_retries = atou(conf_get(&Conf, "notify-retries", NULL));
    notify_algorithm = conf_get(&Conf, "notify-algorithm", NULL);

    dns_ixfr_enabled = GETBOOL(conf_get(&Conf, "ixfr-enabled", NULL));
    Verbose(_("DNS IXFR is %senabled"), (dns_ixfr_enabled)?"":_("not "));
    ixfr_gc_enabled = GETBOOL(conf_get(&Conf, "ixfr-gc-enabled", NULL));
    ixfr_gc_interval = atou(conf_get(&Conf, "ixfr-gc-interval", NULL));
    ixfr_gc_delay = atou(conf_get(&Conf, "ixfr-gc-delay", NULL));

    mydns_rr_extended_data = GETBOOL(conf_get(&Conf, "extended-data-support", NULL));

    mydns_dbengine = conf_get(&Conf, "dbengine", NULL);

    wildcard_recursion = atoi(conf_get(&Conf, "wildcard-recursion", NULL));

    ignore_minimum = GETBOOL(conf_get(&Conf, "ignore-minimum", NULL));

    /* Set table names if provided */
    mydns_set_soa_table_name(conf_get(&Conf, "soa-table", NULL));
    mydns_set_rr_table_name(conf_get(&Conf, "rr-table", NULL));

    /* Set additional where clauses if provided */
    mydns_set_soa_where_clause(conf_get(&Conf, "soa-where", NULL));
    mydns_set_rr_where_clause(conf_get(&Conf, "rr-where", NULL));

    /* Set recursive server if specified */
    conf_set_recursive();

#ifdef DN_COLUMN_NAMES
    dn_default_ns = conf_get(&Conf, "default-ns", NULL);
#endif
}
예제 #16
0
void
#ifdef STANDALONE_SERVER
main (int argc, char *argv[])
{
  unsigned window_size;
  string identity; /* This will be the contents of the identity_atom */
#else /* not STANDALONE_SERVER */
start_server (unsigned window_size, string identity)
{
#endif /* not STANDALONE_SERVER */

  XTextProperty textP;
  Widget viewport_widget;
  int zero = 0;
  
  /* This routine will intercept messages we get.  */
  XtActionsRec actions[] = { { "MessageHandler", message_handler } };
  
  /* Here we assume that all the characters will fit in an em square. 
     (We make further assumptions below.)  The TFM format guarantees
     that the design size is not negative.  Values in the resource
     database override this.  These initial values are only useful if we
     are not standalone, but we reassign just below if we are
     standalone.  */
  Arg geometry_args[]
    = { { XtNheight, window_size },
        { XtNwidth,  window_size },
      };

#ifdef STANDALONE_SERVER
  if (argc == 3)
    {
      window_size = atou (argv[1]);
      geometry_args[0].value = geometry_args[1].value = window_size;
      identity = argv[2];
    }
  else
    {
      fprintf (stderr, "Usage: %s window-size identity.\n", argv[0]);
      exit(0);
    }
#endif /* STANDALONE_SERVER */

  /* We have no fallback resources, and we've already parsed the args.  */
  top_level = XtInitialize (NULL, CLASS_NAME, NULL, 0, &zero, NULL);

  viewport_widget
    = XtCreateManagedWidget ("viewport", viewportWidgetClass, top_level,
	                     NULL, 0); 
  canvas_widget
    = XtCreateManagedWidget ("canvas", labelWidgetClass, viewport_widget,
                             geometry_args, XtNumber (geometry_args));

  XtAddActions (actions, XtNumber (actions));

  XtRealizeWidget (top_level);
  
  display = XtDisplay (top_level);

  foserver_exit_atom = XInternAtom (display, FOSERVER_EXIT_ATOM, False);
  foserver_update_pixmap_atom
    = XInternAtom (display, FOSERVER_UPDATE_PIXMAP_ATOM, False);

  /* Get the identity atom number. Create it if it doesn't exist.  */
  foserver_identity_atom
    = XInternAtom (display, FOSERVER_IDENTITY_ATOM, False);

  textP.value = (unsigned char *) identity; /* Set value.  */
  textP.encoding = XA_STRING;
  textP.format = 8;
  textP.nitems = strlen (identity);
  XSetTextProperty (display, XtWindow (canvas_widget), &textP,
                    foserver_identity_atom);

  /* Process events forever.  */
  XtMainLoop ();
}
예제 #17
0
파일: conf.c 프로젝트: shangyanjin/mydns-ng
/**************************************************************************************************
	DUMP_CONFIG
	Output configuration info (in a sort of config-file format).
**************************************************************************************************/
void
dump_config(void) {
    time_t	time_now = time(NULL);
    int		len = 0, w = 0, n, defaulted;
    char		pair[512], buf[80];
    CONF		*c;

    /*
    **	Pretty header
    */
    puts("##");
    puts("##  "MYDNS_CONF);
    printf("##  %.24s\n", ctime(&time_now));
    printf("##  %s\n", _("For more information, see mydns.conf(5)."));
    puts("##");

    /*
    ** Get longest words
    */
    for (n = 0; defConfig[n].name; n++) {
        const char *value = conf_get(&Conf, defConfig[n].name, &defaulted);

        c = &defConfig[n];
        if (!c->value || !c->value[0])
            continue;
        if (!value) {
            if ((len = strlen(c->name) + (c->value ? strlen(c->value) : 0)) > w)
                w = len;
        } else {
            char *cp, *vbuf, *v;
            if (!strcasecmp(c->name, "listen") || !strcasecmp(c->name, "no-listen")) {
                while ((cp = strchr(value, ',')))
                    *cp = CONF_FS_CHAR;
            }
            vbuf = STRDUP(value);
            for (cp = vbuf; (v = strsep(&cp, CONF_FS_STR));)
                if ((len = strlen(c->name) + strlen(v)) > w)
                    w = len;
            RELEASE(vbuf);
        }
    }
    w += strlen(" = ");

    /*
    **	Output name/value pairs
    */
    for (n = 0; defConfig[n].name; n++) {
        const char	*value = conf_get(&Conf, defConfig[n].name, &defaulted);

        c = &defConfig[n];

        if (c->name[0] == '-') {
            printf("\n\n%-*.*s\t# %s\n\n", w, w, " ", _(c->desc));
            continue;
        }

        if (!value) {
            if (!c->value || !c->value[0])
                continue;
            value = c->value;
            defaulted = 1;
        }

        /* Pick between "nobody" and "nogroup" for default group */
        if (!strcasecmp(c->name, "group") && getgrnam("nogroup"))
            c->value = V_("nogroup");

        /* If cache-size/cache-expire are set, copy values into data/reply-cache-size */
        if (!strcasecmp(c->name, "cache-size")) {
            if (defaulted) {
                continue;
            } else {
                snprintf(buf, sizeof(buf), "%d", atou(value) - (atou(value)/3));
                conf_clobber(&Conf, "zone-cache-size", buf);
                snprintf(buf, sizeof(buf), "%d", atou(value)/3);
                conf_clobber(&Conf, "reply-cache-size", buf);
            }
        } else if (!strcasecmp(c->name, "cache-expire")) {
            if (defaulted) {
                continue;
            } else {
                snprintf(buf, sizeof(buf), "%d", atou(value));
                conf_clobber(&Conf, "zone-cache-expire", buf);
                snprintf(buf, sizeof(buf), "%d", atou(value)/2);
                conf_clobber(&Conf, "reply-cache-expire", buf);
            }
        } else if (!strcasecmp(c->name, "listen") || !strcasecmp(c->name, "no-listen")) {
            char *cp, *vbuf, *v;
            while ((cp = strchr(value, ',')))
                *cp = CONF_FS_CHAR;
            vbuf = STRDUP(value);
            for (cp = vbuf; (v = strsep(&cp, CONF_FS_STR));) {
                if (v == vbuf) {
                    snprintf(pair, sizeof(pair), "%s = %s", c->name, v);
                    printf("%-*.*s\t# %s\n", w, w, pair, _(c->desc));
                } else {
                    printf("%s = %s\n", c->name, v);
                }
            }
            RELEASE(vbuf);
        } else {
            snprintf(pair, sizeof(pair), "%s = %s", c->name, value);
            printf("%-*.*s\t# %s\n", w, w, pair, _(c->desc));
        }
    }
    printf("\n");
}
예제 #18
0
파일: conf.c 프로젝트: shangyanjin/mydns-ng
/**************************************************************************************************
	CONF_SET_RECURSIVE
	If the 'recursive' configuration option was specified, set the recursive server.
**************************************************************************************************/
static void
conf_set_recursive(void) {
    char		*c;
    const char	*address = conf_get(&Conf, "recursive", NULL);
    char		addr[512];
    int		port = 53;

    if (!address || !address[0])
        return;
    strncpy(addr, address, sizeof(addr)-1);

#if HAVE_IPV6
    if (is_ipv6(addr)) {		/* IPv6 - treat '+' as port separator */
        recursive_family = AF_INET6;
        if ((c = strchr(addr, '+'))) {
            *c++ = '\0';
            if (!(port = atoi(c)))
                port = 53;
        }
        if (inet_pton(AF_INET6, addr, &recursive_sa6.sin6_addr) <= 0) {
            Warnx("%s: %s", address, _("invalid network address for recursive server"));
            return;
        }
        recursive_sa6.sin6_family = AF_INET6;
        recursive_sa6.sin6_port = htons(port);
        forward_recursive = 1;
#if DEBUG_ENABLED && DEBUG_CONF
        DebugX("conf", 1,_("recursive forwarding service through %s:%u"),
               ipaddr(AF_INET6, &recursive_sa6.sin6_addr), port);
#endif
        recursive_fwd_server = STRDUP(address);
    } else {			/* IPv4 - treat '+' or ':' as port separator  */
#endif
        recursive_family = AF_INET;
        if ((c = strchr(addr, '+')) || (c = strchr(addr, ':'))) {
            *c++ = '\0';
            if (!(port = atoi(c)))
                port = 53;
        }
        if (inet_pton(AF_INET, addr, &recursive_sa.sin_addr) <= 0) {
            Warnx("%s: %s", address, _("invalid network address for recursive server"));
            return;
        }
        recursive_sa.sin_family = AF_INET;
        recursive_sa.sin_port = htons(port);
#if DEBUG_ENABLED &&DEBUG_CONF
        DebugX("conf", 1,_("recursive forwarding service through %s:%u"),
               ipaddr(AF_INET, &recursive_sa.sin_addr), port);
#endif
        forward_recursive = 1;
        recursive_fwd_server = STRDUP(address);
#if HAVE_IPV6
    }
#endif

    if (!forward_recursive) return;

    recursion_timeout = atou(conf_get(&Conf, "recursive-timeout", NULL));
    recursion_connect_timeout = atou(conf_get(&Conf, "recursive-connect-timeout", NULL));
    recursion_retries = atou(conf_get(&Conf, "recursive-retries", NULL));
    recursion_algorithm = conf_get(&Conf, "recursive-algorithm", NULL);

}
// ============================================================
int main( const int nArg, const char *aArg[] )
{
// BEGIN OMP
    gnThreadsMaximum = omp_get_num_procs();
// END OMP

    int iArg = 1;
    for( iArg = 1; iArg < nArg; iArg++ )
    {
        if (aArg[ iArg ][0] == '-' )
        {
            if (aArg[iArg][1] == 'j')
            {
                iArg++;
                if (iArg > nArg)
                    return printf( "Invalid # of threads to use.\n" );
                gnThreadsActive = atoi( aArg[ iArg ] );
                if (gnThreadsActive < 0)
                    gnThreadsActive = 0;
                if (gnThreadsActive > gnThreadsMaximum)
                    gnThreadsActive = gnThreadsMaximum;
            }
        }
        else
            break;
    }

    prime_t max = (nArg > iArg)
        ? (prime_t) atou( aArg[ iArg ] )
//      :          6; // Test 6i+1>max && isprime(6i+1)==true
//      :         32; // Test 8 core
//      :         64; // Test 8 core
//      :        255; // 2^8 Test 8 core
//      :        256; //10^3 Test 8 core [54] = 251 // Largest 8-bit prime

//      :        100; //10^2    [             25] =            97 // 25 primes between 1 and 100
//      :       1000; //10^3    [            168] =           997
//             10000; //10^4    [          1,229] =         9,973 //
//      :      65536; // 2^16   [          6,542] =        65,521 // x86: 00:00:00.001, x64: 00:00:00.000  Primes/Sec: 64,000,000 K#/s Largest 16-bit prime
//      :     100000; //10^5    [          9,592] =        99,991 // x86: 00:00:00.001, x64: 00:00:00.000  Primes/Sec: 97,000,000 K#/s
//      :     611953; //        [         50,000] =       611,953 // x86: 00:00:00.002, x64: 00:00:00.002  Primes/Sec: 298,500 K#/s    First 50,000 primes
//      :    1000000; //10^6    [         78,498] =       999,983 // x86: 00:00:00.003, x64: 00:00:00.002  Primes/Sec: 488,000 K#/s
        :   10000000; //10^7    [        664,579] =     9,999,991 // x86: 00:00:00.031, x64: 00:00:00.034  Primes/Sec: 264 M#/s
//      :   15485863; //        [      1,000,000] =    15,485,863 // x86: 00:00:00.057, x64: 00:00:00.055  Primes/Sec: 254 M#/s        First 1,000,000 primes
//      :  100000000; //10^8    [      5,761,455] =    99,999,989 // x86: 00:00:00.490, x64: 00:00:00.484  Primes/Sec: 196 M#/s
//      : 1000000000; //10^9    [     50,847,534] =   999,999,937 // x86: crash         x64: 00:00:10.590  Primes/Sec: 89 M#/s
//      : 2038074743; //        [    100,000,000] = 2,038,074,743 //                    x64: 00:00:23.130  Primes/Sec: 84 M#/s First 100,000,000 primes
//      : 2147483644; // 2^31-4 [    105,097,564] = 2,147,483,629 //                    x64: 00:00:24.502  Primes/Sec: 83 M#/s
//      : 2147483647; // 2^31-1 [               ]
//      : 2147483648; // 2^31   [    105,097,565] = 2,147,483,647 //                    x64: 00:00:43.818  Primes/Sec: 46 M#/s
//      : 4294967292; // 2^32-4 [               ]
//      : 4294967295; // 2^32-1 [               ]
//      : 4294967296; // 2^32   [    203,280,221] =
//      :10000000000; //10^10   [    455,052,511] =
//      :       1e11; //10^11   [  4,118,054,813] =
//      :       1e12; //10^12   [ 37,607,912,018] =
//      :       1e13; //10^13   [346,065,536,839] =

    AllocArray ( max );
    TimerStart ( max );
    BuildPrimes( max );
    TimerStop  ( max );
    getchar();
    PrintPrimes();
    DeleteArray();

    return 0;
}
예제 #20
0
static void
pg_show(const struct req *req, char *path)
{
	struct manpaths	 ps;
	size_t		 sz;
	char		*sub;
	char		 file[PATH_MAX];
	const char	*cp;
	int		 rc, catm;
	unsigned int	 vol, rec, mr;
	DB		*idx;
	DBT		 key, val;

	idx = NULL;

	/* Parse out mroot, volume, and record from the path. */

	if (NULL == path || NULL == (sub = strchr(path, '/'))) {
		resp_error400();
		return;
	} 
	*sub++ = '\0';
	if ( ! atou(path, &mr)) {
		resp_error400();
		return;
	}
	path = sub;
	if (NULL == (sub = strchr(path, '/'))) {
		resp_error400();
		return;
	}
	*sub++ = '\0';
	if ( ! atou(path, &vol) || ! atou(sub, &rec)) {
		resp_error400();
		return;
	} else if (mr >= (unsigned int)req->psz) {
		resp_error400();
		return;
	}

	/*
	 * Begin by chdir()ing into the manroot.
	 * This way we can pick up the database files, which are
	 * relative to the manpath root.
	 */

	if (-1 == chdir(req->p[(int)mr].path)) {
		perror(req->p[(int)mr].path);
		resp_baddb();
		return;
	}

	memset(&ps, 0, sizeof(struct manpaths));
	manpath_manconf(&ps, "etc/catman.conf");

	if (vol >= (unsigned int)ps.sz) {
		resp_error400();
		goto out;
	}

	sz = strlcpy(file, ps.paths[vol], PATH_MAX);
	assert(sz < PATH_MAX);
	strlcat(file, "/", PATH_MAX);
	strlcat(file, MANDOC_IDX, PATH_MAX);

	/* Open the index recno(3) database. */

	idx = dbopen(file, O_RDONLY, 0, DB_RECNO, NULL);
	if (NULL == idx) {
		perror(file);
		resp_baddb();
		goto out;
	}

	key.data = &rec;
	key.size = 4;

	if (0 != (rc = (*idx->get)(idx, &key, &val, 0))) {
		rc < 0 ? resp_baddb() : resp_error400();
		goto out;
	} else if (0 == val.size) {
		resp_baddb();
		goto out;
	}

	cp = (char *)val.data;
	catm = 'c' == *cp++;

	if (NULL == memchr(cp, '\0', val.size - 1)) 
		resp_baddb();
	else {
 		file[(int)sz] = '\0';
 		strlcat(file, "/", PATH_MAX);
 		strlcat(file, cp, PATH_MAX);
		if (catm) 
			catman(req, file);
		else
			format(req, file);
	}
out:
	if (idx)
		(*idx->close)(idx);
	manpath_free(&ps);
}
예제 #21
0
// ./next_gen "# of permutations" stem0 stem1 stem2 ...
int main(int argc, unsigned char **argv) {
  char phrase[59] = "I would much rather hear more about your whittling project";
  unsigned int permutations = atou((char *)argv[1]);

  sseK00_19 = _mm_set1_epi32(0x5a827999);
  sseK20_39 = _mm_set1_epi32(0x6ed9eba1);
  sseK40_59 = _mm_set1_epi32(0x8f1bbcdc);
  sseK60_79 = _mm_set1_epi32(0xca62c1d6);

  best_stem  = malloc(sizeof(char) * 5);

  shortest_d = 180;

  // Get finished context for phrase
  SHA_CTX *phrase_ctx = malloc(sizeof(SHA_CTX));
  sha1_full(phrase_ctx, phrase);

  // Load prefixes
  unsigned char **prefixes = malloc(sizeof(char *) * PREFIX_COUNT);
  int p = 0;
  for(p = 0;p < PREFIX_COUNT;p++) 
    prefixes[p] = argv[2 + p];

  // Get chaining contexts for suffixes
  SHA_CTX *prefix_ctxs = malloc(sizeof(SHA_CTX) * PREFIX_COUNT);
  for(p = 0;p < PREFIX_COUNT;p++) 
    sha1_partial(&prefix_ctxs[p], prefixes[p]);

  struct vector_ctx *vc = malloc(sizeof(struct vector_ctx) * PREFIX_COUNT/4);
  struct vector_ctx *vc_ptr = vc;

  SHA_CTX *prefix_ptr = prefix_ctxs;
  for(p = 0;p < PREFIX_COUNT;p+=4) {
    vectorize_prefixes(vc_ptr, prefix_ptr);

    prefix_ptr += 4;
    vc_ptr += 1;
  }


  // Allocate memory for expanded message template
  uint32_t *w = malloc(sizeof(uint32_t) * 80);
  
  int w_i = 0;

  // We only hash suffixes that are 5 bytes long
  
  // w[0] prefix_stem
  // w[1] current final char + some other stuff and zeros
  // w[2]-w[14]
  // Expanded message blocks 2-14 are always 0x0000000...
  for(w_i = 2;w_i < 15;w_i++)
    w[w_i] = 0;

  // w[15] is the size of the message
  w[15] = 552;
  // w[16] - stem constant - W13 ^ W8 ^ W2 ^ W0  => W0 <<< 1
  // w[17] - changing lots
  // w[18] - constant
  w[18] = ROTATE(w[15], 1);
  // w[19] - stem constant
  // w[20] - changing lots 


  uint32_t *stem_w = malloc(sizeof(uint32_t) * 80);
  uint32_t *stem_x = malloc(sizeof(uint32_t) * 80);

  init_lut();

  struct vector_ctx *my_vc = malloc(sizeof(struct vector_ctx) * PREFIX_COUNT/2);
  int i = 0;
  char suffix_stem[5] = "!!!!";
  for(i = 0;i < permutations;i++) {
    memcpy(stem_w, w, 80 * sizeof(uint32_t));
    memcpy(my_vc, vc, sizeof(struct vector_ctx) * PREFIX_COUNT/2);

    int dist = shortest_distance(phrase_ctx, my_vc, suffix_stem, stem_w, stem_x);

    next_stem(suffix_stem);
  }

  free(vc);
  free(my_vc);
  free(w);
  free(stem_w);
  free(stem_x);

  // Print shortest_distance and the 5 char ending.
  printf("%d,%s,%d\n", shortest_d, best_stem, best_last+33);
}
예제 #22
0
int main(int argc, char *argv[]) {

	struct IdDocIDmapFormat *IdDocIDmap;


	time_t now = time(NULL);

	char query[512];
	char url[201];
	//selecter fra db
	char mysql_query [2048];
        static MYSQL demo_db;
	int i, pages;	
	unsigned int DocID;
	int total;

        MYSQL_RES *mysqlres; /* To be used to fetch information into */
        MYSQL_ROW mysqlrow;

      	if (argc < 3) {
//                printf("Dette programet slår opp ekte DocID for pi. \n\n\tUsage: ./PiToWWWDocID UrlToDocID_folder sql_table");
                printf("Dette programet slår opp ekte DocID for pi. \n\n\tUsage: ./PiToWWWDocID UrlToDocID_db sql_table\n");
		printf("\nMerk: Navn på index-fil er det samme som UrlToDocID_db + '.index'\n");
               exit(0);
        }

        char *UrlToDocIDdb = argv[1];
        char *table = argv[2];


 	#ifdef WITH_THREAD
                my_init();
                if (mysql_thread_safe() == 0) {
                        printf("The MYSQL client is'en compiled at thread safe! This will broboble crash.\n");
                }
        #endif


	mysql_init(&demo_db);

        if(!mysql_real_connect(&demo_db, "web1.jayde.boitho.com", "boitho", "G7J7v5L5Y7", "boithoweb", 3306, NULL, 0)){
                printf(mysql_error(&demo_db));
                exit(1);
        }


	char		db_index[strlen(UrlToDocIDdb)+7];
	sprintf(db_index, "%s.index", UrlToDocIDdb);
	urldocid_data	*data = urldocid_search_init(db_index, UrlToDocIDdb);


	sprintf(mysql_query, "select id,url from %s WHERE WWWDocID is NULL OR WWWDocID='0' limit 10",table);

	total = 0;
	while (1) {

        	if(mysql_real_query(&demo_db, mysql_query, strlen(mysql_query))){ /* Make query */
        	        printf(mysql_error(&demo_db));
        	        //return(1);
        	        pthread_exit((void *)1); /* exit with status */
        	}

        	mysqlres=mysql_store_result(&demo_db); /* Download result from server */
		_configdatanr = (int)mysql_num_rows(mysqlres);

		if (_configdatanr == 0) {
			break;
		}

		#ifdef DEBUG
		printf("nrofrows %i\n",_configdatanr);
		#endif

		if ((IdDocIDmap = malloc(sizeof(struct IdDocIDmapFormat) * _configdatanr)) == NULL) {
			perror("malloc IdDocIDmap");
			exit(1);
		}	
		pages=0;



        	while ((mysqlrow=mysql_fetch_row(mysqlres)) != NULL) { /* Get a row from the results */

			strscpy(url,mysqlrow[1],sizeof(url));
			url_normalization(url,sizeof(url));

			#ifdef DEBUG
			printf("url \"%s\"\n",url);
			#endif

               		if (!getDocIDFromUrl(data, url, &DocID)) {
                	        printf("Unable to find docId.\n\tMain \"%s\"\n\tIndex \"%s\"\n",UrlToDocIDdb, db_index);              
				

				//DocID = 0;
				DocID = PIStartDOCID + atou(mysqlrow[0]);


	                } else {
	                        //look up rank for docid
	                }

			IdDocIDmap[pages].id = atou(mysqlrow[0]);
			IdDocIDmap[pages].DocID = DocID;
 	
			#ifdef DEBUG
        	        printf("\tid %s, WWWDocID %u,url \"%s\"\n",mysqlrow[0],DocID,url);
			#endif

			if ((total % 1000) == 0) {
				printf("total %i\n",total);
			}

			++pages;
			++total;
		}


		for (i=0;i<pages;i++) {
			#ifdef DEBUG
			printf("id %u => DocID %u\n",IdDocIDmap[i].id,IdDocIDmap[i].DocID);
			#endif
			snprintf(query,sizeof(query),"update LOW_PRIORITY %s set WWWDocID=%u where id=%u",table,IdDocIDmap[i].DocID,IdDocIDmap[i].id);

			#ifdef DEBUG
			printf("query \"%s\"\n",query);
			#endif
			mysql_real_query(&demo_db, query, strlen(query));
		}	

		free(IdDocIDmap);

		mysql_free_result(mysqlres);

	}

	mysql_close(&demo_db);
	urldocid_search_exit(data);

	printf("did lookup %i\n",total);
}
예제 #23
0
파일: main.c 프로젝트: apinkney97/JSReflow
void
main (int argc, string argv[])
{
  int code;
  string font_name = read_command_line (argc, argv);
  bitmap_font_type f = get_bitmap_font (font_name, atou (dpi));
  string font_basename = basename (font_name);

  /* Initializing the display might involve forking a process.  We
     wouldn't want that process to get copies of open output files,
     since then when it exited, random stuff might get written to the
     end of the file.  */
  init_display (f);

  if (logging)
    log_file = xfopen (concat (font_basename, ".log"), "w");

  if (strlen (BITMAP_FONT_COMMENT (f)) > 0)
    REPORT1 ("{%s}\n", BITMAP_FONT_COMMENT (f));

  if (output_name == NULL)
    output_name = font_basename;

  bzr_start_output (output_name, f);

  /* The main loop: for each character, find the outline of the shape,
     then fit the splines to it.  */
  for (code = starting_char; code <= ending_char; code++)
    {
      pixel_outline_list_type pixels;
      spline_list_array_type splines;
      char_info_type *c = get_char (font_name, code);
    
      if (c == NULL) continue;

      REPORT1 ("[%u ", code);
      if (logging)
	{
	  LOG ("\n\n\f");
	  print_char (log_file, *c);
	}

      x_start_char (*c);
      pixels = find_outline_pixels (*c);
      /* `find_outline_pixels' uses corners as the coordinates, instead
         of the pixel centers.  So we have to increase the bounding box.  */
      CHAR_MIN_COL (*c)--; CHAR_MAX_COL (*c)++;
      CHAR_MIN_ROW (*c)--; CHAR_MAX_ROW (*c)++;

      REPORT ("|");
      splines = fitted_splines (pixels);

      bzr_output_char (*c, splines);
      
      /* Flush output before displaying the character, in case the user
         is interested in looking at it and the online version
         simultaneously.  */
      flush_log_output ();

      x_output_char (*c, splines);
      REPORT ("]\n");

      /* If the character was empty, it won't have a bitmap.  */
      if (BITMAP_BITS (CHAR_BITMAP (*c)) != NULL)
        free_bitmap (&CHAR_BITMAP (*c));

      free_pixel_outline_list (&pixels);
      free_spline_list_array (&splines);
    }

  bzr_finish_output ();
  close_display ();

  close_font (font_name);

  exit (0);
}
예제 #24
0
tmpl (void)::rsp_fsm()
{

  //////////////////////////////////////////////////////////////////////////
  // The VCI_RSP FSM controls the following ressources:
  // - m_vci_rsp_fsm:
  // - m_icache_miss_buf[m_icache_words]
  // - m_dcache_miss_buf[m_dcache_words]
  // - m_icache_miss_req reset
  // - m_icache_unc_req reset
  // - m_dcache_miss_req reset
  // - m_dcache_unc_req reset
  // - m_icache_write_req reset
  // - m_vci_rsp_data_error set
  // - m_vci_rsp_ins_error set
  // - m_vci_rsp_cpt
  // In order to have only one active VCI transaction, this VCI_RSP_FSM
  // is synchronized with the VCI_CMD FSM, and both FSMs exit the
  // IDLE state simultaneously.
  //
  // VCI formats:
  // This component accepts single word or multi-word response packets for
  // write response packets.
  //
  // Error handling:
  // This FSM analyzes the VCI error code and signals directly the
  // Write Bus Error.
  // In case of Read Data Error, the VCI_RSP FSM sets the m_vci_rsp_data_error
  // flip_flop and the error is signaled by the DCACHE FSM.
  // In case of Instruction Error, the VCI_RSP FSM sets the m_vci_rsp_ins_error
  // flip_flop and the error is signaled by the DCACHE FSM.
  // In case of Cleanup Error, the simulation stops with an error message...
  //////////////////////////////////////////////////////////////////////////
  
  switch (m_vci_rsp_fsm) {
    
  case RSP_IDLE:
    //if (m_vci_cmd_fsm != CMD_IDLE) break;
    
    m_vci_rsp_cpt = 0;
    if      ( m_icache_miss_req && m_pdes_local_time->get().value()>m_icache_time_req)        m_vci_rsp_fsm = RSP_INS_MISS;
    else if ( m_icache_unc_req && m_pdes_local_time->get().value()>m_icache_time_req)         m_vci_rsp_fsm = RSP_INS_UNC;
    else if ( m_dcache_write_req && m_pdes_local_time->get().value()>m_dcache_write_time_req) m_vci_rsp_fsm = RSP_DATA_WRITE;
    else if ( m_dcache_miss_req && m_pdes_local_time->get().value()>m_dcache_read_time_req)       m_vci_rsp_fsm = RSP_DATA_MISS;
    else if ( m_dcache_unc_req && m_pdes_local_time->get().value()>m_dcache_read_time_req)        m_vci_rsp_fsm = RSP_DATA_UNC;
    break;
    
  case RSP_INS_MISS:
    m_cost_imiss_transaction++;
    wait(m_rsp_received);
    for(unsigned int i=0;i<(m_payload_ptr->get_data_length()/vci_param::nbytes); i++){
      m_icache_miss_buf[i] = atou(m_payload_ptr->get_data_ptr(), (i * vci_param::nbytes));
    }
    m_icache_miss_req = false;
    m_vci_rsp_fsm = RSP_IDLE;
    m_vci_rsp_ins_error = m_payload_ptr->is_response_error();
   
    break;
    
  case RSP_INS_UNC:
    m_cost_imiss_transaction++;
    wait(m_rsp_received);
    m_icache_miss_buf[0] = atou(m_payload_ptr->get_data_ptr(), 0);
    m_icache_buf_unc_valid = true;
    m_vci_rsp_fsm = RSP_IDLE;
    m_icache_unc_req = false;
    m_vci_rsp_ins_error = m_payload_ptr->is_response_error();

    break;
    
  case RSP_DATA_MISS:
    m_cost_dmiss_transaction++;
    wait(m_rsp_received);
    for(unsigned int i=0;i<(m_payload_ptr->get_data_length()/vci_param::nbytes); i++){
      m_dcache_miss_buf[i] = atou(m_payload_ptr->get_data_ptr(), (i * vci_param::nbytes));
    }
    m_dcache_miss_req = false;
    m_vci_rsp_fsm = RSP_IDLE;
    m_vci_rsp_data_error = m_payload_ptr->is_response_error();
    break;
    
  case RSP_DATA_WRITE:
    m_cost_write_transaction++;
    wait(m_rsp_received);
    if(m_pdes_local_time->get()>=m_rsp_time){
      m_vci_rsp_fsm = RSP_IDLE;
      m_dcache_write_req = false;
      if ( m_payload_ptr->is_response_error()) {
#ifdef SOCLIB_MODULE_DEBUG
	std::cout << name() << " write BERR" << std::endl;
#endif
	m_iss.setWriteBerr();
      }
    }
    else
      m_vci_rsp_fsm = RSP_DATA_WRITE_TIME_WAIT;
   break;
  case RSP_DATA_WRITE_TIME_WAIT:
    if(m_pdes_local_time->get()>=m_rsp_time){
      m_vci_rsp_fsm = RSP_IDLE;
      m_dcache_write_req = false;
      if ( m_payload_ptr->is_response_error()) {
#ifdef SOCLIB_MODULE_DEBUG
	std::cout << name() << " write BERR" << std::endl;
#endif
	m_iss.setWriteBerr();
      }
    }
    break;
  case RSP_DATA_UNC:
    m_cost_unc_transaction++;
    wait(m_rsp_received);
    m_dcache_miss_buf[0] = atou(m_payload_ptr->get_data_ptr(), 0);
    m_vci_rsp_fsm = RSP_IDLE;
    m_dcache_unc_req = false;
    m_vci_rsp_data_error = m_payload_ptr->is_response_error();
    break;
    
  } // end switch m_vci_rsp_fsm
}
예제 #25
0
int
main(int argc, char **argv)
{

	int i;
	char *subname;
	struct gcaoptFormat gcaopt;

	gcaopt.MaxAgeDiflastSeen  = (86400 * 5); //86400=1 dag
	gcaopt.log = NULL;
	gcaopt.logSummary = NULL;
	gcaopt.lastSeenHack = 0;
	gcaopt.dontcheckok = 0;

        extern char *optarg;
        extern int optind, opterr, optopt;
        char c;
        while ((c=getopt(argc,argv,"t:dlsho"))!=-1) {
                switch (c) {
                        case 'h':
				print_usage();
				break;
                        case 't':
                                gcaopt.MaxAgeDiflastSeen  = atou(optarg);
                                break;
			case 'l':
				if ((gcaopt.log = fopen(bfile("logs/gc"),"ab")) == NULL) {
					perror("logs/gc");
					exit(-1);
				}
				if ((gcaopt.logSummary = fopen(bfile("logs/gcSummary"),"ab")) == NULL) {
					perror("logs/gcSummary");
					exit(-1);
				}

				break;
			case 's':
				gcaopt.lastSeenHack = 1;
				break;
			case 'o':
				gcaopt.dontcheckok = 1;
				break;
                        default:
                                exit(1);
                }

        }
        --optind;



	DIR *ll;


	#ifndef BLACK_BOX
		fprintf("dette fungerer bare med black boks for nå\n");
		exit(1);
	#endif

	if ((argc -optind) == 2) {
		subname = argv[1 +optind];

		gc_coll(subname, &gcaopt);


	}
	else if ((argc -optind) == 1) {

		ll = listAllColl_start();

		while((subname = listAllColl_next(ll)) != NULL) {
			printf("indexing collection \"%s\"\n",subname);

			gc_coll(subname, &gcaopt);

		}

		listAllColl_close(ll);

	}
	else {
		print_usage();
	}



	return 0;
}