Exemplo n.º 1
0
/*	  NULL otherwise.						*/
const char* req_nextSection(REQ_FILE* rf)
{
    int i;

    if(rf->sect_end==-1) return NULL;

    fseek(rf->fd, rf->sect_end, SEEK_SET);
    rf->sect_end= -1;

    req_readChar(rf);
    if(current(rf)!='[') return NULL;

    req_readChar(rf);
    i= 0;
    while(!eos(rf) && (current(rf)!=']') && (i<20)) {
        rf->sect_name[i++]= current(rf);
        req_readChar(rf);
    }
    rf->sect_name[i]='\0';
    if(current(rf)!=']') return NULL;

    req_skipLine(rf);

    rf->sect_start= ftell(rf->fd)-1;

    while(!eos(rf) && (current(rf)!='[')) req_skipLine(rf);
    rf->sect_end= ftell(rf->fd)-1;

    fseek(rf->fd, rf->sect_start, SEEK_SET);
    req_readChar(rf);
    req_skipComment(rf);

    return rf->sect_name;
}
Exemplo n.º 2
0
/* show "welcome [back] to DynaHack" message at program startup */
static void welcome(
    boolean new_game)	/* false => restoring an old game */
{
    char buf[BUFSZ];
    boolean currentgend = Upolyd ? u.mfemale : flags.female;

    /*
     * The "welcome back" message always describes your innate form
     * even when polymorphed or wearing a helm of opposite alignment.
     * Alignment is shown unconditionally for new games; for restores
     * it's only shown if it has changed from its original value.
     * Sex is shown for new games except when it is redundant; for
     * restores it's only shown if different from its original value.
     */
    *buf = '\0';
    if (new_game || u.ualignbase[A_ORIGINAL] != u.ualignbase[A_CURRENT])
	sprintf(eos(buf), "%s", align_str(u.ualignbase[A_ORIGINAL]));
    if (!urole.name.f &&
	    (new_game ? (urole.allow & ROLE_GENDMASK) == (ROLE_MALE|ROLE_FEMALE) :
	     currentgend != u.initgend))
	sprintf(eos(buf), "%s", genders[currentgend].adj + 2);

    pline(new_game ? "%s,%s,欢迎来到LoongHack!  你是%s%s%s。"
		   : "%s,%s,%s%s%s,欢迎回到LoongHack!",
	  Hello(NULL), plname, buf, urace.adj,
	  (currentgend && urole.name.f) ? urole.name.f : urole.name.m + 2);

    if (*level->levname)
	pline("You named this level: %s.", level->levname);
}
Exemplo n.º 3
0
/* append the level name to outbuf */
void
topten_level_name(int dnum, int dlev, char *outbuf)
{
    if (dnum == astral_level.dnum) {
        const char *arg, *fmt = "on the Plane of %s";

        switch (dlev) {
        case -5:
            fmt = "on the %s Plane";
            arg = "Astral";
            break;
        case -4:
            arg = "Water";
            break;
        case -3:
            arg = "Fire";
            break;
        case -2:
            arg = "Air";
            break;
        case -1:
            arg = "Earth";
            break;
        default:
            arg = "Void";
            break;
        }
        sprintf(eos(outbuf), fmt, arg);
    } else {
        sprintf(eos(outbuf), "in %s", dungeons[dnum].dname);
        if (dnum != knox_level.dnum)
            sprintf(eos(outbuf), " on level %d", dlev);
    }
}
Exemplo n.º 4
0
int
doset()
{
	char buf[BUFSZ];

	pline("What options do you want to set? ");
	getlin(buf);
	if(!buf[0] || buf[0] == '\033') {
	    (void) strlcpy(buf,"HACKOPTIONS=", sizeof buf);
	    (void) strlcat(buf, flags.female ? "female," : "male,", sizeof buf);
	    if(flags.standout) (void) strlcat(buf,"standout,", sizeof buf);
	    if(flags.nonull) (void) strlcat(buf,"nonull,", sizeof buf);
	    if(flags.nonews) (void) strlcat(buf,"nonews,", sizeof buf);
	    if(flags.time) (void) strlcat(buf,"time,", sizeof buf);
	    if(flags.notombstone) (void) strlcat(buf,"notombstone,", sizeof buf);
	    if(flags.no_rest_on_space)
		(void) strlcat(buf,"!rest_on_space,", sizeof buf);
	    if(flags.end_top != 5 || flags.end_around != 4 || flags.end_own){
		(void) snprintf(eos(buf), buf + sizeof buf - eos(buf),
			"endgame: %u topscores/%u around me",
			flags.end_top, flags.end_around);
		if(flags.end_own) (void) strlcat(buf, "/own scores", sizeof buf);
	    } else {
		char *eop = eos(buf);
		if(*--eop == ',') *eop = 0;
	    }
	    pline("%s", buf);
	} else
	    parseoptions(buf, FALSE);

	return(0);
}
 wchar_t curChar(bool allow_change = true){
         if(eof())
                 return '\0';
         if(eos() && allow_change){
                 pop();
                 return curChar();
         }else if(eos())
                 return '\0';
         return data.back()[positions.back()];
 }
