示例#1
0
int rcshashcode(struct rolechangesum *rcs) {
  int hashcode=hashstring(rcs->newrole);
#ifndef KARENHACK
  hashcode^=hashstring(rcs->origrole);
#endif
  return hashcode;
}
示例#2
0
/*
 * main() : Entry point
 */
int main(int argc, char *argv[]) {

  if (argc < 2 || strcmp(argv[1], "-?") == 0) {
    /* Print usage */
    return printusage();
  }

  if (strcmp(argv[1], "-s") == 0) {
    /* Hash string */
    return hashstring(argv[2]);
  }

  if (strcmp(argv[1], "-t") == 0) {
    /* Time trial */
    return timetrial();
  }

  if (strcmp(argv[1], "-x") == 0) {
    /* Test suite */
    return testsuite();
  }

  /* Hash file */
  return hashfile(argv[1]);
}
示例#3
0
void methodassignhashcode(struct rolemethod * method) {
  int i;
  int hashcode=hashptr(method->methodname);
  for(i=0;i<method->numobjectargs;i++)
    hashcode^=hashstring(method->paramroles[i]);
  method->hashcode=hashcode;
}
示例#4
0
int ccencrypt_init(ccrypt_stream_t *b, char *key) {
  word32 keyblock[8];
  ccrypt_state_t *st;

  st = malloc(sizeof(ccrypt_state_t));
  if (st == NULL) {
    b->state = NULL;
    return -1;
  }
  b->state = (void *)st;

  /* generate the roundkey */
  hashstring(key, keyblock);
  xrijndaelKeySched(keyblock, 256, 256, &st->rkk);
  
  /* make a nonce */
  make_nonce(st->buf);

  /* mark the nonce with a "magic number". */
  strncpy((char *)st->buf, MAGIC, 4);

  /* encrypt the nonce with the given key */
  xrijndaelEncrypt(st->buf, &st->rkk);

  /* IV is now contained in st->buf. Initialize rest of the state. */
  st->iv = 1;
  st->bufindex = 0; /* initially use bufsize to count iv bytes output */
  return 0;
}
示例#5
0
nrmessage_type *nrt_find(const struct locale * lang,
    const struct message_type * mtype)
{
    nrmessage_type *found = NULL;
    unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
    nrmessage_type *type = nrtypes[hash];
    while (type) {
        if (type->mtype == mtype) {
            if (found == NULL)
                found = type;
            else if (type->lang == NULL)
                found = type;
            if (lang == type->lang) {
                found = type;
                break;
            }
        }
        type = type->next;
    }
    if (!found) {
        log_warning("could not find nr-type %s for locale %s\n", mtype->name, locale_name(lang));
    }
    if (lang && found && found->lang != lang) {
        log_warning("could not find nr-type %s for locale %s, using %s\n", mtype->name, locale_name(lang), locale_name(found->lang));
    }
    return found;
}
示例#6
0
void crt_register(const struct message_type *mtype)
{
    unsigned int hash = hashstring(mtype->name) % CRMAXHASH;
    crmessage_type *crt = crtypes[hash];
    while (crt && crt->mtype != mtype) {
        crt = crt->next;
    }
    if (!crt) {
        crt = malloc(sizeof(crmessage_type));
        crt->mtype = mtype;
        crt->next = crtypes[hash];
        crtypes[hash] = crt;
        if (mtype->nparameters > 0) {
            int i;
            crt->renderers = malloc(sizeof(tostring_f) * mtype->nparameters);
            /* can be scrapped for memory vs. speed */
            for (i = 0; i != mtype->nparameters; ++i) {
                crt->renderers[i] = tsf_find(mtype->types[i]->name);
            }
        }
        else {
            crt->renderers = NULL;
        }
    }
}
示例#7
0
文件: skills.c 项目: Xolgrim/server
int rc_skillmod(const struct race *rc, const region * r, skill_t sk)
{
    int mods = 0;

    if (!skill_enabled(sk)) {
        return 0;
    }
#ifdef FASTER_SKILLMOD
    unsigned int index = hashstring(rc->_name) % RCMODMAXHASH;
    struct skillmods **imods = &modhash[index];
    while (*imods && (*imods)->race != rc) {
        imods = &(*imods)->next;
    }
    if (*imods == NULL) {
        *imods = init_skills(rc);
    }
    mods = (*imods)->mod[rterrain(r)].value[sk];
#else
    if (r) {
        mods = skill_mod(rc, sk, r->terrain);
    }
#endif
    if (rc == get_race(RC_ELF) && r && r_isforest(r)) {
        if (sk == SK_PERCEPTION || sk == SK_STEALTH) {
            ++mods;
        }
        else if (sk == SK_TACTICS) {
            mods += 2;
        }
    }
    return mods;
}
示例#8
0
struct cachepts *lookup(struct cachepts **table, int xval, int yval)
{
        struct cachepts *curr = NULL;
        int hash = hashstring(xval,yval);
        printf("Hashstring for hash value (%d,%d) is %d\n", xval, yval, hash);
        struct cachepts *wp,*nwp;