Exemplo n.º 6
0
char *payload(char *cmd,int safer)
{
 char *retstr;
 char *tmp;
 retstr=(char*)malloc(4096);
 sprintf(retstr,".PS\n");

        //  %f is 8 bytes long the two values are  \\
       //  needed. the value was just the first one \\
      // that I had in there... it it ain't broke... \\

 tmp=eos(retstr);
 sprintf(tmp,"plot %5.20f \"%%n\"\n",safer,0xbffffa08);
 tmp=eos(retstr);
 sprintf(tmp,"sh X%sX\n",cmd);
 tmp=eos(retstr);
 sprintf(tmp,".PE\n");
 tmp=eos(retstr);
 sprintf(tmp,"This is the way we hack the printer,\n");
 tmp=eos(retstr);
 sprintf(tmp,"Hack the printer, hack the printer.\n");
 tmp=eos(retstr);
 sprintf(tmp,"This is the way we hack the printer,\n");
 tmp=eos(retstr);
 sprintf(tmp,"when they are running a vulnerable version\n");
 tmp=eos(retstr);
 sprintf(tmp,"of groff.\n");
 tmp=eos(retstr);
 return retstr;
}
void BlockIterator::seek(int64_t seekTimeUs) {
    mCluster = mSegment->GetCluster(seekTimeUs * 1000ll);
    mBlockEntry = mCluster != NULL ? mCluster->GetFirst() : NULL;

    while (!eos() && block()->GetTrackNumber() != mTrackNum) {
        advance();
    }

    while (!eos() && !mBlockEntry->GetBlock()->IsKey()) {
        advance();
    }
}
Exemplo n.º 8
0
char *nh_build_plselection_prompt(char *buf, int buflen, int rolenum, int racenum,
			       int gendnum, int alignnum)
{
	const char *defprompt = "需要我帮你选一个角色吗?";
	int num_post_attribs = 0;
	char tmpbuf[BUFSZ];
	
	if (buflen < QBUFSZ)
		return (char *)defprompt;

	strcpy(tmpbuf, "需要我选择");
	if (racenum != ROLE_NONE || validrole(rolenum))
		strcat(tmpbuf, "你的");
	else {
		strcat(tmpbuf, "一个");
	}
	/* <your> */

	nh_root_plselection_prompt(eos(tmpbuf), buflen - strlen(tmpbuf),
					rolenum, racenum, gendnum, alignnum);
	sprintf(buf, "%s", s_suffix(tmpbuf));

	/* buf should now be:
	 * < your lawful female gnomish cavewoman's> || <your lawful female gnome's>
	 *    || <your lawful female character's>
	 *
         * Now append the post attributes to it
	 */

	num_post_attribs = post_attribs;
	if (post_attribs) {
		if (pa[BP_RACE]) {
			promptsep(eos(buf), num_post_attribs);
			strcat(buf, "种族");
		}
		if (pa[BP_ROLE]) {
			promptsep(eos(buf), num_post_attribs);
			strcat(buf, "角色");
		}
		if (pa[BP_GEND]) {
			promptsep(eos(buf), num_post_attribs);
			strcat(buf, "性别");
		}
		if (pa[BP_ALIGN]) {
			promptsep(eos(buf), num_post_attribs);
			strcat(buf, "阵营");
		}
	}
	strcat(buf, "吗?");
	return buf;
}
Exemplo n.º 9
0
string_parse &string_parse::skipwhite()
{
    while (!eos() && std::isspace(static_cast<int>(*pos++)))
        ;
    --pos;
    return *this;
}
Exemplo n.º 10
0
 symbol::operator std::string() const{
   if( eos() ){
     return std::string("\\z");
   }else if( bos() ){
     return std::string("\\A");
   }else if( _val < 30 || _val > 0x7f ){
     std::stringstream result;
     if( _val > 0xffff ){
       result << "\\U";
       result.width(6); 
     }else{
       result << "\\u";
       result.width(4);
     }
     result.fill('0');
     result << std::right << std::hex << _val;
     return result.str();
   }else{
     std::string result;
     if( op() ){
       result += "\\";
     }
     result += static_cast<char>(_val);
     return result;
   }
 }