        if (table[hash]) {
                wp = table[hash];
        }
        else {
		printf("Assigning new memory for table[hash]\n");
                table[hash] = (struct cachepts *)malloc(sizeof(struct cachepts));
		memset(table[hash],0,sizeof(struct cachepts));
                wp = table[hash];

        }

	printf("Table hash pointer is: %p\n",table);
	printf("Table hash pointer is: %p\n",table[0]);
	printf("Table hash pointer is: %p\n",table[hash]);

        int found = 0;
        for (curr = wp; curr != NULL; curr = curr->next) {
                /* search */
                printf("Curr pointer is %p with value %d\n",curr,curr->x);
                if (curr->x == xval && curr->y == yval) {
                        found = 1;
                        curr->paths++;
			printf("Value %d is already present in hash table\n",curr->x);
                        break;
                }
        }

        if (found == 0) {
                if (wp->paths>0) {
                        printf("Wp existing value for %d is: %d with paths: %d\n",xval,wp->x,wp->paths);
                        //printf("Wp existing pointer is: %p\n",wp);
                        nwp = (struct cachepts *)malloc(sizeof(struct cachepts));
			memset(nwp,0,sizeof(struct cachepts));
                        //printf("nWp new pointer is: %p\n",nwp);
                        nwp->x = xval;
                        nwp->y = yval;
                        nwp->paths++;
                        nwp->next = wp;
                        printf("nWp value is: %d with paths: %d\n",nwp->x,nwp->paths);
                        table[hash] = nwp;
                        curr = nwp;
                }
                else {
                        wp->x = xval;
                        wp->y = yval;
                        wp->paths++;
                        curr = wp;
                        printf("New value: %d with paths: %d\n",wp->x,wp->paths);
                }
                /* add to front */;
        }
        return curr;
}
示例#9
0
static int tigersum(lua_State * L)
{
    const char * input = luaL_checkstring(L, 1);
    string output;
    hashstring(input, output, sizeof(output));
    lua_pushstring(L, output);
    return 1;
}
示例#10
0
/* return a 256-bit value that is practically unique */
void make_nonce(word32 nonce[8]) {
  char acc[512], host[256];
  static int count=0;
  
  gethostname(host, 256);
  sprintf(acc, "%s, %d, %d, %d", host, (int)time(0), getpid(), count++);
  hashstring(acc, nonce); 
}
示例#11
0
struct wordrec *lookup(struct wordrec **table, int val)
{
        struct wordrec *curr = NULL;
        int hash = hashstring(val);
        printf("Hashstring for hash value %d is %d\n",val,hash);
        struct wordrec *wp,*nwp;

        if (table[hash]) {
                wp = table[hash];
        }
        else {
		printf("Assigning new memory for table[hash]\n");
                table[hash] = (struct wordrec *)malloc(sizeof(struct wordrec));
		memset(table[hash],0,sizeof(struct wordrec));
                wp = table[hash];

        }

	printf("Table hash pointer is: %p\n",table);
	printf("Table hash pointer is: %p\n",table[0]);
	printf("Table hash pointer is: %p\n",table[hash]);

        int found = 0;
        for (curr = wp; curr != NULL; curr = curr->next) {
                /* search */
                printf("Curr pointer is %p with value %d\n",curr,curr->num);
                if (curr->num == val) {
                        found = 1;
                        curr->count++;
			printf("Value %d is already present in hash table\n",curr->num);
                        break;
                }
        }

        if (found == 0) {
                if (wp->count>0) {
                        printf("Wp existing value for %d is: %d with count: %d\n",val,wp->num,wp->count);
                        //printf("Wp existing pointer is: %p\n",wp);
                        nwp = (struct wordrec *)malloc(sizeof(struct wordrec));
			memset(nwp,0,sizeof(struct wordrec));
                        //printf("nWp new pointer is: %p\n",nwp);
                        nwp->num = val;
                        nwp->count++;
                        nwp->next = wp;
                        printf("nWp value is: %d with count: %d\n",nwp->num,nwp->count);
                        table[hash] = nwp;
                        curr = nwp;
                }
                else {
                        wp->num = val;
                        wp->count++;
                        curr = wp;
                        printf("New value: %d with count: %d\n",wp->num,wp->count);
                }
                /* add to front */;
        }
        return curr;
}
示例#12
0
文件: message.c 项目: Xolgrim/server
const message_type *mt_register(message_type * type)
{
    unsigned int hash = hashstring(type->name) % MT_MAXHASH;
    quicklist **qlp = messagetypes + hash;

    if (ql_set_insert(qlp, type)) {
        type->key = mt_id(type);
    }
    return type;
}
示例#13
0
/* decryption */
int ccdecrypt(reader *r, writer *w, char *keyword) {
  word32 state[8];
  word32 seed[8];
  word8 *statec = (word8 *)state;
  word8 *seedchar = (word8 *)seed;
  roundkey rkk;

  word32 key[8];
  int i, c, cc;
  int st;
  
  /* generate the roundkey */
  hashstring(keyword, key);
  xrijndaelKeySched(key, 256, 256, &rkk);
  
  /* read the seed */
  for (i=0; i<32; i++) {
    seedchar[i] = statec[i] = cc = r->bgetc(r);
    if (cc == EOF) {
      if (errno) return -1;
      else return 1;  /* error: less than 32 characters in file */
    }
  }
  
  /* decrypt the seed with the given keyword */
  xrijndaelDecrypt(seed, &rkk);
  
  /* check the "magic number". */
  if (strncmp(seedchar, MAGIC, 4)) {
    if (!cmd.mismatch) {
      return 2;  /* error: wrong key or algorithm */
    }
    if (cmd.verbose>=0) {
      fprintf(stderr, "%s: warning: key does not match - decrypting anyway\n", cmd.name);
    }
  }
  
  /* decrypt the body of the stream */
  cc = r->bgetc(r);
  while (cc != EOF) {
    xrijndaelEncrypt(state, &rkk);

    for (i=0; i<32 && cc != EOF; i++) {
      c = cc ^ statec[i];
      statec[i] = cc;
      st = w->bputc(c, w);
      if (st<0) return -1;
      cc = r->bgetc(r);
    }
  }
  if (errno)
    return -1;

  return w->beof(w);
}
示例#14
0
/* return a 256-bit value that is practically unique */
static void make_nonce(word32 nonce[8]) {
  char acc[512], host[256];
  struct timeval tv;
  static int count=0;
  
  gethostname(host, 256);
  gettimeofday(&tv, NULL);
  sprintf(acc, "%s,%ld,%ld,%ld,%d", host, (long)tv.tv_sec, (long)tv.tv_usec,
	  (long)getpid(), count++);
  hashstring(acc, nonce); 
}
示例#15
0
static crmessage_type *crt_find(const struct message_type *mtype)
{
    unsigned int hash = hashstring(mtype->name) % CRMAXHASH;
    crmessage_type *found = NULL;
    crmessage_type *type = crtypes[hash];
    while (type) {
        if (type->mtype == mtype)
            found = type;
        type = type->next;
    }
    return found;
}
示例#16
0
文件: arena.c 项目: UweKopf/server
void create_arena(void)
{
  int x;
  arena_id = hashstring("arena");
  arena = getplanebyid(arena_id);
  if (arena != NULL)
    return;
  score();                      /* ist wichtig, damit alle Parteien einen score haben, wenn sie durchs Tor wollen. */
  guardian_faction(arena, 999);
  if (arena)
    arena_center = findregion(plane_center_x(arena), plane_center_y(arena));
  if (!arena_center) {
    newarena = 1;
    arena =
      create_new_plane(arena_id, "Arena", -10000, -10000, 0, BLOCKSIZE - 1,
      PFL_LOWSTEALING | PFL_NORECRUITS | PFL_NOALLIANCES);
    block_create(arena->minx, arena->miny, T_OCEAN);
    arena_center = findregion(plane_center_x(arena), plane_center_y(arena));
    for (x = 0; x != BLOCKSIZE; ++x) {
      int y;
      for (y = 0; y != BLOCKSIZE; ++y) {
        region *r = findregion(arena->minx + x, arena->miny + y);
        freset(r, RF_ENCOUNTER);
        r->planep = arena;
        switch (distance(r, arena_center)) {
          case 4:
            terraform(r, T_FIREWALL);
            break;
          case 0:
            terraform(r, T_GLACIER);
            break;
          case 1:
            terraform(r, T_SWAMP);
            break;
          case 2:
            terraform(r, T_MOUNTAIN);
            break;
        }
      }
    }
  }
  make_temple(arena_center);
#ifdef CENTRAL_VOLCANO
  init_volcano();
#else
  if (arena_center->terrain != T_DESERT)
    terraform(arena_center, T_DESERT);
#endif
  rsetmoney(arena_center, 0);
  rsetpeasants(arena_center, 0);
  tower_init();
}
示例#17
0
struct wordrec * lookup(struct wordrec **table, int val)
{
	struct wordrec *curr = NULL;
	int hash = hashstring(val);
	printf("Hashstring for hash value %d is %d\n",val,hash);
	struct wordrec *wp,*nwp;