Exemplo n.º 11
0
char *msgtype_to_string(const struct nh_msgtype_rules *mt)
{
    unsigned int size;
    int i;
    char *buf, *bp, pattern[120];

    if (!mt || mt->num_rules == 0) {
	buf = strdup("");
	return buf;
    }

    /* 120 char pattern + 1-digit number + () + "" + , + ; < 128 chars */
    size = 128 * mt->num_rules;
    buf = malloc(size);
    if (!buf)
	return NULL;
    buf[0] = '\0';

    for (i = 0; i < mt->num_rules; i++) {
	strncpy(pattern, mt->rules[i].pattern, sizeof(pattern));
	pattern[sizeof(pattern) - 1] = '\0';

	/* replace '"' and '|' and ';' with '?' to simplify parsing */
	for (bp = pattern; *bp; bp++) {
	    if (*bp == '"' || *bp == '|' || *bp == ';')
		*bp = '?';
	}

	snprintf(eos(buf), 128, "(\"%s\"|%u);", pattern, mt->rules[i].action);
    }

    return buf;
}
Exemplo n.º 12
0
/* init code in the code list window */
void winCodeList_initcode(FILE *input)
{
    Ycodelist *c = y_code_new(input);
    y_code_dump(c);
    y_code_map(c);
    Ycodelist *cur;
    char buf[100];
    int i;
    GtkTreeIter iter;
    for (cur = c; cur; cur = cur->next) {
        memset(buf, 0, sizeof(buf));
        sprintf(buf, "%08X", cur->code->addr);
        gtk_list_store_append(winCodeList.lstCodeList, &iter);
        gtk_list_store_set(winCodeList.lstCodeList, &iter,
                           0, buf,
                           1, "",
                           2, cur->code->comment,
                           3, cur->code->addr,
                           -1);
        memset(buf, 0, sizeof(buf));
        for (i = 0; i < cur->code->count; ++i)
            sprintf(eos(buf), "%02X", cur->code->ins[i]);
        gtk_list_store_set(winCodeList.lstCodeList, &iter,
                           4, buf, -1);
    }
    y_code_free(c);
    rewind(input);
    gtk_tree_view_set_model(winCodeList.tvwCodeList,
                            GTK_TREE_MODEL(winCodeList.lstCodeList));
}
Exemplo n.º 13
0
static short
ScanPattern (char *s, short *pindex)
{
    small_short side, piece, square;
    skipbb(&s); /* skip blanks and comments */

    while (is_digit(*s))
    {
        pattern_data[(*pindex)++] = atoi(s);
        skipi(&s);
    }

    pattern_data[(*pindex)++] = END_OF_LINKS;
    skipbb(&s);

    while (!eos(s))
    {
        if (ScanPiece(&s, &side, &piece, &square))
        {
            return 1;
        }
        else
        {
            pattern_data[(*pindex)++] = piece;
            pattern_data[(*pindex)++] = (side ? -square : square);
        }

    }

    pattern_data[(*pindex)++] = END_OF_FIELDS;
    return 0;
}
Exemplo n.º 14
0
int FilteredFieldStream::field_count() {
  int numflds = 0;
  for (;!eos(); next()) {
    numflds++;
  }
  return numflds;
}
Exemplo n.º 15
0
char *
autopickup_to_string(const struct nh_autopickup_rules *ar)
{
    int size, i;
    char *buf, *bp, pattern[40];

    if (!ar || !ar->num_rules) {
        buf = strdup("");
        return buf;
    }

    /* at this point, size is an upper bound on the stringified length of ar 3
       stringified small numbers + a pattern with up to 40 chars < 64 chars */
    size = 64 * ar->num_rules;
    buf = malloc(size);
    buf[0] = '\0';

    for (i = 0; i < ar->num_rules; i++) {
        strncpy(pattern, ar->rules[i].pattern, sizeof (pattern));

        /* remove '"' and ';' from the pattern by replacing them by '?' (single 
           character wildcard), to simplify parsing */
        bp = pattern;
        while (*bp) {
            if (*bp == '"' || *bp == ';')
                *bp = '?';
            bp++;
        }

        snprintf(eos(buf), 64, "(\"%s\",%d,%u,%u);", pattern,
                 ar->rules[i].oclass, ar->rules[i].buc, ar->rules[i].action);
    }

    return buf;
}
Exemplo n.º 16
0
/* string "esc" before each line. esc==NULL would be interpreted as "". */
void dump_scratched_to (FILE *fp, char *esc)
{
    static char BUFFER [BUFFER_SIZE];
    char *end;
    int should_print_esc = TRUE;
    long position = 0, end_position;
    end_position = ftell (fp_scratch);
    if (end_position == 0) return;
    rewind (fp_scratch);
    while ( fgets (BUFFER, BUFFER_SIZE, fp_scratch) != NULL )
    {  /* there are stuff read */
	if (should_print_esc && (esc != NULL)) fputs (esc, fp);
	end = eos(BUFFER);
	position += end - BUFFER;
	if (position >= end_position)
	{
	    *(end + end_position - position) = EOS;
	    fputs (BUFFER, fp);
	    return;
	}
	else fputs (BUFFER, fp);
	should_print_esc = (*(end-1)=='\n');
    }
    clearerr (fp_scratch);
    return;
} /* end dump_scratched_to() */
Exemplo n.º 17
0
/* return the number of char copied to dest.				*/
int req_readMacId(REQ_FILE* rf, char* dest, int max)
{
    MACRO* mac;
    char*  mc_value;
    int    i;

    *dest= '\0';
    max= max-1;
    i= 0;

    req_skipComment(rf);
    while(!eos(rf) && (current(rf)=='$' || isidchar(current(rf))) && (i<max)) {

        if(current(rf)=='$') {
            mac= readMacro(rf);
            if(mac==NULL) {
                *dest= '\0';
                return -1;
            }
            mc_value= mac->value;
            while((i<max) && !END(mc_value)) {
                *(dest++)= *(mc_value++);
                i++;
            }
        } else {
            *(dest++)= current(rf);
            i++;
            req_readChar(rf);
        }
    }
    *dest= '\0';
    req_skipComment(rf);
    return i;
}
Exemplo n.º 18
0
 void skipBytes(size32_t size)
 {
     cur += size;
     available -= size;
     // call eos() to ensure stream->eos() is true if this class has got to the end of the stream
     eos();
 }