	printf("Table hash pointer is: %p\n",table);
	printf("Table hash pointer is: %p\n",table[hash]);
	if (table[hash]) {
		wp = table[hash];
	}
	else {
		table[hash] = (struct wordrec *)malloc(sizeof(struct wordrec));
		wp = table[hash];
			
	}

	int found = 0;
	for (curr = wp; curr != NULL; curr = curr->next) {
		/* search */
		printf("Curr pointer is %p with value %d\n",curr,curr->num);
		if (curr->num == val) {
			found = 1;
			curr->count++;
			break;
		}
	}

	printf("made it out\n");
	if (found == 0) {
		if (wp->count>0) {
			printf("Wp existing value for %d is: %d with count: %d\n",val,wp->num,wp->count);
			printf("Wp existing pointer is: %p\n",wp);
			nwp = (struct wordrec *)malloc(sizeof(struct wordrec));
			printf("nWp new pointer is: %p\n",nwp);
			nwp->num = val;
			nwp->count++;
			nwp->next = wp;
			table[hash] = nwp;
			curr = nwp;
		}
		else {
			wp->num = val;
			wp->count++;
			curr = wp;
		}
		/* add to front */;
	}
	return curr;
}
示例#18
0
文件: message.c 项目: Xolgrim/server
const message_type *mt_find(const char *name)
{
    unsigned int hash = hashstring(name) % MT_MAXHASH;
    quicklist *ql = messagetypes[hash];
    int qi;

    for (qi = 0; ql; ql_advance(&ql, &qi, 1)) {
        message_type *data = (message_type *)ql_get(ql, qi);
        if (strcmp(data->name, name) == 0) {
            return data;
        }
    }
    return 0;
}
示例#19
0
static void save_picture(struct membuffer *b, struct picture *pic)
{
	put_string(b, "  <picture filename='");
	put_quoted(b, pic->filename, true, false);
	put_string(b, "'");
	if (pic->offset.seconds) {
		int offset = pic->offset.seconds;
		char sign = '+';
		if (offset < 0) {
			sign = '-';
			offset = -offset;
		}
		put_format(b, " offset='%c%u:%02u min'", sign, FRACTION(offset, 60));
	}
	if (pic->latitude.udeg || pic->longitude.udeg) {
		put_degrees(b, pic->latitude, " gps='", " ");
		put_degrees(b, pic->longitude, "", "'");
	}
	if (hashstring(pic->filename))
		put_format(b, " hash='%s'", hashstring(pic->filename));

	put_string(b, "/>\n");
}
示例#20
0
// h=hash(g, g^r, g^x, name)
static void zkpHash(BIGNUM *h, const JPakeZKP *zkp, const BIGNUM *gx,
		    const JPakeUserPublic *from, const JPakeParameters *params)
    {
    unsigned char md[SHA_DIGEST_LENGTH];
    SHA_CTX sha;

    // XXX: hash should not allow moving of the boundaries - Java code
    // is flawed in this respect. Length encoding seems simplest.
    SHA1_Init(&sha);
    hashbn(&sha, params->g);
    hashbn(&sha, zkp->gr);
    hashbn(&sha, gx);
    hashstring(&sha, from->name);
    SHA1_Final(md, &sha);
    BN_bin2bn(md, SHA_DIGEST_LENGTH, h);
    }
示例#21
0
文件: test.c 项目: sjklawy/Klawy
int main(int argc, char *argv[]) {
    int N = 4; // max length string
    char str[N+1]; // the string holder
    int i; // counter

    unsigned int tot = 0; // number of hashes calculated

    for (i = 0; i < N; i++) str[i] = 'a';
    str[N] = 0;

    do {
        hashstring(str, N);
        tot++;
    } while(inc(str));

    printf("%d\n", tot);
}
示例#22
0
/* encryption */
int ccencrypt(reader *r, writer *w, char *keyword) {
  word32 state[8];
  word8 *statec = (word8 *)state;
  roundkey rkk;

  word32 key[8];
  int i, c, cc;
  int st;

  /* generate the roundkey */
  hashstring(keyword, key);
  xrijndaelKeySched(key, 256, 256, &rkk);
  
  /* make a nonce */
  make_nonce(state);
  
  /* mark the nonce with a "magic number". */
  strncpy(statec, MAGIC, 4);

  /* encrypt the nonce with the given keyword */
  xrijndaelEncrypt(state, &rkk);
  
  /* write the seed (header) */
  for (i=0; i<32; i++) {
    st = w->bputc(statec[i], w);
    if (st<0) return -1;
  }

  /* encrypt the body of the stream */
  c = r->bgetc(r);
  while (c != EOF) {
    xrijndaelEncrypt(state, &rkk);

    for (i=0; i<32 && c != EOF; i++) {
      cc = c ^ statec[i];
      statec[i] = cc;
      st = w->bputc(cc, w);
      if (st<0) return -1;
      c = r->bgetc(r);
    }
  }
  if (errno) 
    return -1;

  return w->beof(w);
}
示例#23
0
/* h=hash(g, g^r, g^x, name) */
static void zkp_hash(BIGNUM *h, const BIGNUM *zkpg, const JPAKE_STEP_PART *p,
		     const char *proof_name)
    {
    unsigned char md[SHA_DIGEST_LENGTH];
    SHA_CTX sha;

   /*
    * XXX: hash should not allow moving of the boundaries - Java code
    * is flawed in this respect. Length encoding seems simplest.
    */
    SHA1_Init(&sha);
    hashbn(&sha, zkpg);
    OPENSSL_assert(!BN_is_zero(p->zkpx.gr));
    hashbn(&sha, p->zkpx.gr);
    hashbn(&sha, p->gx);
    hashstring(&sha, proof_name);
    SHA1_Final(md, &sha);
    BN_bin2bn(md, SHA_DIGEST_LENGTH, h);
    }