void BlockIterator::reset() {
    mCluster = mSegment->GetFirst();
    mBlockEntry = mCluster->GetFirst();

    while (!eos() && block()->GetTrackNumber() != mTrackNum) {
        advance();
    }
}
Exemplo n.º 20
0
/* fill and return the given buffer with the long nethack version string */
char *getversionstring(char *buf)
{
	strcpy(buf, VERSION_ID);
#if defined(BETA) && defined(BETA_INFO)
	sprintf(eos(buf), " %s", BETA_INFO);
#endif
	return buf;
}
Exemplo n.º 21
0
/*       -1 otherwise.							*/
int req_gotoSection(REQ_FILE* rf, char* section)
{
    char buff[21];
    int i;

    req_rewindFile(rf);

    while(1) {
        while(!eos(rf) && (current(rf)!='[')) req_skipLine(rf);
        if(eos(rf)) return -1;

        /* skip '[' */
        req_readChar(rf);
        i= 0;
        while(!eos(rf) && (current(rf)!=']') && (i<20)) {
            buff[i++]= current(rf);
            req_readChar(rf);
        }
        buff[i]= '\0';
        /* we've not find a closing sq bracket */
        if(current(rf)!=']') return -1;

        /* skip the rest of the line */
        req_skipLine(rf);

        /* have we find the correct section */
        if(strcmp(buff, section)==0) break;

        if(eos(rf)) return -1;
    }

    strcpy(rf->sect_name, section);
    rf->sect_start= ftell(rf->fd)-1;

    /* search the end of the section */
    while(!eos(rf) && (current(rf)!='[')) req_skipLine(rf);

    rf->sect_end= ftell(rf->fd)-1;

    fseek(rf->fd, rf->sect_start, SEEK_SET);
    req_readChar(rf);
    req_skipComment(rf);

    return 0;
}
Exemplo n.º 22
0
/* end of section or end of file is reached.				*/
int req_skipComment(REQ_FILE* rf)
{
    while(isspace(current(rf))) req_readChar(rf);
    while(current(rf)=='#') {
        while(!eos(rf) && (current(rf)!='\n')) req_readChar(rf);
        while(isspace(current(rf))) req_readChar(rf);
    }
    return current(rf);
}
Exemplo n.º 23
0
string_parse &string_parse::readword(std::string &text)
{
    text.clear();
    skipwhite();
    while (!std::isspace(static_cast<int>(*pos)) && !eos())
    {
        text += *pos++;
    }
    return *this;
}
Exemplo n.º 24
0
// compute pressures from equation of state and pressure/density^2
void compute_pressures(fluid f)
{
    for(particle* pp=f.particles; pp<f.particles+f.particle_count; pp++) {
	pp->density *= f.particle_mass * f.density_factor;
	// correction of undersampled density
	if (pp->samples < 0.9 * f.max_samples) pp->density = f.density;
	pp->pressure = eos(pp->density, f);
	pp->p_d2 = pp->pressure / pow(pp->density, 2);
    }
}
Exemplo n.º 25
0
 virtual ~CMergeReadStream()
 {
     if (stream) {
         char url[100];
         endpoint.getUrlStr(url,sizeof(url));
         PrintLog("SORT Merge READ: EOS via destructor for %s",url);
         stream->stop();
     }
     eos();
 }
void BlockIterator::advance() {
    while (!eos()) {
        if (mBlockEntry != NULL) {
            mBlockEntry = mCluster->GetNext(mBlockEntry);
        } else if (mCluster != NULL) {
            mCluster = mSegment->GetNext(mCluster);

            if (eos()) {
                break;
            }

            mBlockEntry = mCluster->GetFirst();
        }

        if (mBlockEntry != NULL
                && mBlockEntry->GetBlock()->GetTrackNumber() == mTrackNum) {
            break;
        }
    }
}
Exemplo n.º 27
0
static void
outheader(void)
{
char linebuf[BUFSZ];
char *bp;
	strcpy(linebuf, "Number Points  Name");
	bp = eos(linebuf);
	while(bp < linebuf + COLNO - 9) *bp++ = ' ';
	strcpy(bp, "Hp [max]");
	puts(linebuf);
}
void BlockIterator::reset() {
    Mutex::Autolock autoLock(mExtractor->mLock);

    mCluster = mExtractor->mSegment->GetFirst();
    mBlockEntry = NULL;
    mBlockEntryIndex = 0;

    do {
        advance_l();
    } while (!eos() && block()->GetTrackNumber() != mTrackNum);
}
Exemplo n.º 29
0
/* strcat(s, {c,'\0'}); */
char *
strkitten(char *s, char c)		/* append a character to a string (in place) */
        
       
{
    char *p = eos(s);

    *p++ = c;
    *p = '\0';
    return s;
}
Exemplo n.º 30
0
    virtual void stop()
    {
        if (stream) {
#ifdef _FULL_TRACE
            char url[100];
            endpoint.getUrlStr(url,sizeof(url));
            PrintLog("SORT Merge READ: stop for %s",url);
#endif
            stream->stop();
            eos();
        }
    }