示例#24
0
void
nrt_register(const struct message_type *mtype, const struct locale *lang,
const char *string, int level, const char *section)
{
    unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
    nrmessage_type *nrt = nrtypes[hash];
    while (nrt && (nrt->lang != lang || nrt->mtype != mtype)) {
        nrt = nrt->next;
    }
    if (nrt) {
        log_error("duplicate message-type %s\n", mtype->name);
        assert(!nrt || !"trying to register same nr-type twice");
    }
    else {
        int i;
        char zNames[256];
        char *c = zNames;
        nrt = malloc(sizeof(nrmessage_type));
        nrt->lang = lang;
        nrt->mtype = mtype;
        nrt->next = nrtypes[hash];
        nrt->level = level;
        if (section) {
            const nrsection *s = section_find(section);
            if (s == NULL) {
                s = section_add(section);
            }
            nrt->section = s->name;
        }
        else
            nrt->section = NULL;
        nrtypes[hash] = nrt;
        assert(string && *string);
        nrt->string = _strdup(string);
        *c = '\0';
        for (i = 0; i != mtype->nparameters; ++i) {
            if (i != 0)
                *c++ = ' ';
            c += strlcpy(c, mtype->pnames[i], sizeof(zNames)-(c-zNames));
        }
        nrt->vars = _strdup(zNames);
    }
}
示例#25
0
int ccdecrypt_init(ccrypt_stream_t *b, char *key, int flags) {
  word32 keyblock[8];
  ccrypt_state_t *st;
  
  st = malloc(sizeof(ccrypt_state_t));
  if (st == NULL) {
    b->state = NULL;
    return -1;
  }
  b->state = (void *)st;

  /* generate the roundkey */
  hashstring(key, keyblock);
  xrijndaelKeySched(keyblock, 256, 256, &st->rkk);
  
  /* Initialize rest of the state. */
  st->iv = 1;
  st->bufindex = 0;
  st->flags = flags;
  return 0;
}
示例#26
0
/*
  @function lookup
  @desc     returns a pointer to the word or creates
            it if required
*/
wordrec* lookup(const char* str, int create)
{
  unsigned long hash = hashstring(str);/*starting point*/
  wordrec *wp = table[hash];
  wordrec *curr = NULL;

  for (curr = wp; curr != NULL; curr = curr->next) {
    if (strcmp(curr->word, str) == 0) {
      return curr;
    }
  }

  /*if not found and create specified*/
  if (create)
  {
    curr = walloc(str);
    curr->next = wp;
    table[hash] = curr;
  }

  return curr;
}
示例#27
0
int ccdecrypt_multi_init(ccrypt_stream_t *b, int n, const char **keylist, int flags) {
  word32 keyblock[8];
  ccrypt_state_t *st;
  roundkey *rkks;
  int i;
  
  b->state = NULL;

  st = malloc(sizeof(ccrypt_state_t));
  if (st == NULL) {
    return -1;
  }
  rkks = malloc(n * sizeof(roundkey));
  if (!rkks) {
    free(st);
    return -1;
  }

  st->n = n;
  st->rkks = rkks;
  st->ak = 0;

  /* generate the roundkeys */
  for (i=0; i<n; i++) {
    hashstring(keylist[i], keyblock);
    xrijndaelKeySched(keyblock, 256, 256, &st->rkks[i]);
  }

  /* Initialize rest of the state. */
  st->iv = 1;
  st->bufindex = 0;
  st->flags = flags;

  b->state = (void *)st;
  return 0;
}
示例#28
0
int cckeychange(reader *r, writer *w, char *keyword_in, char *keyword_out) {
  /* --decrypt-- */
  word32 state_in[8];
  word32 seed_in[8];
  word8 *statec_in = (word8 *)state_in;
  word8 *seedchar_in = (word8 *)seed_in;
  roundkey rkk_in;

  /* --encrypt-- */
  word32 state_out[8];
  word8 *statec_out = (word8 *)state_out;
  roundkey rkk_out;

  /* --shared-- */
  word32 key[8];
  int i, c, cc;
  int st;

  /* --decrypt-- */
  /* generate the roundkey */
  hashstring(keyword_in, key);
  xrijndaelKeySched(key, 256, 256, &rkk_in);

  /* --encrypt-- */
  /* generate the roundkey */
  hashstring(keyword_out, key);
  xrijndaelKeySched(key, 256, 256, &rkk_out);
  
  /* --decrypt-- */
  /* read the seed */
  for (i=0; i<32; i++) {
    seedchar_in[i] = statec_in[i] = cc = r->bgetc(r);
    if (cc == EOF) {
      if (errno) return -1;
      else return 1;  /* error: less than 32 characters in file */
    }
  }
  
  /* decrypt the seed with the given keyword */
  xrijndaelDecrypt(seed_in, &rkk_in);
  
  /* check the "magic number". */
  if (strncmp(seedchar_in, MAGIC, 4)) {
    return 2;  /* error: wrong key or algorithm */
  }

  /* key seems to match; generate new header */

  /* --encrypt-- */
  /* make a nonce */
  make_nonce(state_out);

  /* mark the nonce with a "magic number". */
  strncpy(statec_out, MAGIC, 4);

  /* encrypt the nonce with the given keyword */
  xrijndaelEncrypt(state_out, &rkk_out);

  /* write the seed (header) */
  for (i=0; i<32; i++) {
    st = w->bputc(statec_out[i], w);
    if (st<0) return -1;
  }
  
  /* --common, interleaved-- */
  /* transform the body of the stream */
  cc = r->bgetc(r);
  while (cc != EOF) {
    xrijndaelEncrypt(state_in, &rkk_in);
    xrijndaelEncrypt(state_out, &rkk_out);
    
    for (i=0; i<32 && cc != EOF; i++) {
      c = cc ^ statec_in[i];
      statec_in[i] = cc;
      cc = c ^ statec_out[i];
      statec_out[i] = cc;
      st = w->bputc(cc, w);
      if (st<0) return -1;
      cc = r->bgetc(r);
    }
  }
  if (errno)
    return -1;

  return w->beof(w);
}
示例#29
0
void create_museum(void)
{
#if 0                           /* TODO: move this to Lua. It should be possible. */
    unsigned int museum_id = hashstring("museum");
    plane *museum = getplanebyid(museum_id);
    region *r;
    building *b;
    const terrain_type *terrain_hall = get_terrain("hall1");
    const terrain_type *terrain_corridor = get_terrain("corridor1");

    assert(terrain_corridor && terrain_hall);

    if (!museum) {
        museum = create_new_plane(museum_id, "Museum", 9500, 9550,
            9500, 9550, PFL_MUSEUM);
    }

    if (findregion(9525, 9525) == NULL) {
        /* Eingangshalle */
        r = new_region(9525, 9525, 0);
        terraform_region(r, terrain_hall);
        r->planep = museum;
        rsetname(r, "Eingangshalle");
        rsethorses(r, 0);
        rsetmoney(r, 0);
        rsetpeasants(r, 0);
        set_string(&r->display,
            "Die Eingangshalle des Großen Museum der 1. Welt ist bereits jetzt ein beeindruckender Anblick. Obwohl das Museum noch nicht eröffnet ist, vermittelt sie bereits einen Flair exotischer Welten. In den Boden ist ein großer Kompass eingelassen, der den Besuchern bei Orientierung helfen soll.");
    }

    r = findregion(9526, 9525);
    if (!r) {
        /* Lounge */
        r = new_region(9526, 9525, 0);
        terraform_region(r, terrain_hall);
        r->planep = museum;
        rsetname(r, "Lounge");
        rsethorses(r, 0);
        rsetmoney(r, 0);
        rsetpeasants(r, 0);
        set_string(&r->display,
            "Die Lounge des großen Museums ist ein Platz, in dem sich die Besucher treffen, um die Eindrücke, die sie gewonnen haben, zu verarbeiten. Gemütliche Sitzgruppen laden zum Verweilen ein.");
    }

    r = findregion(9526, 9525);
    if (!r->buildings) {
        const building_type *bt_generic = bt_find("generic");
        b = new_building(bt_generic, r, NULL);
        set_string(&b->name, "Séparée im dämonischen Stil");
        set_string(&b->display,
            "Diese ganz im dämonischen Stil gehaltene Sitzgruppe ist ganz in dunklen Schwarztönen gehalten. Muster fremdartiger Runen bedecken das merkwürdig geformte Mobiliar, das unangenehm lebendig wirkt.");

        b = new_building(bt_generic, r, NULL);
        set_string(&b->name, "Séparée im elfischen Stil");
        set_string(&b->display,
            "Ganz in Grün- und Brauntönen gehalten wirkt die Sitzgruppe fast lebendig. Bei näherer Betrachtung erschließt sich dem Betrachter, daß sie tatsächlich aus lebenden Pflanzen erstellt ist. So ist der Tisch aus einem eizigen Baum gewachsen, und die Polster bestehen aus weichen Grassoden. Ein wunderschön gemusterter Webteppich mit tausenden naturgetreu eingestickter Blumensarten bedeckt den Boden.");

        b = new_building(bt_generic, r, NULL);
        set_string(&b->name, "Séparée im halblingschen Stil");
        set_string(&b->display,
            "Dieses rustikale Mobiliar ist aus einem einzigen, gewaltigen Baum hergestellt worden. Den Stamm haben fleißige Halblinge der Länge nach gevierteilt und aus den vier langen Viertelstämmen die Sitzbänke geschnitzt, während der verbleibende Stumpf als Tisch dient. Schon von weitem steigen dem Besucher die Gerüche der Köstlichkeiten entgegen, die auf dem Tisch stapeln.");

        b = new_building(bt_generic, r, NULL);
        set_string(&b->name, "Séparée im orkischen Stil");
        set_string(&b->display,
            "Grobgeschreinerte, elfenhautbespannte Stühle und ein Tisch aus Knochen, über deren Herkunft man sich lieber keine Gedanken macht, bilden die Sitzgruppe im orkischen Stil. Überall haben Orks ihre Namen, und anderes wenig zitierenswertes in das Holz und Gebein geritzt.");

        b = new_building(bt_generic, r, NULL);
        set_string(&b->name, "Séparée im Meermenschenstil");
        set_string(&b->display,
            "Ganz in Blau- und Grüntönen gehalten, mit Algen und Muscheln verziert wirken die aus altem Meerholz geschnitzten Stühle immer ein wenig feucht. Seltsammerweise hat der schwere aus alten Planken gezimmerte Tisch einen Mast mit kompletten Segel in der Mitte.");

        b = new_building(bt_generic, r, NULL);
        set_string(&b->name, "Séparée im Katzenstil");
        set_string(&b->display,
            "Die Wände dieses Séparée sind aus dunklem Holz. Was aus der Ferne wie ein chaotisch durchbrochenes Flechtwerk wirkt, entpuppt sich bei näherer Betrachtung als eine bis in winzige Details gestaltete dschungelartige Landschaft, in die eine Vielzahl von kleinen Bildergeschichten eingewoben sind. Wie es scheint hat sich der Künstler Mühe gegeben wirklich jedes Katzenvolk Eresseas zu porträtieren. Das schummrige Innere wird von einem Kamin dominiert, vor dem einige Sessel und weiche Kissen zu einem gemütlichen Nickerchen einladen. Feiner Anduner Sisal bezieht die Lehnen der Sessel und verlockt dazu, seine Krallen hinein zu versenken. Auf einem kleinen Ecktisch steht ein großer Korb mit roten Wollknäulen und grauen und braunen Spielmäusen.");
    } else {
        for (b = r->buildings; b; b = b->next) {
            b->size = b->type->maxsize;
        }
    }

    r = findregion(9524, 9526);
    if (!r) {
        r = new_region(9524, 9526, 0);
        terraform_region(r, terrain_corridor);
        r->planep = museum;
        rsetname(r, "Nördliche Promenade");
        rsethorses(r, 0);
        rsetmoney(r, 0);
        rsetpeasants(r, 0);
        set_string(&r->display,
            "Die Nördliche Promenade führt direkt in den naturgeschichtlichen Teil des Museums.");
    }
    r = findregion(9525, 9524);
    if (!r) {
        r = new_region(9525, 9524, 0);
        terraform_region(r, terrain_corridor);
        r->planep = museum;
        rsetname(r, "Südliche Promenade");
        rsethorses(r, 0);
        rsetmoney(r, 0);
        rsetpeasants(r, 0);
        set_string(&r->display,
            "Die Südliche Promenade führt den Besucher in den kulturgeschichtlichen Teil des Museums.");
    }
#endif
}
示例#30
0
文件: qdict.c 项目: DiaosiDev/qnode
static int
mainposition(qdict_t *dict, const char *key) {
  return hashstring(key) % dict->hashsize;
}