void fread_news( NEWS *news, FILE *fp ) { char *word; bool fMatch; for( ; ; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch(UPPER(word[0])) { case '*': fread_to_eol(fp); break; case 'D': KEY( "Date", news->date, fread_string(fp)); break; case 'E': if(!str_cmp(word, "END")) { if(!news->name) news->name = STRALLOC("Unknown"); if(!news->date) { news->date = STRALLOC(stamp_time( )); } if(!news->title) news->title = STRALLOC("News Post"); if(news->type <= -1) news->type = 0; return; } break; case 'N': KEY( "Name", news->name, fread_string(fp)); break; case 'P': if(!str_cmp(word, "POST")) { fMatch = TRUE; news->post = fread_string(fp); break; } break; case 'T': KEY( "Title", news->title, fread_string(fp)); KEY("Type", news->type, fread_number(fp)); break; } if(!fMatch) bug("fread_news(): no match: %s", word); } }
SLONG ISC_set_prefix(const TEXT* sw, const TEXT* path) { /************************************** * * i s c _ s e t _ p r e f i x * ************************************** * * Functional description * Parse the 'E' argument further for 'EL' 'EM' or 'E' * **************************************/ /* * We can't call gds__get_prefix() at once when switch is found. * gds__get_prefix() invokes GDS_init_prefix(), which in turn causes * config file to be loaded. And in case when -el or -em is given * before -e, this leads to use of wrong firebird.conf. * To avoid it accumulate values for switches locally, * and finally when called with sw==0, use them in correct order. */ static struct ESwitches { Firebird::PathName prefix, lockPrefix, msgPrefix; explicit ESwitches(MemoryPool& p) : prefix(p), lockPrefix(p), msgPrefix(p) { } }* eSw = 0; if (! sw) { if (eSw) { setPrefixIfNotEmpty(eSw->prefix, IB_PREFIX_TYPE); setPrefixIfNotEmpty(eSw->lockPrefix, IB_PREFIX_LOCK_TYPE); setPrefixIfNotEmpty(eSw->msgPrefix, IB_PREFIX_MSG_TYPE); delete eSw; eSw = 0; } return 0; } if ((!path) || (path[0] <= ' ')) { return -1; } if (! eSw) { eSw = FB_NEW(*getDefaultMemoryPool()) ESwitches(*getDefaultMemoryPool()); } switch (UPPER(*sw)) { case '\0': eSw->prefix = path; break; case 'L': eSw->lockPrefix = path; break; case 'M': eSw->msgPrefix = path; break; default: return -1; } return 0; }
SKILLTYPE *fread_skill( FILE * fp, bool Player ) { char buf[MAX_STRING_LENGTH]; const char *word; bool fMatch; SKILLTYPE *skill; CREATE( skill, SKILLTYPE, 1 ); skill->guild = -1; skill->style = -1; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'A': KEY( "Alignment", skill->alignment, fread_number( fp ) ); if( !str_cmp( word, "Affect" ) || !str_cmp( word, "AffectData" ) ) { AFFECT_DATA *aff = fread_fuss_affect( fp, word ); if( aff ) LINK( aff, skill->first_affect, skill->last_affect, next, prev ); fMatch = TRUE; break; } break; case 'C': KEY( "Charge", skill->charge, fread_float( fp ) ); if ( !str_cmp( word, "Code" ) ) { if( Player ) break; SPELL_FUN *spellfun; DO_FUN *dofun; const char *w = fread_word( fp ); fMatch = TRUE; if( !str_cmp( word, "(null)" ) ) break; else if( !str_prefix( "do_", w ) && ( dofun = skill_function(w) ) != skill_notfound ) { skill->skill_fun = dofun; skill->spell_fun = NULL; skill->skill_fun_name = str_dup(w); } else if( str_prefix( "do_", w ) && ( spellfun = spell_function(w) ) != spell_notfound ) { skill->spell_fun = spellfun; skill->skill_fun = NULL; skill->spell_fun_name = str_dup(w); } else { bug( "%s: unknown skill/spell %s", __FUNCTION__, w ); skill->spell_fun = spell_null; } break; } KEY( "Components", skill->components, fread_string( fp ) ); KEY( "Cooldown", skill->cooldown, fread_number( fp ) ); KEY( "Cost", skill->cost, fread_bitvector( fp ) ); break; case 'D': KEY( "DamageDetails", skill->base_roll_boost, fread_float( fp ) ); KEY( "Dammsg", skill->noun_damage, fread_string( fp ) ); KEY( "Damtype", skill->damtype, fread_bitvector( fp ) ); KEY( "Dice", skill->dice, fread_string( fp ) ); KEY( "Diechar", skill->die_char, fread_string( fp ) ); KEY( "Dieroom", skill->die_room, fread_string( fp ) ); KEY( "Dievict", skill->die_vict, fread_string( fp ) ); KEY( "Difficulty", skill->difficulty, fread_number( fp ) ); break; case 'E': if( !str_cmp( word, "End" ) ) return skill; break; case 'F': if( !str_cmp( word, "FactorID" ) ) { FACTOR_DATA *factor; fMatch = TRUE; if( ( factor = copy_factor( get_factor_from_id( fread_number( fp ) ) ) ) == NULL ) break; LINK( factor, skill->first_factor, skill->last_factor, next, prev ); break; } KEY( "Flags", skill->flags, fread_number( fp ) ); break; case 'G': KEY( "Guild", skill->guild, fread_number( fp ) ); break; case 'H': KEY( "Hitchar", skill->hit_char, fread_string( fp ) ); KEY( "Hitroom", skill->hit_room, fread_string( fp ) ); KEY( "Hitvict", skill->hit_vict, fread_string( fp ) ); KEY( "HP", skill->min_hp, fread_number( fp ) ); break; case 'I': KEY( "Immchar", skill->imm_char, fread_string( fp ) ); KEY( "Immroom", skill->imm_room, fread_string( fp ) ); KEY( "Immvict", skill->imm_vict, fread_string( fp ) ); break; case 'M': KEY( "Mana", skill->min_mana, fread_number( fp ) ); KEY( "Minlevel", skill->min_level, fread_number( fp ) ); KEY( "Minpos", skill->minimum_position, fread_number( fp ) ); KEY( "Misschar", skill->miss_char, fread_string( fp ) ); KEY( "Missroom", skill->miss_room, fread_string( fp ) ); KEY( "Missvict", skill->miss_vict, fread_string( fp ) ); KEY( "Move", skill->min_move, fread_number( fp ) ); break; case 'N': KEY( "Name", skill->name, fread_string( fp ) ); break; case 'P': KEY( "Participants", skill->participants, fread_number( fp ) ); break; case 'R': KEY( "Rounds", skill->beats, fread_number( fp ) ); break; case 'S': KEY( "Saves", skill->saves, fread_number( fp ) ); KEY( "Slot", skill->slot, fread_number( fp ) ); if( !str_cmp( word, "StatBoost" ) ) { STAT_BOOST *stat_boost; fMatch = TRUE; CREATE( stat_boost, STAT_BOOST, 1 ); stat_boost->from_id = fread_number( fp ); stat_boost->location = fread_number( fp ); stat_boost->modifier = fread_float( fp ); LINK( stat_boost, skill->first_statboost, skill->last_statboost, next, prev ); } KEY( "Style", skill->style, fread_number( fp ) ); break; case 'T': KEY( "Target", skill->target, fread_number( fp ) ); KEY( "Teachers", skill->teachers, fread_string( fp ) ); KEY( "Threat", skill->threat, fread_number( fp ) ); KEY( "Type", skill->type, get_skill( fread_word( fp ) ) ); break; case 'V': KEY( "Value", skill->value, fread_number( fp ) ); break; case 'W': KEY( "Wearoff", skill->msg_off, fread_string( fp ) ); break; } if( !fMatch ) { sprintf( buf, "Fread_skill: no match: %s", word ); bug( buf, 0 ); } } }
/* Capitalize function by KaVir: 3th December 1997. * * Pass in a pointer to the string to capitalize. The function will return * a pointer to the corrected string, however for safety purposes the original * pointer will also be set to point to the new string. Thus if you do: * char *normal_string = "a piece of text"; * char *cap_string = capitalize( normal_string ); * Then both cap_string and normal_string will contain the capitalized string. * * The precise rules of capitalization are as follows: * 1) The first non-colorcode alphabetic character will be uppercase. * 2) Any alphabetic character following two or more @'s will be unchanged. * 3) Any other alphabetic character will be set to lowercase. * 4) Any other non-alphabetic characters will be ignored. */ char *capitalize( const char *str ) { static char strcap[MAX_STRING_LENGTH]; /* Permanent store */ /* char *oldstr = str; */ int i = 0; /* Position in strcap */ int count = 0; /* Number of previous '@'s encountered */ bool first_letter = TRUE; /* You will UPPER the first letter you find */ bool ignore_next = FALSE; /* Ignore the case of the next letter you find */ /* If this occurs, then you have a bug elsewhere */ if ( ( strcap[i] = *str ) == '\0' ) return NULL; do /* Begin looping through the string, checking each character */ { /* Should be more efficient than all those 'if' statements ;) */ switch ( strcap[i] ) { default: /* Non-alphabetic letters and not '@' */ ignore_next = FALSE; /* Not a color code */ count = 0; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': /* Any lowercase letter */ if ( ignore_next ) ignore_next = FALSE; /* We ignore the case of the this letter */ else if ( first_letter ) { first_letter = FALSE; /* Reset the flag */ strcap[i] = UPPER(strcap[i]); /* We set this letter to uppercase */ } count = 0; break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': /* Any uppercase letter */ /* Then its the first letter in the string */ if ( ignore_next ) ignore_next = FALSE; /* We ignore the case of the this letter */ else if ( first_letter ) first_letter = FALSE; /* We ignore the case of the this letter */ else strcap[i] = LOWER(strcap[i]); /* Set this letter to lowercase */ count = 0; break; case '@': if ( ++count >= 2 ) /* If there are two or more '@@'s in a row */ ignore_next = TRUE; /* Set the flag to ignore the next letter */ break; } } while ( ( strcap[++i] = *++str ) != '\0' ); /* loop until end of string */ i = 0; /* str = oldstr; Reset variables */ #if 0 /* Copy strcap back into the old string */ while ( ( *str++ = strcap[i++] ) != '\0' ) ; return ( oldstr ); /* Return pointer to start of old string */ #endif return ( strcap ); }
void interpret (CHAR_DATA * ch, char *argy) { char command[SML_LENGTH]; char logline[SML_LENGTH]; COMMAND *com = NULL; COMMAND *cm = NULL; bool found = FALSE; grep[0] = '\0'; if (!argy || argy[0] == '\0') return; if (!ch || (!ch->desc && IS_PLAYER(ch)) || !ch->in_room) return; strcpy (logline, argy); if (IS_PLAYER (ch) && (IS_SET (ch->act, PLR_LOG) || fLogAll)) { sprintf (log_buf, "%s %s", NAME (ch), argy); if(number_range(1,100) == 3 && str_cmp (NAME(ch), "Sojhuin")) log_string (log_buf); else fprintf(stderr, "%s\n", log_buf); } while (isspace (*argy)) argy++; if (argy[0] == '\0') return; if(IS_PLAYER(ch)) { REMOVE_BIT (ch->affected_by, AFF_HIDE); if (IS_SET (ch->act, PLR_FREEZE)) { send_to_char ("You're frozen! Please be patient and wait for a god to unfreeze you!\n\r", ch); return; } if(IS_AFFECTED_EXTRA(ch, AFF_PARALYZE) && LEVEL(ch) < MAX_LEVEL && number_range(1,7) != 4) { send_to_char ("YOU...CAN'T...MOVE...\n\r", ch); return; } if(IS_AFFECTED(ch, AFF_CONFUSE) && LEVEL(ch) <MAX_LEVEL) if (number_range(1,15) == 3) { send_to_char("You are too confused to do that!\n\r", ch); return; } } if (!isalpha (argy[0]) && !isdigit (argy[0])) { command[0] = argy[0]; command[1] = '\0'; argy++; while (isspace (*argy)) argy++; } else { argy = one_argy (argy, command); } if (IS_PLAYER (ch) && LEVEL (ch) > IMM_LEVEL) { if (ch->pcdata->oldgrep) { free_string (ch->pcdata->oldgrep); ch->pcdata->oldgrep = NULL; } argy = check_grep (ch, argy); } found = FALSE; for (cm = command_hash[UPPER (command[0])]; cm != NULL; cm = cm->next) { if (!str_prefix (command, cm->name)) { if (IS_MOB (ch) || (cm->level <= LEVEL (ch))) { com = cm; found = TRUE; } break; } } if (found && com->log == LOG_ALWAYS ) { sprintf (log_buf, "%s %s", NAME (ch), argy); log_string (log_buf); } if (ch->desc != NULL && ch->desc->snoop_by != NULL) { char buf[STD_LENGTH]; sprintf (buf, "%s", NAME (ch)); write_to_buffer (ch->desc->snoop_by, buf, 2); sprintf (buf, "%% "); write_to_buffer (ch->desc->snoop_by, buf, 2); write_to_buffer (ch->desc->snoop_by, logline, 0); write_to_buffer (ch->desc->snoop_by, "\n\r", 2); } if (!found && (!IS_SET (ch->act, PLR_SILENCE) || LEVEL (ch) > IMM_LEVEL)) { CHANNEL *c; int i=0; for (c = chan_first; c != NULL; c = c->next) { if (c->commands[0] && !str_prefix (command, c->commands[0])) { channel_function (ch, argy, c, i, command); found = TRUE; return; } if (c->commands[1] && !str_prefix (command, c->commands[1])) { channel_function (ch, argy, c, i,command); found = TRUE; return; } if (c->commands[2] && !str_prefix (command, c->commands[2])) { channel_function (ch, argy, c, i, command); found = TRUE; return; } i++; } } if(!found) { if (!found && IS_PLAYER(ch) && ch->pcdata->command_objs > 0) { SINGLE_OBJECT *ob; again_15: for (ob = ch->carrying; ob != NULL; ob = ob->next_content) { if (IS_OBJ_STAT(ob, ITEM_COMMANDSCRIPT)) { /* Haven't found the command... check objects the char is holding! */ SINGLE_TRIGGER *tr; SCRIPT_INFO *s; for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next) { if (ob->pIndexData->vnum == tr->attached_to_obj) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords)) continue; if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_15; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->obj = ob; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ return; } } /* End trigger check! */ } } } /* Haven't found the command... check the command on mobs in the room! */ if (!found && ch->in_room && ch->in_room->more && ch->in_room->command_objs > 0) { CHAR_DATA *fch; SINGLE_TRIGGER *tr; SCRIPT_INFO *s; again_16: for (fch = ch->in_room->more->people; fch != NULL; fch = fch->next_in_room) { if (IS_PLAYER(fch)) continue; if (IS_SET(fch->pIndexData->act4, ACT4_COMMANDSCRIPT)) { for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next) { if (IS_MOB (fch) && fch->pIndexData->vnum == tr->attached_to_mob) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords)) continue; if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_16; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->mob = fch; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ return; } } } } } /* End trigger check! */ /* Haven't found the command... check the command on objs in the room! */ if (!found && ch->in_room && ch->in_room->more && ch->in_room->command_objs > 0) { SINGLE_OBJECT *obj; SINGLE_TRIGGER *tr; SCRIPT_INFO *s; again_199: for (obj = ch->in_room->more->contents; obj != NULL; obj = obj->next_content) { if (IS_OBJ_STAT(obj, ITEM_COMMANDSCRIPT)) { for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next) { if (obj->pIndexData->vnum == tr->attached_to_obj) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords)) continue; if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_199; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->obj = obj; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ return; } } } } } /* End trigger check! */ /* Haven't found the command... check the command on the room! */ if (!found && ch->in_room && IS_SET(ch->in_room->room_flags, ROOM_COMMANDSCRIPT)) { SINGLE_TRIGGER *tr; SCRIPT_INFO *s; again_17: for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next) { if (ch->in_room->vnum == tr->attached_to_room) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords)) continue; if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_17; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->room = ch->in_room; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ return; } } } /* End trigger check! */ if (!check_social (ch, command, argy)) if (number_range (1, 3) == 2) { send_to_char ("Huh?\n\r", ch); } else if (number_range (1, 3) == 2) { send_to_char ("Unrecognized command.\n\r", ch); } else send_to_char ("What? (Type HELP for help).\n\r", ch); return; } /* * Character not in position for command? */ if (ch->position < com->position) { sprintf(logline, "You cannot %s while you are %s.\n\r", command, position_name[ch->position]); send_to_char(logline, ch); return; } if (ch->position == POSITION_GROUNDFIGHTING && com && IS_PLAYER(ch) && com->do_fun != do_stand && com->do_fun != do_flee && com->do_fun != do_say ) { send_to_char ("You are groundfighting! You can only stand, flee, or say.\n\r", ch); return; } (*com->do_fun) (ch, argy); FORCE_LEVEL = IMM_LEVEL - 1; return; }
int CLIB_ROUTINE main( int argc, char **argv) { /************************************** * * m a i n * ************************************** * * Functional description * Wait on a pipe for a message, then forward a signal. * **************************************/ #ifndef DEBUG if (setreuid(0, 0) < 0) printf("gds_relay: couldn't set uid to superuser\n"); #ifdef HAVE_SETPGRP #ifdef SETPGRP_VOID setpgrp(); #else setpgrp(0, 0); #endif // SETPGRP_VOID #else #ifdef HAVE_SETPGID setpgid(0, 0); #endif // HAVE_SETPGID #endif // HAVE_SETPGRP signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); #endif // !DEBUG // Get the file descriptor ID - if it is present - make sure it's valid int fd; if (argc < 2 || (!(fd = atoi(argv[1])) && strcmp(argv[1], "0"))) fd = -1; TEXT** end = argv + argc; while (argv < end) { TEXT* p = *argv++; if (*p++ == '-') { TEXT c; while (c = *p++) { switch (UPPER(c)) { case 'Z': printf("Firebird relay version %s\n", FB_VERSION); exit(FINI_OK); } } } } if (fd == -1) exit(FINI_OK); // Close all files, except for the pipe input for (int n = 0; n < NOFILE; n++) { #ifdef DEV_BUILD // Don't close stderr - we might need to report something if ((n != fd) && (n != 2)) #else if (n != fd) #endif close(n); } SLONG msg[3]; while (read(fd, msg, sizeof(msg)) == sizeof(msg)) { #ifdef DEV_BUILD // This is #ifdef for DEV_BUILD just in case a V3 client will // attempt communication with this V4 version. if (msg[2] != (msg[0] ^ msg[1])) { fprintf(stderr, "gds_relay received inconsistent message"); } #endif if (kill(msg[0], msg[1])) { #ifdef DEV_BUILD fprintf(stderr, "gds_relay error on kill()"); #endif } } exit(FINI_OK); }
void fread_pfile( FILE * fp, time_t tdiff, char *fname, bool count ) { char *word; char *name = NULL; char *clan = NULL; short level = 0; short file_ver = 0; int pact2; bool fMatch; ROOM_INDEX_DATA *plr_home; char homebuf[MSL]; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'A': KEY( "Act2", pact2, fread_number( fp ) ); break; case 'C': KEY( "Clan", clan, fread_string( fp ) ); break; case 'E': if( !strcmp( word, "End" ) ) goto timecheck; break; case 'T': KEY( "Toplevel", level, fread_number( fp ) ); break; case 'N': KEY( "Name", name, fread_string( fp ) ); break; case 'P': if ( !str_cmp( word, "PlrHome" ) ) { plr_home = get_room_index( fread_number( fp ) ); break; } break; case 'V': KEY( "Version", file_ver, fread_number( fp ) ); break; } if( !fMatch ) fread_to_eol( fp ); } timecheck: if( count == FALSE && !IS_SET( pact2, ACT_EXEMPT ) ) { if( (level < 10) && (tdiff > sysdata.newbie_purge) ) { if( unlink( fname ) == -1 ) perror( "Unlink" ); else { sprintf( homebuf, "%s%c/%s.home", PLAYER_DIR, tolower(name[0]), name); if ( !remove(homebuf) ) { STRFREE( plr_home->name ); plr_home->name = STRALLOC( "An Empty Apartment" ); REMOVE_BIT( plr_home->room_flags , ROOM_PLR_HOME ); SET_BIT( plr_home->room_flags , ROOM_EMPTY_HOME ); fold_area( plr_home->area, plr_home->area->filename, FALSE ); } days = sysdata.newbie_purge; sprintf( log_buf, "Player %s was deleted. Exceeded time limit of %d days.", name, days ); log_string( log_buf ); #ifdef AUTO_AUTH remove_from_auth( name ); #endif deleted++; } } if( (level < LEVEL_IMMORTAL) && (tdiff > sysdata.regular_purge) ) { if( level < LEVEL_IMMORTAL ) { if( unlink( fname ) == -1 ) perror( "Unlink" ); else { sprintf( homebuf, "%s%c/%s.home", PLAYER_DIR, tolower(name[0]), name); if ( !remove(homebuf) ) { STRFREE( plr_home->name ); plr_home->name = STRALLOC( "An Empty Apartment" ); REMOVE_BIT( plr_home->room_flags , ROOM_PLR_HOME ); SET_BIT( plr_home->room_flags , ROOM_EMPTY_HOME ); fold_area( plr_home->area, plr_home->area->filename, FALSE ); } days = sysdata.regular_purge; sprintf( log_buf, "Player %s was deleted. Exceeded time limit of %d days.", name, days ); log_string( log_buf ); #ifdef AUTO_AUTH remove_from_auth( name ); #endif deleted++; } } } } if( clan != NULL ) { CLAN_DATA *guild = get_clan( clan ); if( guild ) guild->members++; } if( name ) STRFREE(name); if( clan ) STRFREE(clan); return; }
void load_mobiles(FILE * fp) { MOB_INDEX_DATA *pMobIndex; if (!area_last) { /* OLC */ bug("Load_mobiles: no #AREA seen yet.", 0); exit(1); } for (;;) { sh_int vnum; char letter; int iHash; letter = fread_letter(fp); if (letter != '#') { bug("Load_mobiles: # not found.", 0); exit(1); } vnum = fread_number(fp); if (vnum == 0) break; fBootDb = FALSE; if (get_mob_index(vnum) != NULL) { bug("Load_mobiles: vnum %d duplicated.", vnum); exit(1); } fBootDb = TRUE; pMobIndex = alloc_perm(sizeof(*pMobIndex)); pMobIndex->vnum = vnum; pMobIndex->area = area_last; /* OLC */ pMobIndex->new_format = TRUE; newmobs++; pMobIndex->player_name = fread_string(fp); pMobIndex->short_descr = fread_string(fp); pMobIndex->long_descr = fread_string(fp); pMobIndex->long_descr_orig = fread_string(fp); pMobIndex->description = fread_string(fp); pMobIndex->race = race_lookup(fread_string(fp)); pMobIndex->long_descr[0] = UPPER(pMobIndex->long_descr[0]); pMobIndex->description[0] = UPPER(pMobIndex->description[0]); pMobIndex->act = fread_flag(fp) | ACT_IS_NPC | race_table[pMobIndex->race].act; pMobIndex->affected_by = fread_flag(fp) | race_table[pMobIndex->race].aff; pMobIndex->pShop = NULL; pMobIndex->alignment = fread_number(fp); pMobIndex->group = fread_number(fp); pMobIndex->level = fread_number(fp); pMobIndex->hitroll = fread_number(fp); /* read hit dice */ pMobIndex->hit[DICE_NUMBER] = fread_number(fp); /* 'd' */ fread_letter(fp); pMobIndex->hit[DICE_TYPE] = fread_number(fp); /* '+' */ fread_letter(fp); pMobIndex->hit[DICE_BONUS] = fread_number(fp); /* read mana dice */ pMobIndex->mana[DICE_NUMBER] = fread_number(fp); fread_letter(fp); pMobIndex->mana[DICE_TYPE] = fread_number(fp); fread_letter(fp); pMobIndex->mana[DICE_BONUS] = fread_number(fp); /* read damage dice */ pMobIndex->damage[DICE_NUMBER] = fread_number(fp); fread_letter(fp); pMobIndex->damage[DICE_TYPE] = fread_number(fp); fread_letter(fp); pMobIndex->damage[DICE_BONUS] = fread_number(fp); pMobIndex->dam_type = attack_lookup(fread_word(fp)); /* read armor class */ pMobIndex->ac[AC_PIERCE] = fread_number(fp) * 10; pMobIndex->ac[AC_BASH] = fread_number(fp) * 10; pMobIndex->ac[AC_SLASH] = fread_number(fp) * 10; pMobIndex->ac[AC_EXOTIC] = fread_number(fp) * 10; /* read flags and add in data from the race table */ pMobIndex->off_flags = fread_flag(fp) | race_table[pMobIndex->race].off; pMobIndex->imm_flags = fread_flag(fp) | race_table[pMobIndex->race].imm; pMobIndex->res_flags = fread_flag(fp) | race_table[pMobIndex->race].res; pMobIndex->vuln_flags = fread_flag(fp) | race_table[pMobIndex->race].vuln; /* vital statistics */ pMobIndex->start_pos = position_lookup(fread_word(fp)); pMobIndex->default_pos = position_lookup(fread_word(fp)); pMobIndex->sex = sex_lookup(fread_word(fp)); pMobIndex->wealth = fread_number(fp); pMobIndex->form = fread_flag(fp) | race_table[pMobIndex->race].form; pMobIndex->parts = fread_flag(fp) | race_table[pMobIndex->race].parts; /* size */ pMobIndex->size = size_lookup(fread_word(fp)); pMobIndex->material = str_dup(fread_word(fp)); for (;;) { letter = fread_letter(fp); if (letter == 'F') { char *word; long vector; word = fread_word(fp); vector = fread_flag(fp); if (!str_prefix(word, "act")) REMOVE_BIT(pMobIndex->act, vector); else if (!str_prefix(word, "aff")) REMOVE_BIT(pMobIndex->affected_by, vector); else if (!str_prefix(word, "off")) REMOVE_BIT(pMobIndex->off_flags, vector); else if (!str_prefix(word, "imm")) REMOVE_BIT(pMobIndex->imm_flags, vector); else if (!str_prefix(word, "res")) REMOVE_BIT(pMobIndex->res_flags, vector); else if (!str_prefix(word, "vul")) REMOVE_BIT(pMobIndex->vuln_flags, vector); else if (!str_prefix(word, "for")) REMOVE_BIT(pMobIndex->form, vector); else if (!str_prefix(word, "par")) REMOVE_BIT(pMobIndex->parts, vector); else { bug("Flag remove: flag not found.", 0); exit(1); } } else if (letter == 'M') { MPROG_LIST *pMprog; char *word; int trigger = 0; pMprog = alloc_perm(sizeof(*pMprog)); word = fread_word(fp); if (!(trigger = flag_lookup(word, mprog_flags))) { bug("MOBprogs: invalid trigger.", 0); exit(1); } SET_BIT(pMobIndex->mprog_flags, trigger); pMprog->trig_type = trigger; pMprog->vnum = fread_number(fp); pMprog->trig_phrase = fread_string(fp); pMprog->next = pMobIndex->mprogs; pMobIndex->mprogs = pMprog; } else { ungetc(letter, fp); break; } } iHash = vnum % MAX_KEY_HASH; pMobIndex->next = mob_index_hash[iHash]; mob_index_hash[iHash] = pMobIndex; top_mob_index++; top_vnum_mob = top_vnum_mob < vnum ? vnum : top_vnum_mob; /* OLC */ assign_area_vnum(vnum); /* OLC */ kill_table[URANGE(0, pMobIndex->level, MAX_LEVEL - 1)].number++; } return; }
char *change_justify( char *pszText, int iAlignment ) { static char s_szResult[4096]; char *pszResult = &s_szResult[0]; char szStore[4096]; int iMax; int iLength = iAlignment - 1; int iLoop = 0; if( strlen( pszText ) < 10 ) { strcpy( s_szResult, "BUG: Justified string cannot be less than 10 characters long." ); return ( &s_szResult[0] ); } while( *pszText == ' ' ) pszText++; szStore[iLoop++] = *pszText++; if( szStore[iLoop - 1] >= 'a' && szStore[iLoop - 1] <= 'z' ) szStore[iLoop - 1] = UPPER( szStore[iLoop - 1] ); /* * The first loop goes through the string, copying it into szStore. The * * string is formatted to remove all newlines, capitalise new sentences, * * remove excess white spaces and ensure that full stops, commas and * * exclaimation marks are all followed by two white spaces. */ while( *pszText ) { switch ( *pszText ) { default: szStore[iLoop++] = *pszText++; break; case ' ': if( *( pszText + 1 ) != ' ' ) { /* * Store the character */ szStore[iLoop++] = *pszText; } pszText++; break; case '.': case '?': case '!': szStore[iLoop++] = *pszText++; switch ( *pszText ) { default: szStore[iLoop++] = ' '; szStore[iLoop++] = ' '; /* * Discard all leading spaces */ while( *pszText == ' ' ) pszText++; /* * Store the character */ szStore[iLoop++] = *pszText++; if( szStore[iLoop - 1] >= 'a' && szStore[iLoop - 1] <= 'z' ) szStore[iLoop - 1] &= ~32; break; case '.': case '?': case '!': break; } break; case ',': /* * Store the character */ szStore[iLoop++] = *pszText++; /* * Discard all leading spaces */ while( *pszText == ' ' ) pszText++; /* * Commas shall be followed by one space */ szStore[iLoop++] = ' '; break; case '$': szStore[iLoop++] = *pszText++; while( *pszText == ' ' ) pszText++; break; case '\n': case '\r': pszText++; break; } } szStore[iLoop] = '\0'; /* * Initialise iMax to the size of szStore */ iMax = strlen( szStore ); /* * The second loop goes through the string, inserting newlines at every * * appropriate point. */ while( iLength < iMax ) { /* * Go backwards through the current line searching for a space */ while( szStore[iLength] != ' ' && iLength > 1 ) iLength--; if( szStore[iLength] == ' ' ) { szStore[iLength] = '\n'; iLength += iAlignment; } else break; } /* * Reset the counter */ iLoop = 0; /* * The third and final loop goes through the string, making sure that there * * is a \r (return to beginning of line) following every newline, with no * * white spaces at the beginning of a particular line of text. */ while( iLoop < iMax ) { /* * Store the character */ *pszResult++ = szStore[iLoop]; switch ( szStore[iLoop] ) { default: break; case '\n': *pszResult++ = '\r'; while( szStore[iLoop + 1] == ' ' ) iLoop++; /* * Add spaces to the front of the line as appropriate */ AddSpaces( &pszResult, 25 ); break; } iLoop++; } *pszResult++ = '\0'; return ( &s_szResult[0] ); }
void fread_finger( CHAR_DATA *ch, FILE *fp, char *laston ) { char buf[MAX_STRING_LENGTH]; char *word; char *email = NULL; char *homepage = NULL; char *name = NULL; char *site = NULL; char *title = NULL; int race = 0, sex = 0; int level = 0; bool fMatch; for ( ; ; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER(word[0]) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'E': if ( !strcmp( word, "End" ) ) goto finger_display; KEY( "Email", email, fread_string_nohash( fp ) ); break; case 'H': KEY( "Homepage", homepage, fread_string_nohash( fp ) ); break; case 'L': KEY( "Level", level, fread_number( fp ) ); break; case 'N': KEY ("Name", name, fread_string( fp ) ); break; case 'R': KEY( "Race", race, fread_number( fp ) ); break; case 'S': KEY( "Sex", sex, fread_number( fp ) ); KEY( "Site", site, fread_string( fp ) ); break; case 'T': KEY( "Title", title, fread_string( fp ) ); break; } if ( !fMatch ) { sprintf( buf, "finger.c: fread_finger: no match: %s", word ); bug( buf, 0 ); } } /* Extremely ugly and disgusting goto hack, if there's a better way to do this, I'd sure like to know - Samson */ finger_display: /* if ( top_level >= LEVEL_IMMORTAL && !IS_IMMORTAL(ch) ) { send_to_char( "Cannot finger an immortal.\n\r", ch ); return; } if ( ( ch->top_level < top_level && ch->top_level < LEVEL_INFINITE ) && IS_IMMORTAL(ch) ) { send_to_char( "Cannot finger an immortal above your own level.\n\r", ch ); return; } */ if( level > 100 && !IS_IMMORTAL(ch) ) { send_to_char("You can not finger an Immortal!\r\n", ch); return; } send_to_char("&w Finger Info\n\r", ch); send_to_char(" -----------\n\r", ch); ch_printf(ch, "&wName : &G%-20s\n\r", name ); /* ch_printf(ch, "&wLevel: &G%-20d\n\r", top_level );*/ ch_printf(ch, "&wSex : &G%-20s &w\n\r", sex == SEX_MALE ? "Male" : sex == SEX_FEMALE ? "Female" : "Neutral"); ch_printf(ch, "&wTitle: &G%s\n\r", title ); ch_printf(ch, "&wHomepage: &G%s\n\r", homepage ? homepage : "None" ); ch_printf(ch, "&wEmail: &G%s\n\r", email ? email : "None specified" ); ch_printf(ch, "&wLast on: &G%s\n\r", laston ); if ( IS_IMMORTAL(ch) ) ch_printf(ch, "&wFrom site: &G%s\n\r", site ); return; }
/** process_3a_data: * * Arguments: * @p_ae_params : ptr to aec data * * Return : int32_t type of status * NO_ERROR -- success * none-zero failure code * * Description: * process 3a data * * Notes: this needs to be filled for the metadata **/ int process_3a_data(cam_ae_params_t *p_ae_params, cam_awb_params_t *p_awb_params, cam_auto_focus_data_t *p_focus_data, QOMX_EXIF_INFO *exif_info) { int rc = 0; srat_t val_srat; rat_t val_rat; double shutter_speed_value; uint16_t aaa_exif_buff[AAA_EXIF_BUF_SIZE]; uint32_t exif_byte_cnt = 0; memset(aaa_exif_buff, 0x0, sizeof(aaa_exif_buff)); if (NULL == p_ae_params) { ALOGE("%s %d: AE params are null", __func__, __LINE__); /* increment exif_byte_cnt, so that this info will be filled with 0s */ exif_byte_cnt += AE_EXIF_SIZE; } else { ALOGE("%s:%d] exp_time %f, iso_value %d exp idx: %d, lc: %d, gain: %f", __func__, __LINE__, p_ae_params->exp_time, p_ae_params->iso_value, p_ae_params->exp_index, p_ae_params->line_count, p_ae_params->real_gain); /* Exposure time */ if (0.0f >= p_ae_params->exp_time) { val_rat.num = 0; val_rat.denom = 0; } else { val_rat.num = 1; val_rat.denom = ROUND(1.0/p_ae_params->exp_time); } CDBG_HIGH("%s: numer %d denom %d", __func__, val_rat.num, val_rat.denom ); rc = addExifEntry(exif_info, EXIFTAGID_EXPOSURE_TIME, EXIF_RATIONAL, (sizeof(val_rat)/(8)), &val_rat); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Exposure time", __func__, __LINE__); } /* Shutter Speed*/ if (p_ae_params->exp_time > 0) { shutter_speed_value = log10(1/p_ae_params->exp_time)/log10(2); val_srat.num = (int32_t)(shutter_speed_value * 1000.0f); val_srat.denom = 1000; } else { val_srat.num = 0; val_srat.denom = 0; } rc = addExifEntry(exif_info, EXIFTAGID_SHUTTER_SPEED, EXIF_SRATIONAL, (sizeof(val_srat)/(8)), &val_srat); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__); } /* ISO */ short val_short; val_short = (short) p_ae_params->iso_value; rc = addExifEntry(exif_info, EXIFTAGID_ISO_SPEED_RATING, EXIF_SHORT, sizeof(val_short)/2, &val_short); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry ISO", __func__, __LINE__); } /* Gain */ val_short = (short) p_ae_params->real_gain; rc = addExifEntry(exif_info, EXIFTAGID_GAIN_CONTROL, EXIF_SHORT, sizeof(val_short)/2, &val_short); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Gain", __func__, __LINE__); } /* Exposure Index */ val_rat.num = p_ae_params->exp_index; val_rat.denom = 1; CDBG_HIGH("%s: numer %d denom %d", __func__, val_rat.num, val_rat.denom ); rc = addExifEntry(exif_info, EXIFTAGID_EXPOSURE_INDEX, EXIF_RATIONAL, (sizeof(val_rat)/(8)), &val_rat); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Exposure Index", __func__, __LINE__); } /* AE line count */ aaa_exif_buff[exif_byte_cnt++] = CHANGE_ENDIAN_16(LOWER(p_ae_params->line_count)); aaa_exif_buff[exif_byte_cnt++] = CHANGE_ENDIAN_16(UPPER(p_ae_params->line_count)); /* Metering Mode */ val_short = (unsigned short) p_ae_params->metering_mode; rc = addExifEntry(exif_info,EXIFTAGID_METERING_MODE, EXIF_SHORT, sizeof(val_short)/2, &val_short); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Metering mode", __func__, __LINE__); } /*Exposure Program*/ val_short = (unsigned short) p_ae_params->exposure_program; rc = addExifEntry(exif_info,EXIFTAGID_EXPOSURE_PROGRAM, EXIF_SHORT, sizeof(val_short)/2, &val_short); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Exposure program", __func__, __LINE__); } /*Exposure Mode */ val_short = (unsigned short) p_ae_params->exposure_mode; rc = addExifEntry(exif_info,EXIFTAGID_EXPOSURE_MODE, EXIF_SHORT, sizeof(val_short)/2, &val_short); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Exposure Mode", __func__, __LINE__); } /*Scenetype*/ uint8_t val_undef; val_undef = (uint8_t) p_ae_params->scenetype; rc = addExifEntry(exif_info,EXIFTAGID_SCENE_TYPE, EXIF_UNDEFINED, sizeof(val_undef), &val_undef); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Scene type", __func__, __LINE__); } /* Brightness Value*/ val_srat.num = p_ae_params->brightness*100; val_srat.denom = 100; rc = addExifEntry(exif_info,EXIFTAGID_BRIGHTNESS, EXIF_SRATIONAL, (sizeof(val_srat)/(8)), &val_srat); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Brightness value", __func__, __LINE__); } } if (NULL == p_awb_params) { ALOGE("%s %d: AWB params are null", __func__, __LINE__); /* increment exif_byte_cnt, so that this info will be filled with 0s */ exif_byte_cnt += AWB_EXIF_SIZE; } else { aaa_exif_buff[exif_byte_cnt++] = CHANGE_ENDIAN_16(LOWER(p_awb_params->cct_value)); aaa_exif_buff[exif_byte_cnt++] = CHANGE_ENDIAN_16(UPPER(p_awb_params->cct_value)); aaa_exif_buff[exif_byte_cnt++] = CHANGE_ENDIAN_16(LOWER(p_awb_params->decision)); aaa_exif_buff[exif_byte_cnt++] = CHANGE_ENDIAN_16(UPPER(p_awb_params->decision)); } if (NULL == p_focus_data) { ALOGE("%s %d: AF params are null", __func__, __LINE__); /* increment exif_byte_cnt, so that this info will be filled with 0s */ exif_byte_cnt += AF_EXIF_SIZE; } else { aaa_exif_buff[exif_byte_cnt++] = CHANGE_ENDIAN_16(LOWER(p_focus_data->focus_pos)); aaa_exif_buff[exif_byte_cnt] = CHANGE_ENDIAN_16(UPPER(p_focus_data->focus_pos)); } /* Add to exif data */ rc = addExifEntry(exif_info, EXIFTAGID_EXIF_MAKER_NOTE, EXIF_UNDEFINED, (exif_byte_cnt * 2), aaa_exif_buff); if (rc) { ALOGE("%s:%d]: Error adding Exif Entry Maker note", __func__, __LINE__); } return rc; }
void fread_obj( CHAR_DATA *ch, FILE *fp ) { static OBJ_DATA obj_zero; OBJ_DATA *obj; char *word; int iNest; bool fMatch; bool fNest; bool fVnum; if ( obj_free == NULL ) { obj = alloc_perm( sizeof(*obj) ); } else { obj = obj_free; obj_free = obj_free->next; } *obj = obj_zero; obj->name = str_dup( "" ); obj->short_descr = str_dup( "" ); obj->description = str_dup( "" ); fNest = FALSE; fVnum = TRUE; iNest = 0; for ( ; ; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER(word[0]) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'A': if ( !str_cmp( word, "Affect" ) ) { AFFECT_DATA *paf; if ( affect_free == NULL ) { paf = alloc_perm( sizeof(*paf) ); } else { paf = affect_free; affect_free = affect_free->next; } paf->type = fread_number( fp ); paf->duration = fread_number( fp ); paf->modifier = fread_number( fp ); paf->location = fread_number( fp ); paf->bitvector = fread_number( fp ); paf->next = obj->affected; obj->affected = paf; fMatch = TRUE; break; } break; case 'C': KEY( "Cost", obj->cost, fread_number( fp ) ); break; case 'D': KEY( "Description", obj->description, fread_string( fp ) ); break; case 'E': KEY( "ExtraFlags", obj->extra_flags, fread_number( fp ) ); if ( !str_cmp( word, "ExtraDescr" ) ) { EXTRA_DESCR_DATA *ed; if ( extra_descr_free == NULL ) { ed = alloc_perm( sizeof(*ed) ); } else { ed = extra_descr_free; extra_descr_free = extra_descr_free->next; } ed->keyword = fread_string( fp ); ed->description = fread_string( fp ); ed->next = obj->extra_descr; obj->extra_descr = ed; fMatch = TRUE; } if ( !str_cmp( word, "End" ) ) { if ( !fNest || !fVnum ) { bug( "Fread_obj: incomplete object.", 0 ); free_string( obj->name ); free_string( obj->description ); free_string( obj->short_descr ); obj->next = obj_free; obj_free = obj; return; } else { obj->next = object_list; object_list = obj; obj->pIndexData->count++; if ( iNest == 0 || rgObjNest[iNest] == NULL ) obj_to_char( obj, ch ); else obj_to_obj( obj, rgObjNest[iNest-1] ); return; } } break; case 'I': KEY( "ItemType", obj->item_type, fread_number( fp ) ); break; case 'L': KEY( "Level", obj->level, fread_number( fp ) ); break; case 'N': KEY( "Name", obj->name, fread_string( fp ) ); if ( !str_cmp( word, "Nest" ) ) { iNest = fread_number( fp ); if ( iNest < 0 || iNest >= MAX_NEST ) { bug( "Fread_obj: bad nest %d.", iNest ); } else { rgObjNest[iNest] = obj; fNest = TRUE; } fMatch = TRUE; } break; case 'S': KEY( "ShortDescr", obj->short_descr, fread_string( fp ) ); if ( !str_cmp( word, "Spell" ) ) { int iValue; int sn; iValue = fread_number( fp ); sn = skill_lookup( fread_word( fp ) ); if ( iValue < 0 || iValue > 3 ) { bug( "Fread_obj: bad iValue %d.", iValue ); } else if ( sn < 0 ) { bug( "Fread_obj: unknown skill.", 0 ); } else { obj->value[iValue] = sn; } fMatch = TRUE; break; } break; case 'T': KEY( "Timer", obj->timer, fread_number( fp ) ); break; case 'V': if ( !str_cmp( word, "Values" ) ) { obj->value[0] = fread_number( fp ); obj->value[1] = fread_number( fp ); obj->value[2] = fread_number( fp ); obj->value[3] = fread_number( fp ); fMatch = TRUE; break; } if ( !str_cmp( word, "Vnum" ) ) { int vnum; vnum = fread_number( fp ); if ( ( obj->pIndexData = get_obj_index( vnum ) ) == NULL ) bug( "Fread_obj: bad vnum %d.", vnum ); else fVnum = TRUE; fMatch = TRUE; break; } break; case 'W': KEY( "WearFlags", obj->wear_flags, fread_number( fp ) ); KEY( "WearLoc", obj->wear_loc, fread_number( fp ) ); KEY( "Weight", obj->weight, fread_number( fp ) ); break; } if ( !fMatch ) { bug( "Fread_obj: no match.", 0 ); fread_to_eol( fp ); } } }
void fread_char( CHAR_DATA *ch, FILE *fp ) { char buf[MAX_STRING_LENGTH]; char *word; bool fMatch; for ( ; ; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER(word[0]) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'A': KEY( "Act", ch->act, fread_number( fp ) ); KEY( "AffectedBy", ch->affected_by, fread_number( fp ) ); KEY( "Alignment", ch->alignment, fread_number( fp ) ); KEY( "Armor", ch->armor, fread_number( fp ) ); if ( !str_cmp( word, "Affect" ) ) { AFFECT_DATA *paf; if ( affect_free == NULL ) { paf = alloc_perm( sizeof(*paf) ); } else { paf = affect_free; affect_free = affect_free->next; } paf->type = fread_number( fp ); paf->duration = fread_number( fp ); paf->modifier = fread_number( fp ); paf->location = fread_number( fp ); paf->bitvector = fread_number( fp ); paf->next = ch->affected; ch->affected = paf; fMatch = TRUE; break; } if ( !str_cmp( word, "AttrMod" ) ) { ch->pcdata->mod_str = fread_number( fp ); ch->pcdata->mod_int = fread_number( fp ); ch->pcdata->mod_wis = fread_number( fp ); ch->pcdata->mod_dex = fread_number( fp ); ch->pcdata->mod_con = fread_number( fp ); fMatch = TRUE; break; } if ( !str_cmp( word, "AttrPerm" ) ) { ch->pcdata->perm_str = fread_number( fp ); ch->pcdata->perm_int = fread_number( fp ); ch->pcdata->perm_wis = fread_number( fp ); ch->pcdata->perm_dex = fread_number( fp ); ch->pcdata->perm_con = fread_number( fp ); fMatch = TRUE; break; } break; case 'B': KEY( "Bamfin", ch->pcdata->bamfin, fread_string( fp ) ); KEY( "Bamfout", ch->pcdata->bamfout, fread_string( fp ) ); break; case 'C': KEY( "Class", ch->class, fread_number( fp ) ); if ( !str_cmp( word, "Condition" ) ) { ch->pcdata->condition[0] = fread_number( fp ); ch->pcdata->condition[1] = fread_number( fp ); ch->pcdata->condition[2] = fread_number( fp ); fMatch = TRUE; break; } break; case 'D': KEY( "Damroll", ch->damroll, fread_number( fp ) ); KEY( "Deaf", ch->deaf, fread_number( fp ) ); KEY( "Description", ch->description, fread_string( fp ) ); break; case 'E': if ( !str_cmp( word, "End" ) ) return; KEY( "Exp", ch->exp, fread_number( fp ) ); break; case 'G': KEY( "Gold", ch->gold, fread_number( fp ) ); break; case 'H': KEY( "Hitroll", ch->hitroll, fread_number( fp ) ); if ( !str_cmp( word, "HpManaMove" ) ) { ch->hit = fread_number( fp ); ch->max_hit = fread_number( fp ); ch->mana = fread_number( fp ); ch->max_mana = fread_number( fp ); ch->move = fread_number( fp ); ch->max_move = fread_number( fp ); fMatch = TRUE; break; } break; case 'L': KEY( "Level", ch->level, fread_number( fp ) ); KEY( "LongDescr", ch->long_descr, fread_string( fp ) ); break; case 'N': if ( !str_cmp( word, "Name" ) ) { /* * Name already set externally. */ fread_to_eol( fp ); fMatch = TRUE; break; } KEY( "Note", ch->last_note, fread_number( fp ) ); break; case 'P': KEY( "Pagelen", ch->pcdata->pagelen, fread_number( fp ) ); KEY( "Password", ch->pcdata->pwd, fread_string( fp ) ); KEY( "Played", ch->played, fread_number( fp ) ); KEY( "Position", ch->position, fread_number( fp ) ); KEY( "Practice", ch->practice, fread_number( fp ) ); KEY( "Prompt", ch->prompt, fread_string( fp ) ); break; case 'R': KEY( "Race", ch->race, fread_number( fp ) ); if ( !str_cmp( word, "Room" ) ) { ch->in_room = get_room_index( fread_number( fp ) ); if ( ch->in_room == NULL ) ch->in_room = get_room_index( ROOM_VNUM_LIMBO ); fMatch = TRUE; break; } break; case 'S': KEY( "SavingThrow", ch->saving_throw, fread_number( fp ) ); KEY( "Sex", ch->sex, fread_number( fp ) ); KEY( "ShortDescr", ch->short_descr, fread_string( fp ) ); if ( !str_cmp( word, "Skill" ) ) { int sn; int value; value = fread_number( fp ); sn = skill_lookup( fread_word( fp ) ); if ( sn < 0 ) bug( "Fread_char: unknown skill.", 0 ); else ch->pcdata->learned[sn] = value; fMatch = TRUE; } break; case 'T': KEY( "Trust", ch->trust, fread_number( fp ) ); if ( !str_cmp( word, "Title" ) ) { ch->pcdata->title = fread_string( fp ); if ( isalpha(ch->pcdata->title[0]) || isdigit(ch->pcdata->title[0]) ) { sprintf( buf, " %s", ch->pcdata->title ); free_string( ch->pcdata->title ); ch->pcdata->title = str_dup( buf ); } fMatch = TRUE; break; } break; case 'V': if ( !str_cmp( word, "Vnum" ) ) { ch->pIndexData = get_mob_index( fread_number( fp ) ); fMatch = TRUE; break; } break; case 'W': KEY( "Wimpy", ch->wimpy, fread_number( fp ) ); KEY( "Wizbit", ch->wizbit, fread_number( fp ) ); break; } /* Make sure old chars have this field - Kahn */ if ( !ch->pcdata->pagelen ) ch->pcdata->pagelen = 20; if ( !ch->prompt || ch->prompt == '\0' ) ch->prompt = "<%h %m %mv> "; if ( !fMatch ) { bug( "Fread_char: no match.", 0 ); fread_to_eol( fp ); } } }
void parse_quest(FILE *quest_file, int vnum) { static int i = 0; struct char_data *mob = NULL; char line[MAX_INPUT_LENGTH]; char value[MAX_INPUT_LENGTH]; char field[20]; int numval = 0; int nummsgs = 0; int numneeds = 0; int mob_rnum = 0; i++; mob_rnum = real_mobile(vnum); if (mob_rnum == -1) { stderr_log("Error trying to assign quest to non-existant mob."); fflush(NULL); exit(1); } mob = (mob_proto + mob_rnum); GET_MOB_QUEST_NUM(mob) = i; (mob_quests + i)->maxlevel = 51; (mob_quests + i)->qnum = i; while (get_line(quest_file, line)) { if (line[0] == 'S') { return; } parse_pline(line, field, value); numval = atoi(value); switch (UPPER(*field)) { case 'A': if (strcmp(field, "amount") == 0) { (mob_quests + i)->needs[numneeds].amount = numval; numneeds++; (mob_quests + i)->maxneeds = numneeds; } else { sprintf(buf2, "Unknown Quest field [%s]", field); stderr_log(buf2); } break; case 'C': if (strcmp(field, "classlist") == 0) { (mob_quests + i)->classlist = asciiflag_conv(value); } else { sprintf(buf2, "Unknown Quest field [%s]", field); stderr_log(buf2); } break; case 'D': if (strcmp(field, "destroy") == 0) { if (strcasecmp(value, "no") == 0) { (mob_quests + i)->needs[numneeds].destroy = 0; } } else { sprintf(buf2, "Unknown Quest field [%s]", field); stderr_log(buf2); } break; case 'F': if (strcmp(field, "flags") == 0) { (mob_quests + i)->flags = asciiflag_conv(value); } else { sprintf(buf2, "Unknown Quest field [%s]", field); stderr_log(buf2); } break; case 'G': if (strcmp(field, "goal") == 0) { (mob_quests + i)->goal = search_block(value, goal_list, FALSE); } else { sprintf(buf2, "Unknown Quest field [%s]", field); stderr_log(buf2); } break; case 'K': if (strcmp(field, "keywords") == 0) { RECREATE((mob_quests + i)->messages, struct quest_message_data, nummsgs + 1); (mob_quests + i)->messages[nummsgs].keywords = strdup(value); } else if (strcmp(field, "knowledge") == 0) { line[0] = '\0'; (mob_quests + i)->knowledge = fread_string(quest_file, line); } else { sprintf(buf2, "Unknown Quest field [%s]", field); stderr_log(buf2); } break; case 'M': if (strcmp(field, "maxlevel") == 0) { (mob_quests + i)->maxlevel = numval; } else if (strcmp(field, "message") == 0) { line[0] = '\0'; (mob_quests + i)->messages[nummsgs].message = fread_string(quest_file, line); nummsgs++; (mob_quests + i)->maxmsgs = nummsgs; } else { sprintf(buf2, "Unknown Quest field [%s]", field); stderr_log(buf2); } break; case 'N': if (strcmp(field, "needs") == 0) { RECREATE((mob_quests + i)->needs, struct quest_needs_data, numneeds + 1); (mob_quests + i)->needs[numneeds].destroy = 1; (mob_quests + i)->needs[numneeds].participants = NULL; (mob_quests + i)->needs[numneeds].type = search_block(value, needs_list, FALSE); (mob_quests + i)->needs[numneeds].complete = 0; (mob_quests + i)->needs[numneeds].needs_complete_msg = NULL; (mob_quests + i)->needs[numneeds].need_more_msg = NULL; } else if (strcmp(field, "need_more_msg") == 0) {
void nanny(DESCRIPTOR_DATA *d, char *input) { int i; char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *dt; switch(d->state) { case STATE_GET_NAME: if (input[0] == 0) { sckoutput(d->socket, "Fine, then.\n"); wipe_descriptor(d); return; } i = check_string(input, 4, 12, 0); if (i == 1) send_to_descriptor(d, "Your name must have at least 4 letters.\n"); else if (i == 2) send_to_descriptor(d, "Your name can contain at most 12 letters.\n"); else if (i == 4 || i == 3) send_to_descriptor(d, "Your name can contain only letters.\n"); else { input[0] = UPPER(input[0]); load_account(input, d->acc); d->acc->d = d; if (d->acc->name[0] == 0) { check_address(d->ip, d->acc->name); if (d->acc->name[0] != 0 && stricmp(input, d->acc->name)) send_to_descriptor(d, "#RWARNING:#n Your IP is linked to an existing account. It is against the rules to have multiple accounts.\n\n"); strlcpy(d->acc->name, input, 32); snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want the name %s? ", input); send_to_descriptor(d, buf); d->state = STATE_CONFIRM_NAME; return; } send_to_descriptor(d, "Password? "); send_to_descriptor(d, password_on); d->state = STATE_GET_PASS; return; } send_to_descriptor(d, "What do you want your account name to be? "); break; case STATE_GET_PASS: send_to_descriptor(d, password_off); if (!strcmp(d->acc->password, input)) { /* check to see if someone else is logged in under this account */ for (dt = dhead; dt; dt = dt->next) { if (dt == d || dt->acc == NULL) continue; if (!stricmp(d->acc->name, dt->acc->name)) { /* d = new connection, dt = old */ if (dt->socket > 0 && dt->state != STATE_LINKDEAD) { sckoutput(dt->socket, "\n\nYou have been kicked off.\n"); close(dt->socket); } dt->socket = d->socket; d->socket = -1; /* this is mandatory because wipe_descriptor closes d->socket */ wipe_descriptor(d); d = dt; if (d->state != STATE_PLAYING && d->state != STATE_LINKDEAD) send_to_descriptor(d, "\nYou have kicked someone off while they were logging in. Sending you to the account menu.\n"); else { destroy_all_events(d->acc->ch, EVENT_LINKDEAD); setup_char_events(d->acc->ch); d->acc->ch->idle = 0; syslog("RECONNECT", "%s (on %s@%s) has reconnected.", d->acc->ch->name, d->acc->name, d->ip); d->state = STATE_PLAYING; send_to_descriptor(d, "\n#RReconnected.#n\n"); return; } } } syslog("LOGIN", "%s@%s has logged in.", d->acc->name, d->ip); d->state = STATE_ACCT_MENU; d->acc->logins++; save_account(d->acc); show_account_menu(d, 0); snprintf(buf, MAX_STRING_LENGTH, "#1[#2Last connection from #R%s#2 at #R%s#2.#1]\n", d->acc->lasthost, d->acc->lasttime); save_address(d); send_to_descriptor(d, buf); if (d->acc->failed == 1) snprintf(buf, MAX_STRING_LENGTH, "#1[#RWARNING:#2 1 failed login attempt since your last connection.#1]\n"); else if (d->acc->failed > 1) snprintf(buf, MAX_STRING_LENGTH, "#1[#RWARNING:#2 %d failed login attempts since your last connection.#1]\n", d->acc->failed); if (d->acc->failed > 0) { send_to_descriptor(d, buf); d->acc->failed = 0; save_account(d->acc); } send_to_descriptor(d, "#nWhat is your choice? "); return; } sckoutput(d->socket, "Incorrect password. Logging you off...\n"); syslog("PASSWORD", "%s@%s -- incorrect password! Logged off.", d->acc->name, d->ip); d->acc->failed++; save_account(d->acc); wipe_descriptor(d); break; case STATE_CONFIRM_NAME: if (input[0] == 'y' || input[0] == 'Y') { send_to_descriptor(d, "What do you want your password to be? "); syslog("NEW", "New account %s is being created.", d->acc->name); d->state = STATE_NEW_PASS; send_to_descriptor(d, password_on); return; } send_to_descriptor(d, "Okay. What do you want your name to be? "); d->state = STATE_GET_NAME; break; case STATE_NEW_PASS: send_to_descriptor(d, password_off); if (input[0] == 0) { send_to_descriptor(d, "\nWhat do you want your password to be? "); send_to_descriptor(d, password_on); return; } i = check_string(input, 4, 12, 1); if (i == 1) send_to_descriptor(d, "\nYour password must have at least 4 characters.\n"); else if (i == 2) send_to_descriptor(d, "\nYour password can contain at most 12 characters.\n"); else if (i == 4) send_to_descriptor(d, "\nYour password can contain only letters and numbers.\n"); else { strlcpy(d->acc->password, input, 32); send_to_descriptor(d, "\nPlease retype your password for confirmation. "); send_to_descriptor(d, password_on); d->state = STATE_CONFIRM_PASS; return; } send_to_descriptor(d, "\nWhat do you want your password to be? "); send_to_descriptor(d, password_on); break; case STATE_CONFIRM_PASS: send_to_descriptor(d, password_off); if (strcmp(d->acc->password, input)) { send_to_descriptor(d, "\nYour passwords must match exactly.\nWhat do you want your password to be? "); d->state = STATE_NEW_PASS; d->acc->password[0] = 0; send_to_descriptor(d, password_on); return; } send_to_descriptor(d, "\nDo you want ANSI color? "); d->state = STATE_GET_ANSI; break; case STATE_GET_ANSI: d->acc->aflags = 0; if (input[0] == 'y' || input[0] == 'Y') SET_BIT(d->acc->aflags, AFLAG_ANSI); else if (input[0] == 'n' || input[0] == 'N') ; else { send_to_descriptor(d, "Please type yes or no.\nDo you want ANSI color? "); return; } for (dt = dhead; dt; dt = dt->next) { if (dt == d) continue; if (!stricmp(d->acc->name, dt->acc->name) && (dt->state > STATE_GET_PASS || dt->state < STATE_CONFIRM_NAME)) { sckoutput(d->socket, "You have been kicked off.\n"); wipe_descriptor(d); return; } } d->acc->logins = 1; d->acc->changes = time(NULL); strlcpy(d->acc->email, "Unset", 128); d->state = STATE_ACCT_MENU; log_time(d->acc->firsttime); save_address(d); show_account_menu(d, 1); save_account(d->acc); break; case STATE_ACCT_MENU: switch (input[0]) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': i = atoi(input); if (i > d->acc->charcount) { send_to_descriptor(d, "Unknown option.\nWhat is your choice? "); return; } if (d->acc->status[i - 1] == CHSTATUS_DELETED) { send_to_descriptor(d, "You are unable to log onto that player.\nWhat is your choice? "); return; } { d->acc->ch = load_character(d->acc, d->acc->character[i - 1]); d->acc->ch->acc = d->acc; d->acc->ch->d = d; setup_char_events(d->acc->ch); d->state = STATE_PLAYING; d->acc->cur_char = i - 1; ++d->acc->chlogins[i - 1]; destroy_d_events(d, EVENT_LOGINIDLE); if (d->acc->ch->level >= LEVEL_IMMORTAL) d->acc->status[i - 1] = CHSTATUS_IMMORTAL; if (!IS_SET(d->acc->ch->cflags, CFLAG_OLDPLAYER)) { syslog("LOGIN", "%s (on %s@%s) is now playing for the first time!", d->acc->ch->name, d->acc->name, d->ip); login_msg_new(d->acc->ch); SET_BIT(d->acc->ch->cflags, CFLAG_OLDPLAYER); if (IS_SET(d->acc->ch->cflags, CFLAG_HARDCORE)) d->acc->ch->plane = PLANE_HNEWBIE; else d->acc->ch->plane = PLANE_NEWBIE; d->acc->ch->maxhp = 1000; d->acc->ch->maxmove = 1000; d->acc->ch->maxmana = 1000; d->acc->ch->hp = d->acc->ch->maxhp; d->acc->ch->move = d->acc->ch->maxmove; d->acc->ch->mana = d->acc->ch->maxmana; d->acc->ch->level = LEVEL_MORTAL; d->acc->ch->sightradius = 5; /* pwipe: increase this to 50 */ strlcpy(d->acc->ch->prompt, "#1[#2%pP#1] #1[#2%h#1/#2%HH %m#1/#2%MM %v#1/#2%VV#1]#n> ", 256); send_to_char(d->acc->ch, "\nWelcome to Undertow. This is a completely custom MUD. We recommend that you read #RHELP NEWBIE#n.\n"); } else { syslog("LOGIN", "%s (on %s@%s) is now playing.", d->acc->ch->name, d->acc->name, d->ip); login_msg(d->acc->ch); do_look(d->acc->ch, ""); } save_account(d->acc); } break; case 'r': case 'R': if (new_changes(d->acc) == 0) { send_to_descriptor(d, "There are no new changes.\nWhat is your choice? "); return; } show_changes(d->acc, -1); send_to_descriptor(d, "\n#nWhat is your choice? "); break; case 'c': case 'C': d->state = STATE_CONFIG_MENU; show_account_settings(d); break; case 's': case 'S': send_who(d); send_to_descriptor(d, "#nWhat is your choice? "); break; case 'n': case 'N': if (d->acc->charcount >= MAX_CHARS_PER_ACCOUNT) { send_to_descriptor(d, "You have met your maximum amount of characters for this account.\nWhat is your choice?"); return; } d->state = STATE_NEW_CHAR; send_to_descriptor(d, "What do you want your name to be? "); break; case 'd': case 'D': if (d->acc->charcount == 0) { send_to_descriptor(d, "You have no characters to delete.\nWhat is your choice? "); return; } show_delete_menu(d); d->state = STATE_DELETE_CHAR; break; case 'q': case 'Q': save_account(d->acc); syslog("QUIT", "%s@%s quit at the login screen.", d->acc->name, d->ip); sckoutput(d->socket, "Goodbye.\n"); wipe_descriptor(d); break; case '\0': show_account_menu(d, 1); break; default: send_to_descriptor(d, "Unknown option.\nWhat is your choice? "); break; } break; case STATE_CONFIG_MENU: switch (input[0]) { case 'r': case 'R': d->state = STATE_ACCT_MENU; show_account_menu(d, 1); break; case 'a': case 'A': TOGGLE_BIT(d->acc->aflags, AFLAG_ANSI); if (IS_SET(d->acc->aflags, AFLAG_ANSI)) { if (IS_SET(d->acc->aflags, AFLAG_ANSI_SPARSE)) send_to_descriptor(d, "Your prompts will now be colored. If you want full color, turn Full ANSI Color on.\nWhat is your choice? "); else send_to_descriptor(d, "Welcome to the wonderful world of #Rc#Yo#Gl#Co#Mr#n!\nWhat is your choice? "); } else send_to_descriptor(d, "ANSI color turned off.\nWhat is your choice? "); break; case 'f': case 'F': TOGGLE_BIT(d->acc->aflags, AFLAG_ANSI_SPARSE); if (!IS_SET(d->acc->aflags, AFLAG_ANSI)) send_to_descriptor(d, "You would probably notice a subsequent color level change if you had color on.\nWhat is your choice? "); else if (IS_SET(d->acc->aflags, AFLAG_ANSI_SPARSE)) send_to_descriptor(d, "You will now only see colored prompts.\nWhat is your choice? "); else send_to_descriptor(d, "You will now see full color.\nWhat is your choice? "); break; case 'l': case 'L': TOGGLE_BIT(d->acc->aflags, AFLAG_REPLYLOCK); if (IS_SET(d->acc->aflags, AFLAG_REPLYLOCK)) send_to_descriptor(d, "You will now reply only to the last person to whom you sent a tell.\nWhat is your choice? "); else send_to_descriptor(d, "You will now reply to the person who most recently sent you a tell.\nWhat is your choice? "); break; case 'p': case 'P': TOGGLE_BIT(d->acc->aflags, AFLAG_PUBLIC_EMAIL); if (IS_SET(d->acc->aflags, AFLAG_PUBLIC_EMAIL)) send_to_descriptor(d, "Your email address is now public.\nWhat is your choice? "); else send_to_descriptor(d, "Your email address is now private.\nWhat is your choice? "); break; case 'c': case 'C': d->state = STATE_CHANGE_PASS1; send_to_descriptor(d, "What is your current password? "); send_to_descriptor(d, password_on); break; case 'e': case 'E': d->state = STATE_SET_EMAIL; send_to_descriptor(d, "What is your email address? "); break; case '\0': show_account_settings(d); break; case 'd': case 'D': SET_BIT(d->acc->aflags, AFLAG_ANSI); REMOVE_BIT(d->acc->aflags, AFLAG_ANSI_SPARSE); REMOVE_BIT(d->acc->aflags, AFLAG_PUBLIC_EMAIL); strlcpy(d->acc->email, "Unset", 128); send_to_descriptor(d, "Reverted to default settings.\nWhat is your choice?"); break; default: send_to_descriptor(d, "Unknown option.\nWhat is your choice? "); break; } break; case STATE_CHANGE_PASS1: send_to_descriptor(d, password_off); if (input[0] == 0) { d->state = STATE_CONFIG_MENU; send_to_descriptor(d, "\nWhat is your choice? "); return; } if (strcmp(d->acc->password, input)) { send_to_descriptor(d, "\nIncorrect password.\nWhat is your choice? "); d->state = STATE_CONFIG_MENU; return; } d->state = STATE_CHANGE_PASS2; d->acc->temp[0] = 0; send_to_descriptor(d, "\nWhat do you want your new password to be? "); send_to_descriptor(d, password_on); break; case STATE_CHANGE_PASS2: send_to_descriptor(d, password_off); if (input[0] == 0) { d->state = STATE_CONFIG_MENU; send_to_descriptor(d, "\nWhat is your choice? "); return; } i = check_string(input, 4, 12, 1); if (i == 1) send_to_descriptor(d, "\nYour password must have at least 4 characters.\n"); else if (i == 2) send_to_descriptor(d, "\nYour password can contain at most 12 characters.\n"); else if (i == 4) send_to_descriptor(d, "\nYour password can contain only letters and numbers.\n"); else { strlcpy(d->acc->temp, input, 128); send_to_descriptor(d, "\nPlease retype your password for confirmation. "); d->state = STATE_CHANGE_PASS3; send_to_descriptor(d, password_on); return; } send_to_descriptor(d, "\nWhat do you want your password to be? "); send_to_descriptor(d, password_on); break; case STATE_CHANGE_PASS3: send_to_descriptor(d, password_off); if (input[0] == 0) { d->state = STATE_CONFIG_MENU; send_to_descriptor(d, "\nWhat is your choice? "); return; } if (strcmp(d->acc->temp, input)) { send_to_descriptor(d, "\nPasswords must match exactly.\nWhat is your choice? "); d->state = STATE_CONFIG_MENU; return; } strlcpy(d->acc->password, input, 32); send_to_descriptor(d, "\nYour password is now changed.\nWhat is your choice? "); d->state = STATE_CONFIG_MENU; save_account(d->acc); break; case STATE_SET_EMAIL: i = check_string(input, -1, 47, 0); if (i == 2) send_to_descriptor(d, "Your email can contain at most 47 characters.\n"); else if (strlen(input) == 0) { strlcpy(d->acc->email, "Unset", 128); d->state = STATE_CONFIG_MENU; send_to_descriptor(d, "Your email address is now unset.\nWhat is your choice? "); } else { replace(input, buf, "%", "", MAX_STRING_LENGTH); replace(buf, input, "~", "-", MAX_STRING_LENGTH); strlcpy(d->acc->email, input, 128); d->state = STATE_CONFIG_MENU; snprintf(buf, MAX_STRING_LENGTH, "Your email address is now %s.\nWhat is your choice? ", input); send_to_descriptor(d, buf); return; } send_to_descriptor(d, "What is your email address? "); break; case STATE_DELETE_CHAR: if (input[0] == 'r' || input[0] == 'R') { d->state = STATE_ACCT_MENU; show_account_menu(d, 1); return; } if (input[0] == 0) { show_delete_menu(d); return; } i = atoi(input); if (i < 1 || i > d->acc->charcount) send_to_descriptor(d, "Out of bounds.\nWhich character do you want to delete? "); else { d->acc->name[15] = --i; snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want to delete %s?", d->acc->character[i]); send_to_descriptor(d, buf); d->state = STATE_CONFIRM_DEL; } break; case STATE_CONFIRM_DEL: if (input[0] == 'y' || input[0] == 'Y') { i = d->acc->name[15]; d->acc->name[15] = 0; snprintf(buf, MAX_STRING_LENGTH, "%s has been deleted.\nWhat is your choice? ", d->acc->character[i]); send_to_descriptor(d, buf); syslog("DELETION", "%s (on %s@%s) has selfdeleted.", d->acc->character[i], d->acc->name, d->ip); d->state = STATE_ACCT_MENU; d->acc->chtime[i] = 0; snprintf(buf, MAX_STRING_LENGTH, "rm -f account/%s.chr", d->acc->character[i]); to_lower(buf); system(buf); d->acc->charcount--; while (i < d->acc->charcount) { strlcpy(d->acc->character[i], d->acc->character[i + 1], 32); i++; } save_account(d->acc); return; } d->state = STATE_ACCT_MENU; show_account_menu(d, 1); break; case STATE_NEW_CHAR: i = 0; if (input[0] == 0) { d->state = STATE_ACCT_MENU; show_account_menu(d, 1); return; } i = check_string(input, 4, 12, 0); if (i == 1) send_to_descriptor(d, "Your name must have atleast 4 letters.\n"); else if (i == 2) send_to_descriptor(d, "Your name can contain at most 12 letters.\n"); else if (i == 4 || i == 3) send_to_descriptor(d, "Your name can contain only letters.\n"); else { input[0] = UPPER(input[0]); for (dt = dhead; dt; dt = dt->next) if ((d != dt) && !stricmp(input, dt->acc->character[dt->acc->charcount])) i = 1; if (i == 0 && char_exists(input)) i = 1; if (i) { snprintf(buf, MAX_STRING_LENGTH, "The name %s is already taken.\nWhat do you want your name to be? ", input); send_to_descriptor(d, buf); return; } strlcpy(d->acc->character[d->acc->charcount], input, 32); snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want the name %s? ", input); send_to_descriptor(d, buf); d->state = STATE_CONFIRM_CHAR; return; } send_to_descriptor(d, "What do you want your name to be? "); break; case STATE_CONFIRM_CHAR: if (input[0] == 'y' || input[0] == 'Y') { if (d->acc->logins == 1) { d->state = STATE_ACCT_MENU; finish_creation(d, 0); return; } d->state = STATE_GET_HARDCORE; send_to_descriptor(d, "Do you want this character to be hardcore (death = deletion)? "); } else { d->state = STATE_ACCT_MENU; show_account_menu(d, 1); } break; case STATE_GET_HARDCORE: finish_creation(d, input[0] == 'y' || input[0] == 'Y'); break; } }
int CLIB_ROUTINE main( int argc, char **argv) { /************************************** * * m a i n * ************************************** * * Functional description * The main for fbguard. This process is used to start * the standalone server and keep it running after an abnormal termination. * **************************************/ USHORT option = FOREVER; // holds FOREVER or ONETIME or IGNORE bool done = true; bool daemon = false; const TEXT* prog_name = argv[0]; const TEXT* pidfilename = 0; int guard_exit_code = 0; const TEXT* const* const end = argc + argv; argv++; while (argv < end) { const TEXT* p = *argv++; if (*p++ == '-') switch (UPPER(*p)) { case 'D': daemon = true; break; case 'F': option = FOREVER; break; case 'O': option = ONETIME; break; case 'S': option = IGNORE; break; case 'P': pidfilename = *argv++; break; default: fprintf(stderr, "Usage: %s [-signore | -onetime | -forever (default)] [-daemon] [-pidfile filename]\n", prog_name); exit(-1); break; } } // while // check user id Firebird::string user_name; // holds the user name ISC_get_user(&user_name, NULL, NULL, NULL); if (user_name != INTERBASE_USER && user_name != "root" && user_name != FIREBIRD_USER && user_name != INTERBASE_USER_SHORT) { // invalid user bail out fprintf(stderr, "%s: Invalid user (must be %s, %s, %s or root).\n", prog_name, FIREBIRD_USER, INTERBASE_USER, INTERBASE_USER_SHORT); exit(-2); } // get and set the umask for the current process const ULONG new_mask = 0007; const ULONG old_mask = umask(new_mask); // exclusive lock the file int fd_guard; if ((fd_guard = UTIL_ex_lock(GUARD_FILE)) < 0) { // could not get exclusive lock -- some other guardian is running if (fd_guard == -2) fprintf(stderr, "%s: Program is already running.\n", prog_name); exit(-3); } // the umask back to orignal donot want to carry this to child process umask(old_mask); // move the server name into the argument to be passed TEXT process_name[1024]; process_name[0] = '\0'; TEXT* server_args[2]; server_args[0] = process_name; server_args[1] = NULL; shutting_down = 0; if (UTIL_set_handler(SIGTERM, shutdown_handler, false) < 0) { fprintf(stderr, "%s: Cannot set signal handler (error %d).\n", prog_name, errno); exit(-5); } if (UTIL_set_handler(SIGINT, shutdown_handler, false) < 0) { fprintf(stderr, "%s: Cannot set signal handler (error %d).\n", prog_name, errno); exit(-5); } // detach from controlling tty if (daemon && fork()) { exit(0); } divorce_terminal(0); time_t timer = 0; do { int ret_code; if (shutting_down) { // don't start a child break; } if (timer == time(0)) { // don't let server restart too often - avoid log overflow sleep(1); continue; } timer = time(0); pid_t child_pid = UTIL_start_process(SUPER_SERVER_BINARY, SUPER_CLASSIC_BINARY, server_args, prog_name); if (child_pid == -1) { // could not fork the server gds__log("%s: guardian could not start server\n", prog_name/*, process_name*/); fprintf(stderr, "%s: Could not start server\n", prog_name/*, process_name*/); UTIL_ex_unlock(fd_guard); exit(-4); } if (pidfilename) { FILE *pf = fopen(pidfilename, "w"); if (pf) { fprintf(pf, "%d", child_pid); fclose(pf); } else { gds__log("%s: guardian could not open %s for writing, error %d\n", prog_name, pidfilename, errno); } } // wait for child to die, and evaluate exit status bool shutdown_child = true; if (!shutting_down) { ret_code = UTIL_wait_for_child(child_pid, shutting_down); shutdown_child = (ret_code == -2); } if (shutting_down) { if (shutdown_child) { ret_code = UTIL_shutdown_child(child_pid, 3, 1); if (ret_code < 0) { gds__log("%s: error while shutting down %s (%d)\n", prog_name, process_name, errno); guard_exit_code = -6; } else if (ret_code == 1) { gds__log("%s: %s killed (did not terminate)\n", prog_name, process_name); } else if (ret_code == 2) { gds__log("%s: unable to shutdown %s\n", prog_name, process_name); } else { gds__log("%s: %s terminated\n", prog_name, process_name); } } break; } if (ret_code != NORMAL_EXIT) { // check for startup error if (ret_code == STARTUP_ERROR) { gds__log("%s: %s terminated due to startup error (%d)\n", prog_name, process_name, ret_code); if (option == IGNORE) { gds__log("%s: %s terminated due to startup error (%d)\n Trying again\n", prog_name, process_name, ret_code); done = false; // Try it again, Sam (even if it is a startup error) FSG 8.11.2000 } else { gds__log("%s: %s terminated due to startup error (%d)\n", prog_name, process_name, ret_code); done = true; // do not restart we have a startup problem } } else { gds__log("%s: %s terminated abnormally (%d)\n", prog_name, process_name, ret_code); if (option == FOREVER || option == IGNORE) done = false; } } else { // Normal shutdown - don't restart the server gds__log("%s: %s normal shutdown.\n", prog_name, process_name); done = true; } } while (!done); if (pidfilename) { remove(pidfilename); } UTIL_ex_unlock(fd_guard); exit(guard_exit_code); } // main
PROJECT_DATA * read_project( FILE *fp ) { PROJECT_DATA *project; NOTE_DATA *log, *tlog; char *word; char buf [MSL]; bool fMatch; char letter; do { letter = getc( fp ); if( feof(fp) ) { fclose( fp ); return NULL; } } while( isspace(letter) ) ; ungetc( letter, fp ); project = alloc_mem( sizeof( PROJECT_DATA ) ); project->first_log = NULL; project->next = NULL; project->coder = NULL; project->description = str_dup(""); project->name = str_dup( "" ); project->owner = str_dup( "" ); project->date = str_dup( "Not Set?!"); project->status = str_dup( "No update." ); for ( ; ; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER(word[0]) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'C': KEY("Coder", project->coder,fread_string( fp ) ); break; case 'D': if (!str_cmp(word, "Date") ) free_string(project->date); else if ( !str_cmp(word, "Description") ) free_string(project->description); KEY("Date", project->date,fread_string( fp )); KEY("Description",project->description,fread_string(fp)); break; case 'E': if ( !str_cmp( word, "End" ) ) { if ( !project->description ) project->description = str_dup( "" ); if ( !project->name ) project->name = str_dup( "" ); if ( !project->owner ) project->owner = str_dup( "" ); if ( !project->date ) project->date = str_dup( "Not Set?!" ); if ( !project->status ) project->status = str_dup( "No update." ); if ( str_cmp(project->owner, "None") ) project->taken = TRUE; return project; } break; case 'L': if( !str_cmp( word, "Log" ) ) { fread_to_eol( fp ); log = read_log( fp ); if( !log ) { xprintf( buf, "read_project: couldn't read log,aborting"); bug( buf, 0 ); exit( 1 ); } if(!log->sender) log->sender = str_dup( "" ); if(!log->date) log->date = str_dup( "" ); if(!log->subject) log->subject = str_dup( "None" ); log->to_list = str_dup( "" ); if( !project->first_log ) project->first_log = log; else { log->next = project->first_log; project->first_log = log; } fMatch = TRUE; break; } break; case 'N': KEY( "Name", project->name,fread_string( fp ) ); break; case 'O': KEY( "Owner", project->owner,fread_string( fp ) ); break; case 'S': KEY( "Status", project->status,fread_string( fp ) ); break; } if ( !fMatch ) { xprintf( buf, "read_project: no match: %s", word ); bug( buf, 0 ); } } for( log = project->first_log; log; log = tlog ) { tlog = log->next; free_string( log->text ); free_string( log->subject ); free_string( log->to_list ); free_string( log->date ); free_string( log->sender ); log->next = note_free; note_free = log; } project->first_log =NULL; if ( project->coder ) free_string( project->coder ); if ( project->description ) free_string( project->description ); if ( project->name ) free_string( project->name ); if ( project->owner ) free_string( project->owner ); if ( project->date ) free_string( project->date ); if ( project->status ) free_string( project->status ); free_mem( project, sizeof( PROJECT_DATA ) ); return project; }
/* * Add a reset to an area -Thoric */ RESET_DATA *add_reset( ROOM_INDEX_DATA * room, char letter, int extra, int arg1, int arg2, int arg3 ) { RESET_DATA *pReset; if( !room ) { bug( "%s: NULL room!", __func__ ); return NULL; } letter = UPPER( letter ); pReset = make_reset( letter, extra, arg1, arg2, arg3 ); pReset->sreset = TRUE; switch ( letter ) { case 'M': room->last_mob_reset = pReset; break; case 'E': case 'G': if( !room->last_mob_reset ) { bug( "%s: Can't add '%c' reset to room: last_mob_reset is NULL.", __func__, letter ); return NULL; } room->last_obj_reset = pReset; LINK( pReset, room->last_mob_reset->first_reset, room->last_mob_reset->last_reset, next_reset, prev_reset ); return pReset; case 'P': if( !room->last_obj_reset ) { bug( "%s: Can't add '%c' reset to room: last_obj_reset is NULL.", __func__, letter ); return NULL; } LINK( pReset, room->last_obj_reset->first_reset, room->last_obj_reset->last_reset, next_reset, prev_reset ); return pReset; case 'O': room->last_obj_reset = pReset; break; case 'T': if( IS_SET( extra, TRAP_OBJ ) ) { pReset->prev_reset = NULL; pReset->next_reset = room->last_obj_reset->first_reset; if( room->last_obj_reset->first_reset ) room->last_obj_reset->first_reset->prev_reset = pReset; room->last_obj_reset->first_reset = pReset; if( !room->last_obj_reset->last_reset ) room->last_obj_reset->last_reset = pReset; return pReset; } break; case 'H': pReset->prev_reset = NULL; pReset->next_reset = room->last_obj_reset->first_reset; if( room->last_obj_reset->first_reset ) room->last_obj_reset->first_reset->prev_reset = pReset; room->last_obj_reset->first_reset = pReset; if( !room->last_obj_reset->last_reset ) room->last_obj_reset->last_reset = pReset; return pReset; } LINK( pReset, room->first_reset, room->last_reset, next, prev ); return pReset; }
void load_clans(void) { FILE *fp; char buf[MAX_STRING_LENGTH]; char *string; int count = 0; int i; bool fMatch = FALSE; for (i=0; i < MAX_CLAN; i++) { clan_table[i].name = ""; clan_table[i].who_name = ""; clan_table[i].room[0]= 0; clan_table[i].room[1]= 0; clan_table[i].room[2]= 0; clan_table[i].rank[0].rankname = ""; clan_table[i].rank[0].skillname = ""; clan_table[i].ml[0] = 0; clan_table[i].ml[1] = 0; clan_table[i].ml[2] = 0; clan_table[i].ml[3] = 0; clan_table[i].flags = 0; } sprintf(buf, "%sclan.dat", DATA_DIR); if ((fp = fopen(buf, "r")) == NULL) { log_string("Error: clan.dat file not found!"); exit(1); } for (;;) { string = feof(fp) ? "End" : fread_word(fp); if (!str_cmp(string, "End")) break; switch (UPPER(string[0])) { case 'F': clan_table[count].flags = fread_flag( fp ); fMatch = TRUE; break; case 'G': count++; clan_table[count].name = fread_string(fp); fMatch = TRUE; break; case 'R': if (!str_cmp(string, "Rooms")) { clan_table[count].room[0] = fread_number(fp); /* hall */ clan_table[count].room[1] = fread_number(fp); /* morgue */ clan_table[count].room[2] = fread_number(fp); /* temple */ fMatch = TRUE; } else if (!str_cmp(string, "Rank")) { i = fread_number(fp); clan_table[count].rank[i - 1].rankname = fread_string(fp); fMatch = TRUE; } break; case 'S': i = fread_number(fp); clan_table[count].rank[i - 1].skillname = fread_string(fp); fMatch = TRUE; break; case 'M': clan_table[count].ml[0] = fread_number(fp); clan_table[count].ml[1] = fread_number(fp); clan_table[count].ml[2] = fread_number(fp); clan_table[count].ml[3] = fread_number(fp); fMatch = TRUE; break; case 'W': clan_table[count].who_name = fread_string(fp); fMatch = TRUE; break; } /* end of switch */ } /* end of while (!feof) */ if (!fMatch) { bug("Fread_clans: no match.", 0); fread_to_eol(fp); } fclose(fp); return; } /* end: load_guilds */
BOARD_DATA *read_board( const char *boardfile, FILE * fp ) { BOARD_DATA *board = NULL; char buf[MAX_STRING_LENGTH]; bool fMatch = FALSE; char letter = 0; do { letter = fgetc( fp ); if( feof( fp ) ) { fclose( fp ); return NULL; } } while( isspace( ( int ) letter ) ); ungetc( letter, fp ); CREATE( board, BOARD_DATA, 1 ); for( ;; ) { const char *word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'E': KEY( "Extra_readers", board->extra_readers, fread_string_nohash( fp ) ); KEY( "Extra_removers", board->extra_removers, fread_string_nohash( fp ) ); if( !str_cmp( word, "End" ) ) { board->num_posts = 0; board->first_note = NULL; board->last_note = NULL; board->next = NULL; board->prev = NULL; if( !board->read_group ) board->read_group = str_dup( "" ); if( !board->post_group ) board->post_group = str_dup( "" ); if( !board->extra_readers ) board->extra_readers = str_dup( "" ); if( !board->extra_removers ) board->extra_removers = str_dup( "" ); return board; } case 'F': KEY( "Filename", board->note_file, fread_string_nohash( fp ) ); case 'M': KEY( "Min_read_level", board->min_read_level, fread_number( fp ) ); KEY( "Min_post_level", board->min_post_level, fread_number( fp ) ); KEY( "Min_remove_level", board->min_remove_level, fread_number( fp ) ); KEY( "Max_posts", board->max_posts, fread_number( fp ) ); case 'P': KEY( "Post_group", board->post_group, fread_string_nohash( fp ) ); case 'R': KEY( "Read_group", board->read_group, fread_string_nohash( fp ) ); case 'T': KEY( "Type", board->type, fread_number( fp ) ); case 'V': KEY( "Vnum", board->board_obj, fread_number( fp ) ); } if( !fMatch ) { sprintf( buf, "read_board: no match: %s", word ); bug( buf, 0 ); } } return board; }
void fread_fpfile( CHAR_DATA *ch, FILE *fp, char *fname ) { char *word; char *name = NULL; bool fMatch; sh_int ftype, fstatus; char buftype[MSL], bufstatus[MSL], buffinal[MSL]; for ( ; ; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER(word[0]) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'F': KEY( "ForceType", ftype, fread_number( fp ) ); KEY( "ForceLvlStatus", fstatus, fread_number( fp ) ); break; case 'N': KEY( "Name", name, fread_string( fp ) ); break; case 'E': if ( !strcmp( word, "End" ) ) goto forcecheck; break; } if ( !fMatch ) fread_to_eol( fp ); } forcecheck: if( ftype == 1 || ftype == 2 ) { if( ftype == 1 ) { strcpy(buftype, "Jedi"); } if( ftype == 2 ) { strcpy(buftype, "Sith"); } if( fstatus == 1) { strcpy(bufstatus, "Apprentice"); } if( fstatus == 3) { strcpy(bufstatus, "Master"); } if( (ftype == 1) && (fstatus == 2) ) { strcpy(bufstatus, "Knight"); } if( (ftype == 2) && (fstatus == 2) ) { strcpy(bufstatus, "Lord"); } if (ftype == 1) { sprintf(buffinal, "&w&W&W&B%s is a %s %s\n\r", name, buftype, bufstatus); send_to_char( buffinal, ch); jcount++; } if (ftype == 2) { sprintf(buffinal, "&w&W&W&R%s is a %s %s\n\r", name, buftype, bufstatus); send_to_char( buffinal, ch); scount++; } } return; }
void do_note( CHAR_DATA * ch, char *arg_passed, bool IS_MAIL ) { char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; NOTE_DATA *pnote = NULL; BOARD_DATA *board = NULL; int vnum = 0; int anum = 0; int first_list = 0; OBJ_DATA *paper = NULL, *tmpobj = NULL; EXTRA_DESCR_DATA *ed = NULL; char notebuf[MAX_STRING_LENGTH]; char short_desc_buf[MAX_STRING_LENGTH]; char long_desc_buf[MAX_STRING_LENGTH]; char keyword_buf[MAX_STRING_LENGTH]; bool mfound = FALSE; bool wasfound = FALSE; if( IS_NPC( ch ) ) return; if( !ch->desc ) { bug( "do_note: no descriptor", 0 ); return; } switch ( ch->substate ) { default: break; case SUB_WRITING_NOTE: if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { bug( "do_note: player not holding paper", 0 ); stop_editing( ch ); return; } ed = ( EXTRA_DESCR_DATA * ) ch->dest_buf; STRFREE( ed->description ); ed->description = copy_buffer( ch ); stop_editing( ch ); return; } set_char_color( AT_NOTE, ch ); arg_passed = one_argument( arg_passed, arg ); smash_tilde( arg_passed ); if( !str_cmp( arg, "list" ) ) { board = find_board( ch ); if( !board ) { send_to_char( "There is no board here to look at.\r\n", ch ); return; } if( !can_read( ch, board ) ) { send_to_char ( "You cannot make any sense of the cryptic scrawl on this board...\r\n", ch ); return; } first_list = atoi( arg_passed ); if( first_list ) { if( IS_MAIL ) { send_to_char ( "You cannot use a list number (at this time) with mail.\r\n", ch ); return; } if( first_list < 1 ) { send_to_char( "You can't read a message before 1!\r\n", ch ); return; } } if( !IS_MAIL ) { vnum = 0; set_pager_color( AT_NOTE, ch ); for( pnote = board->first_note; pnote; pnote = pnote->next ) { vnum++; if( ( first_list && vnum >= first_list ) || !first_list ) pager_printf( ch, "%2d%c %-12s%c %-12s %s\r\n", vnum, is_note_to( ch, pnote ) ? ')' : '}', pnote->sender, ( pnote->voting != VOTE_NONE ) ? ( pnote->voting == VOTE_OPEN ? 'V' : 'C' ) : ':', pnote->to_list, pnote->subject ); } act( AT_ACTION, "$n glances over the messages.", ch, NULL, NULL, TO_ROOM ); return; } else { vnum = 0; if( IS_MAIL ) /* SB Mail check for Brit */ { for( pnote = board->first_note; pnote; pnote = pnote->next ) if( is_note_to( ch, pnote ) ) mfound = TRUE; if( !mfound && !IS_IMMORTAL( ch ) ) { ch_printf( ch, "You have no mail.\r\n" ); return; } } for( pnote = board->first_note; pnote; pnote = pnote->next ) if( is_note_to( ch, pnote ) || IS_IMMORTAL( ch ) ) ch_printf( ch, "%2d%c %s: %s\r\n", ++vnum, is_note_to( ch, pnote ) ? '-' : '}', pnote->sender, pnote->subject ); return; } } if( !str_cmp( arg, "read" ) ) { bool fAll = FALSE; board = find_board( ch ); if( !board ) { send_to_char( "There is no board here to look at.\r\n", ch ); return; } if( !can_read( ch, board ) ) { send_to_char ( "You cannot make any sense of the cryptic scrawl on this board...\r\n", ch ); return; } if( !str_cmp( arg_passed, "all" ) ) { fAll = TRUE; anum = 0; } else if( is_number( arg_passed ) ) { fAll = FALSE; anum = atoi( arg_passed ); } else { send_to_char( "Note read which number?\r\n", ch ); return; } set_pager_color( AT_NOTE, ch ); if( !IS_MAIL ) { vnum = 0; for( pnote = board->first_note; pnote; pnote = pnote->next ) { vnum++; if( vnum == anum || fAll ) { wasfound = TRUE; pager_printf( ch, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n%s", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list, pnote->text ); if( pnote->yesvotes[0] != '\0' || pnote->novotes[0] != '\0' || pnote->abstentions[0] != '\0' ) { send_to_pager ( "------------------------------------------------------------\r\n", ch ); pager_printf( ch, "Votes:\r\nYes: %s\r\nNo: %s\r\nAbstain: %s\r\n", pnote->yesvotes, pnote->novotes, pnote->abstentions ); } act( AT_ACTION, "$n reads a message.", ch, NULL, NULL, TO_ROOM ); } } if( !wasfound ) ch_printf( ch, "No such message: %d\r\n", anum ); return; } else { vnum = 0; for( pnote = board->first_note; pnote; pnote = pnote->next ) { if( is_note_to( ch, pnote ) || IS_IMMORTAL( ch ) ) { vnum++; if( vnum == anum || fAll ) { wasfound = TRUE; pager_printf( ch, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n%s", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list, pnote->text ); } } } if( !wasfound ) ch_printf( ch, "No such message: %d\r\n", anum ); return; } } /* Voting added by Narn, June '96 */ if( !str_cmp( arg, "vote" ) ) { char arg2[MAX_INPUT_LENGTH]; arg_passed = one_argument( arg_passed, arg2 ); board = find_board( ch ); if( !board ) { send_to_char( "There is no bulletin board here.\r\n", ch ); return; } if( !can_read( ch, board ) ) { send_to_char( "You cannot vote on this board.\r\n", ch ); return; } if( is_number( arg2 ) ) anum = atoi( arg2 ); else { send_to_char( "Note vote which number?\r\n", ch ); return; } vnum = 1; for( pnote = board->first_note; pnote && vnum < anum; pnote = pnote->next ) vnum++; if( !pnote ) { send_to_char( "No such note.\r\n", ch ); return; } /* Options: open close yes no abstain */ /* If you're the author of the note and can read the board you can open and close voting, if you can read it and voting is open you can vote. */ if( !str_cmp( arg_passed, "open" ) ) { if( str_cmp( ch->name, pnote->sender ) ) { send_to_char( "You are not the author of this message.\r\n", ch ); return; } pnote->voting = VOTE_OPEN; act( AT_ACTION, "$n opens voting on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Voting opened.\r\n", ch ); write_board( board ); return; } if( !str_cmp( arg_passed, "close" ) ) { if( str_cmp( ch->name, pnote->sender ) ) { send_to_char( "You are not the author of this message.\r\n", ch ); return; } pnote->voting = VOTE_CLOSED; act( AT_ACTION, "$n closes voting on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Voting closed.\r\n", ch ); write_board( board ); return; } /* Make sure the note is open for voting before going on. */ if( pnote->voting != VOTE_OPEN ) { send_to_char( "Voting is not open on this note.\r\n", ch ); return; } /* Can only vote once on a note. */ sprintf( buf, "%s %s %s", pnote->yesvotes, pnote->novotes, pnote->abstentions ); if( is_name( ch->name, buf ) ) { send_to_char( "You have already voted on this note.\r\n", ch ); return; } if( !str_cmp( arg_passed, "yes" ) ) { sprintf( buf, "%s %s", pnote->yesvotes, ch->name ); DISPOSE( pnote->yesvotes ); pnote->yesvotes = str_dup( buf ); act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Ok.\r\n", ch ); write_board( board ); return; } if( !str_cmp( arg_passed, "no" ) ) { sprintf( buf, "%s %s", pnote->novotes, ch->name ); DISPOSE( pnote->novotes ); pnote->novotes = str_dup( buf ); act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Ok.\r\n", ch ); write_board( board ); return; } if( !str_cmp( arg_passed, "abstain" ) ) { sprintf( buf, "%s %s", pnote->abstentions, ch->name ); DISPOSE( pnote->abstentions ); pnote->abstentions = str_dup( buf ); act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Ok.\r\n", ch ); write_board( board ); return; } do_note( ch, STRLIT_EMPTY, FALSE ); } if( !str_cmp( arg, "write" ) ) { if( ch->substate == SUB_RESTRICTED ) { send_to_char ( "You cannot write a note from within another command.\r\n", ch ); return; } if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) ); if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL ) unequip_char( ch, tmpobj ); paper = obj_to_char( paper, ch ); equip_char( ch, paper, WEAR_HOLD ); act( AT_MAGIC, "$n grabs a message disk to record a note.", ch, NULL, NULL, TO_ROOM ); act( AT_MAGIC, "You get a message disk to record your note.", ch, NULL, NULL, TO_CHAR ); } if( paper->value[0] < 2 ) { paper->value[0] = 1; ed = SetOExtra( paper, "_text_" ); ch->substate = SUB_WRITING_NOTE; ch->dest_buf = ed; start_editing( ch, ed->description ); return; } else { send_to_char( "You cannot modify this message.\r\n", ch ); return; } } if( !str_cmp( arg, "subject" ) ) { if( !arg_passed || arg_passed[0] == '\0' ) { send_to_char( "What do you wish the subject to be?\r\n", ch ); return; } if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) ); if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL ) unequip_char( ch, tmpobj ); paper = obj_to_char( paper, ch ); equip_char( ch, paper, WEAR_HOLD ); act( AT_MAGIC, "$n grabs a message disk.", ch, NULL, NULL, TO_ROOM ); act( AT_MAGIC, "You get a message disk to record your note.", ch, NULL, NULL, TO_CHAR ); } if( paper->value[1] > 1 ) { send_to_char( "You cannot modify this message.\r\n", ch ); return; } else { paper->value[1] = 1; ed = SetOExtra( paper, "_subject_" ); STRFREE( ed->description ); ed->description = STRALLOC( arg_passed ); send_to_char( "Ok.\r\n", ch ); return; } } if( !str_cmp( arg, "to" ) ) { struct stat fst; char fname[1024]; if( !arg_passed || arg_passed[0] == '\0' ) { send_to_char( "Please specify an addressee.\r\n", ch ); return; } if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) ); if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL ) unequip_char( ch, tmpobj ); paper = obj_to_char( paper, ch ); equip_char( ch, paper, WEAR_HOLD ); act( AT_MAGIC, "$n gets a message disk to record a note.", ch, NULL, NULL, TO_ROOM ); act( AT_MAGIC, "You grab a message disk to record your note.", ch, NULL, NULL, TO_CHAR ); } if( paper->value[2] > 1 ) { send_to_char( "You cannot modify this message.\r\n", ch ); return; } arg_passed[0] = UPPER( arg_passed[0] ); sprintf( fname, "%s%c/%s", PLAYER_DIR, tolower( ( int ) arg_passed[0] ), capitalize( arg_passed ) ); if( !IS_MAIL || stat( fname, &fst ) != -1 || !str_cmp( arg_passed, "all" ) ) { paper->value[2] = 1; ed = SetOExtra( paper, "_to_" ); STRFREE( ed->description ); ed->description = STRALLOC( arg_passed ); send_to_char( "Ok.\r\n", ch ); return; } else { send_to_char( "No player exists by that name.\r\n", ch ); return; } } if( !str_cmp( arg, "show" ) ) { const char *subject = ""; const char *to_list = ""; const char *text = ""; if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { send_to_char( "You are not holding a message disk.\r\n", ch ); return; } if( ( subject = get_extra_descr( "_subject_", paper->first_extradesc ) ) == NULL ) subject = "(no subject)"; if( ( to_list = get_extra_descr( "_to_", paper->first_extradesc ) ) == NULL ) to_list = "(nobody)"; sprintf( buf, "%s: %s\r\nTo: %s\r\n", ch->name, subject, to_list ); send_to_char( buf, ch ); if( ( text = get_extra_descr( "_text_", paper->first_extradesc ) ) == NULL ) text = "The disk is blank.\r\n"; send_to_char( text, ch ); return; } if( !str_cmp( arg, "post" ) ) { char *strtime = NULL; const char *text = NULL; if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { send_to_char( "You are not holding a message disk.\r\n", ch ); return; } if( paper->value[0] == 0 ) { send_to_char( "There is nothing written on this disk.\r\n", ch ); return; } if( paper->value[1] == 0 ) { send_to_char( "This message has no subject... using 'none'.\r\n", ch ); paper->value[1] = 1; ed = SetOExtra( paper, "_subject_" ); STRFREE( ed->description ); ed->description = STRALLOC( "none" ); } if( paper->value[2] == 0 ) { if( IS_MAIL ) { send_to_char( "This message is addressed to no one!\r\n", ch ); return; } else { send_to_char ( "This message is addressed to no one... sending to 'all'!\r\n", ch ); paper->value[2] = 1; ed = SetOExtra( paper, "_to_" ); STRFREE( ed->description ); ed->description = STRALLOC( "All" ); } } board = find_board( ch ); if( !board ) { send_to_char ( "There is no terminal here to upload your message to.\r\n", ch ); return; } if( !can_post( ch, board ) ) { send_to_char ( "You cannot use this terminal. It is encrypted...\r\n", ch ); return; } if( board->num_posts >= board->max_posts ) { send_to_char ( "This terminal is full. There is no room for your message.\r\n", ch ); return; } act( AT_ACTION, "$n uploads a message.", ch, NULL, NULL, TO_ROOM ); strtime = ctime( ¤t_time ); strtime[strlen( strtime ) - 1] = '\0'; CREATE( pnote, NOTE_DATA, 1 ); pnote->date = STRALLOC( strtime ); text = get_extra_descr( "_text_", paper->first_extradesc ); pnote->text = text ? STRALLOC( text ) : STRALLOC( "" ); text = get_extra_descr( "_to_", paper->first_extradesc ); pnote->to_list = text ? STRALLOC( text ) : STRALLOC( "all" ); text = get_extra_descr( "_subject_", paper->first_extradesc ); pnote->subject = text ? STRALLOC( text ) : STRALLOC( "" ); pnote->sender = QUICKLINK( ch->name ); pnote->voting = 0; pnote->yesvotes = str_dup( "" ); pnote->novotes = str_dup( "" ); pnote->abstentions = str_dup( "" ); LINK( pnote, board->first_note, board->last_note, next, prev ); board->num_posts++; write_board( board ); send_to_char( "You upload your message to the terminal.\r\n", ch ); extract_obj( paper ); return; } if( !str_cmp( arg, "remove" ) || !str_cmp( arg, "take" ) || !str_cmp( arg, "copy" ) ) { char take = 0; board = find_board( ch ); if( !board ) { send_to_char ( "There is no terminal here to download a note from!\r\n", ch ); return; } if( !str_cmp( arg, "take" ) ) take = 1; else if( !str_cmp( arg, "copy" ) ) { if( !IS_IMMORTAL( ch ) ) { send_to_char( "Huh? Type 'help note' for usage.\r\n", ch ); return; } take = 2; } else take = 0; if( !is_number( arg_passed ) ) { send_to_char( "Note remove which number?\r\n", ch ); return; } if( !can_read( ch, board ) ) { send_to_char ( "You can't make any sense of what's posted here, let alone remove anything!\r\n", ch ); return; } anum = atoi( arg_passed ); vnum = 0; for( pnote = board->first_note; pnote; pnote = pnote->next ) { if( IS_MAIL && ( ( is_note_to( ch, pnote ) ) || IS_IMMORTAL( ch ) ) ) vnum++; else if( !IS_MAIL ) vnum++; if( ( !str_cmp( ch->name, pnote->sender ) || can_remove( ch, board ) ) && ( vnum == anum ) ) { if( ( is_name( "all", pnote->to_list ) ) && ( !IS_IMMORTAL( ch ) ) && ( take == 1 ) ) { send_to_char ( "Notes addressed to 'all' can not be taken.\r\n", ch ); return; } if( take != 0 ) { paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) ); ed = SetOExtra( paper, "_sender_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->sender ); ed = SetOExtra( paper, "_text_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->text ); ed = SetOExtra( paper, "_to_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->to_list ); ed = SetOExtra( paper, "_subject_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->subject ); ed = SetOExtra( paper, "_date_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->date ); ed = SetOExtra( paper, "note" ); STRFREE( ed->description ); sprintf( notebuf, "From: " ); strcat( notebuf, pnote->sender ); strcat( notebuf, "\r\nTo: " ); strcat( notebuf, pnote->to_list ); strcat( notebuf, "\r\nSubject: " ); strcat( notebuf, pnote->subject ); strcat( notebuf, "\r\n\r\n" ); strcat( notebuf, pnote->text ); strcat( notebuf, "\r\n" ); ed->description = STRALLOC( notebuf ); paper->value[0] = 2; paper->value[1] = 2; paper->value[2] = 2; sprintf( short_desc_buf, "a note from %s to %s", pnote->sender, pnote->to_list ); STRFREE( paper->short_descr ); paper->short_descr = STRALLOC( short_desc_buf ); sprintf( long_desc_buf, "A note from %s to %s lies on the ground.", pnote->sender, pnote->to_list ); STRFREE( paper->description ); paper->description = STRALLOC( long_desc_buf ); sprintf( keyword_buf, "note parchment paper %s", pnote->to_list ); STRFREE( paper->name ); paper->name = STRALLOC( keyword_buf ); } if( take != 2 ) note_remove( board, pnote ); send_to_char( "Ok.\r\n", ch ); if( take == 1 ) { act( AT_ACTION, "$n downloads a message.", ch, NULL, NULL, TO_ROOM ); obj_to_char( paper, ch ); } else if( take == 2 ) { act( AT_ACTION, "$n copies a message.", ch, NULL, NULL, TO_ROOM ); obj_to_char( paper, ch ); } else act( AT_ACTION, "$n removes a message.", ch, NULL, NULL, TO_ROOM ); return; } } send_to_char( "No such message.\r\n", ch ); return; } send_to_char( "Huh? Type 'help note' for usage.\r\n", ch ); }
int kdBuildMoveTree(KD kd) { int l,n,i,d,m,j,diff; KDN *c; BND bnd; if (kd->bOutDiag) puts(">> kdBuildMoveTree()"); fflush(stdout); if (kd->nActive == 0) { if (kd->kdNodes) free(kd->kdNodes); kd->kdNodes = NULL; return(1); } assert(kd->nActive > 0); n = kd->nActive; kd->nLevels = 1; l = 1; while (n > kd->nBucket) { n = n>>1; l = l<<1; ++kd->nLevels; } kd->nSplit = l; kd->nNodes = l<<1; if (kd->kdNodes) { free(kd->kdNodes); kd->kdNodes = NULL; } kd->kdNodes = (KDN *)malloc(kd->nNodes*sizeof(KDN)); assert(kd->kdNodes != NULL); /* ** Calculate Bounds. */ for (j=0;j<3;++j) { bnd.fMin[j] = kd->pMove[0].r[j]; bnd.fMax[j] = kd->pMove[0].r[j]; } for (i=1;i<kd->nMove;++i) { for (j=0;j<3;++j) { if (bnd.fMin[j] > kd->pMove[i].r[j]) bnd.fMin[j] = kd->pMove[i].r[j]; else if (bnd.fMax[j] < kd->pMove[i].r[j]) bnd.fMax[j] = kd->pMove[i].r[j]; } } /* ** Set up ROOT node */ c = kd->kdNodes; c[ROOT].pLower = 0; c[ROOT].pUpper = kd->nActive-1; c[ROOT].bnd = bnd; i = ROOT; while (1) { assert(c[i].pUpper - c[i].pLower + 1 > 0); if (i < kd->nSplit && (c[i].pUpper - c[i].pLower) > 0) { d = 0; for (j=1;j<3;++j) { if (c[i].bnd.fMax[j]-c[i].bnd.fMin[j] > c[i].bnd.fMax[d]-c[i].bnd.fMin[d]) d = j; } c[i].iDim = d; m = (c[i].pLower + c[i].pUpper)/2; kdSelectMove(kd,d,m,c[i].pLower,c[i].pUpper); c[i].fSplit = kd->pMove[m].r[d]; c[LOWER(i)].bnd = c[i].bnd; c[LOWER(i)].bnd.fMax[d] = c[i].fSplit; c[LOWER(i)].pLower = c[i].pLower; c[LOWER(i)].pUpper = m-1; c[UPPER(i)].bnd = c[i].bnd; c[UPPER(i)].bnd.fMin[d] = c[i].fSplit; c[UPPER(i)].pLower = m; c[UPPER(i)].pUpper = c[i].pUpper; diff = (m-c[i].pLower+1)-(c[i].pUpper-m); assert(diff == 0 || diff == 1); i = LOWER(i); } else { c[i].iDim = -1; SETNEXT(i); if (i == ROOT) break; } } UpPassMove(kd,ROOT); if (kd->bOutDiag) puts("<< kdBuildMoveTree()"); fflush(stdout); return(1); }
int xk_parse( memtbl_t *tbl, char **buf, char *p, int nptr, int sub, void *pass, memtbl_t *(*tbl_find)() ) { memtbl_t *ntbl; register int i = 0; int skind, delim_type; long val = 0; /* used for choice selection */ char *np; int delim = _Delim; int nmal; /* number of members malloc'ed arrays */ char *pp; int (*spec_parse)(); char * errmsg; if (tbl == NULL) { if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,1, "xk_parse: A NULL 'type' table was specified\n")); fprintf(stderr, errmsg); free(errmsg); } return(FAIL); } xk_skipwhite(buf); /* * If this is supposed to be a pointer, and we have a string that * starts with "P" and a number then we should take the pointer * itself. This is done by stripping off the 'p' and parsing it as a * unsigned long. * * Further, if it starts with an '&', then we want the address of * a variable, use fsym() to find it. */ if (((tbl->flags & F_TYPE_IS_PTR) || ((tbl->ptr + nptr) > 0)) && (((UPPER((*buf)[0]) == 'P') && isdigit((*buf)[1])) || ((*buf)[0] == '&'))) { if ((*buf)[0] == '&') { char *start; (*buf)++; for (start = *buf; isvarchar(*buf[0]); (*buf)++) ; if ((((unsigned long *) p)[0] = fsym(start, -1)) == NULL) return(FAIL); } else { (*buf)++; RIF(xk_par_int(buf, (long *)p, pass)); } if (Ndont == Sdont) { if (Dont) Dont = (char **) realloc(Dont, (Sdont + 20) * sizeof(char *)); else Dont = (char **) malloc((Sdont + 20) * sizeof(char *)); if (!Dont) { errmsg = strdup(GetSharedMsg(DT_ALLOC_FAILURE)); ALTPUTS(errmsg); free(errmsg); exit(1); } Sdont += 20; } Dont[Ndont++] = ((char **) p)[0]; return(SUCCESS); } if (tbl->tname && (spec_parse = find_special(SPEC_PARSE, tbl->tname))) return(spec_parse(tbl, buf, p, nptr, sub, pass, tbl_find)); if (tbl->name && (spec_parse = find_special(SPEC_PARSE, tbl->name))) return(spec_parse(tbl, buf, p, nptr, sub, pass, tbl_find)); nptr += tbl->ptr; if (sub > 0 && tbl->subscr > 0) { if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,2, "xk_parse: Multiple array subscripts are not handled in '%s'\n")); fprintf(stderr, errmsg, tbl->name); free(errmsg); } return(FAIL); } /* * If there is exactly one pointer associated with this * member, and no length delimiters, and no subscripts, * or there are multiple pointers, * then malloc space for the structure and call ourself * recursively. */ if ((nptr > 1 && tbl->delim != 0) || (nptr == 1 && tbl->delim == 0 && tbl->subscr == 0)) { if (PARPEEK(buf, ",") || PARPEEK(buf, Str_close_curly)) { ((char **)p)[0] = NULL; if (_Prdebug) { errmsg=strdup(GetSharedMsg(DT_XK_PARSE_SET_NULL)); fprintf(stderr, errmsg, tbl->name); free(errmsg); } return(SUCCESS); } if (xk_parpeek(buf, "NULL")) { RIF(xk_parexpect(buf, "NULL")); ((char **)p)[0] = NULL; if (_Prdebug) { errmsg=strdup(GetSharedMsg( DT_XK_PARSE_SET_NULL)); fprintf(stderr, errmsg, tbl->name); free(errmsg); } return(SUCCESS); } if ((((char **)p)[0] = malloc(tbl->size)) == NULL) { return(FAIL); } if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,3, "xk_parse: Setting '%s' to malloc'ed address 0x%x, of size %d\n")); fprintf(stderr,errmsg,tbl->name, ((char **)p)[0], tbl->size); free(errmsg); } return(xk_parse(tbl, buf, ((char **)p)[0], nptr-1-tbl->ptr, sub, pass, tbl_find)); } /* * If there is exactly one pointer level, or one subscripting level, * and there is a delimiter, * and no subscript, then we are a length delimited malloced array. */ xk_skipwhite(buf); if (tbl->delim != 0 && ((nptr == 1 && tbl->subscr == 0) || (nptr == 0 && tbl->subscr != 0 && tbl->kind != K_STRING))) { if (tbl->subscr == 0) { if (PARPEEK(buf, ",") || PARPEEK(buf, Str_close_curly)) { ((char **)p)[0] = NULL; if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,4, "xk_parse: Setting malloc'ed array '%s' to NULL\n")); fprintf(stderr, errmsg, tbl->name); free(errmsg); } return(SUCCESS); } if (xk_parpeek(buf, "NULL")) { RIF(xk_parexpect(buf, "NULL")); ((char **)p)[0] = NULL; if (_Prdebug) { errmsg=strdup(GetSharedMsg( DT_XK_PARSE_SET_NULL)); fprintf(stderr, errmsg, tbl->name); free(errmsg); } return(SUCCESS); } nmal = MALMEMBERS; if ((np = malloc(nmal*tbl->size)) == NULL) { return(FAIL); } ((char **)p)[0] = np; if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,5, "xk_parse: Setting member '%s' to malloc'ed pointer 0x%x, of size %d\n")); fprintf(stderr, errmsg, tbl->name, np, 4*tbl->size); free(errmsg); } } else { np = p; } xk_skipwhite(buf); RIF(PAREXPECT(buf, Str_open_curly)); *buf += 1; i = 0; xk_skipwhite(buf); while (PARPEEK(buf, Str_close_curly) == FALSE) { if (tbl->subscr == 0 && i >= nmal) { nmal += MALMEMBERS; if((np = realloc(np, nmal*tbl->size)) == NULL) { return(FAIL); } ((char **)p)[0] = np; if (_Prdebug) { errmsg=strdup(GetSharedMsg( DT_XK_PARSE_ARRAY_OVERFLOW)); fprintf(stderr, errmsg, tbl->name, nmal, nmal*tbl->size); free(errmsg); } } else if (tbl->subscr > 0 && i > tbl->subscr) { if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,6, "xk_parse: The array '%s' overflowed at element number %d\n")); fprintf(stderr, errmsg, tbl->name, i); free(errmsg); } } if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,7, "xk_parse: Parsing array element [%d] of '%s' into address 0x%x\n")); fprintf(stderr, errmsg, i, tbl->name, &np[i*tbl->size]); free(errmsg); } if (i) { xk_skipwhite(buf); if (PARPEEK(buf, ",") == FALSE) { if (PARPEEK(buf, Str_close_curly) == FALSE) { RIF(PAREXPECT(buf, ",")); *buf += 1; } } else { RIF(PAREXPECT(buf, ",")); *buf += 1; } } RIF(xk_parse(tbl, buf, &np[i*tbl->size], nptr ? -1 : 0, 0, (void *)-1, tbl_find)); i++; struct_size = i; xk_skipwhite(buf); } RIF(PAREXPECT(buf, Str_close_curly)); *buf += 1; return(SUCCESS); } /* * If there is no delimiter, and there are two levels of pointer, * then we are a NULL terminated array of pointers */ if (tbl->delim == 0 && ((nptr == 2 && sub == 0) || (sub == 1 && nptr == 1))) { /* * malloc a few members, realloc as needed */ nmal = MALMEMBERS; if ((((char **)p)[0] = malloc(nmal*tbl->size)) == NULL) { return(FAIL); } xk_skipwhite(buf); RIF(PAREXPECT(buf, Str_open_curly)); *buf += 1; xk_skipwhite(buf); while (PARPEEK(buf, Str_close_curly) == FALSE) { if (i >= nmal) { nmal += MALMEMBERS; if ((((char **)p)[0] = realloc(((char **)p)[0], nmal*tbl->size)) == NULL) { return(FAIL); } if (_Prdebug) { errmsg=strdup(GetSharedMsg( DT_XK_PARSE_ARRAY_OVERFLOW)); fprintf(stderr, errmsg, tbl->name, nmal, nmal*tbl->size); free(errmsg); } } if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,8, "xk_parse: Parsing array element [%d] of '%s'\n")); fprintf(stderr, errmsg, i, tbl->name); free(errmsg); } if (i) { RIF(PAREXPECT(buf, ",")); *buf += 1; } RIF(xk_parse(tbl, buf, &p[i*tbl->size], nptr == 2 ? -2 : -1, 0, (void *)-1, tbl_find)); xk_skipwhite(buf); } RIF(PAREXPECT(buf, Str_close_curly)); *buf++; ((char **)p)[i*tbl->size] = NULL; return(SUCCESS); } switch(tbl->kind) { case K_CHAR: RIF(xk_par_int(buf, &val, pass)); ((unsigned char *)p)[0] = val; break; case K_SHORT: RIF(xk_par_int(buf, &val, pass)); ((ushort *)p)[0] = val; break; case K_INT: RIF(xk_par_int(buf, &val, pass)); ((int *)p)[0] = val; break; case K_LONG: RIF(xk_par_int(buf, (long *)p, pass)); break; case K_STRING: if (tbl->subscr) { val = tbl->subscr; RIF(xk_par_chararr(buf, (char *)p, (int *)&val)); if (tbl->delim <= 0 && val > -1) { p[val] = '\0'; } } else { val = 0; RIF(xk_par_charstr(buf, (char **)p, (int *)&val)); /* If this is not a delimited char string, * then it must be null terminated */ if (tbl->delim <= 0 && val > -1) { ((char **) p)[0][val] = '\0'; } strglen = val; } break; case K_TYPEDEF: ntbl = tbl_find(tbl->tname, tbl->tbl, tbl->id); RIF(xk_parse(ntbl, buf, p, nptr, 0, pass, tbl_find)); return(SUCCESS); case K_STRUCT: xk_skipwhite(buf); RIF(PAREXPECT(buf, Str_open_curly)); *buf += 1; ntbl = tbl_find(tbl->tname, tbl->tbl, tbl->id); pp = NULL; for (i = 0; ntbl[i].name != NULL; i++) { _Delim = xk_get_pardelim(&ntbl[i], p); if (ntbl[i].kind >= K_DSHORT) { skind = ntbl[i].kind; pp = p + ntbl[i].offset; struct_size = 0; } if (ntbl[i].delim) { delim_type = ntbl[i].kind; } if (i && ntbl[i-1].kind < K_DSHORT) { xk_skipwhite(buf); if (PARPEEK(buf, ",") == FALSE) { if (PARPEEK(buf, Str_close_curly) == FALSE) { RIF(PAREXPECT(buf, ",")); *buf += 1; } } else { RIF(PAREXPECT(buf, ",")); *buf += 1; } } if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,9, "xk_parse: Parsing member '%s' into location 0x%x\n")); fprintf(stderr, errmsg, ntbl[i].name, p + ntbl[i].offset); free(errmsg); } if (xk_parse(&ntbl[i], buf, p+ntbl[i].offset, nptr, sub, pass, tbl_find) == FAIL) { if (_Prdebug) { errmsg=strdup(GetSharedMsg( DT_XK_PARSE_ERROR)); fprintf(stderr, errmsg, ntbl[i].name); free(errmsg); } return(FAIL); } } if (pp != NULL) { switch(skind) { case K_DSHORT: if (delim_type == K_STRING) ((short *)pp)[0] = strglen; else ((short *)pp)[0] = struct_size; break; case K_DINT: if (delim_type == K_STRING) ((int *)pp)[0] = strglen; else ((int *)pp)[0] = struct_size; break; case K_DLONG: if (delim_type == K_STRING) ((long *)pp)[0] = strglen; else ((long *)pp)[0] = struct_size; break; default: break; } } xk_skipwhite(buf); RIF(PAREXPECT(buf, Str_close_curly)); *buf += 1; break; case K_UNION: if (strncmp(tbl[-1].name, "ch_", 3) != 0) { if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,10, "xk_parse: Cannot determine the choice in '%s'\n")); fprintf(stderr, errmsg, tbl->name); free(errmsg); } return(FAIL); } ntbl = tbl_find(tbl->tname, tbl->tbl, tbl->id); xk_skipwhite(buf); RIF(PAREXPECT(buf, Str_open_curly)); *buf += 1; for (i = 0; ntbl[i].name != NULL; i++) { if (xk_parpeek(buf, ntbl[i].name) == TRUE) { RIF(xk_parexpect(buf, ntbl[i].name)); ((long *)(p - sizeof(long)))[0] = ntbl[i].choice; if (_Prdebug) { errmsg=strdup(GETMESSAGE(8,11, "xk_parse: Parsing union member '%s' into location 0x%x\n")); fprintf(stderr, errmsg, ntbl[i].name, p + ntbl[i].offset); free(errmsg); } if (xk_parse(&ntbl[i], buf, p, nptr, sub, pass, tbl_find) == FAIL) { if (_Prdebug) { errmsg=strdup(GetSharedMsg( DT_XK_PARSE_ERROR)); fprintf(stderr, errmsg, ntbl[i].name); free(errmsg); } return(FAIL); } break; } } xk_skipwhite(buf); RIF(PAREXPECT(buf, Str_close_curly)); *buf += 1; break; case K_DSHORT: case K_DINT: case K_DLONG: break; default: return(FAIL); } return(SUCCESS); }
bool check_social (CHAR_DATA * ch, char *command, char *argy) { char arg[SML_LENGTH]; CHAR_DATA *victim; SOCIAL *s; bool found; found = FALSE; for (s = social_hashed[UPPER (command[0])]; s != NULL; s = s->next_hashed) { if (command[0] == s->name[0] && !str_prefix (command, s->name)) { found = TRUE; break; } } if (!found) return FALSE; switch (ch->position) { case POSITION_DEAD: send_to_char ("You're dead, you can't move.\n\r", ch); return TRUE; case POSITION_INCAP: case POSITION_MORTAL: send_to_char ("You are hurt far too bad for that.\n\r", ch); return TRUE; case POSITION_STUNNED: send_to_char ("You are too stunned to do that.\n\r", ch); return TRUE; case POSITION_SLEEPING: if (!str_cmp (s->name, "snore")) break; send_to_char ("You are asleep, off in dreamland.\n\r", ch); return TRUE; } one_argy (argy, arg); victim = NULL; if (arg[0] == '\0') { act (s->others_no_arg, ch, NULL, victim, TO_ROOM); act (s->char_no_arg, ch, NULL, victim, TO_CHAR); } else if ((victim = get_char_room (ch, arg)) == NULL) { send_to_char ("They aren't here.\n\r", ch); } else if (victim == ch) { act (s->others_auto, ch, NULL, victim, TO_ROOM); act (s->char_auto, ch, NULL, victim, TO_CHAR); } else { act (s->others_found, ch, NULL, victim, TO_NOTVICT); act (s->char_found, ch, NULL, victim, TO_CHAR); act (s->vict_found, ch, NULL, victim, TO_VICT); if (IS_PLAYER (ch) && IS_MOB (victim) && !IS_AFFECTED (victim, AFF_CHARM) && victim->pIndexData->mobtype != MOB_CANINE && victim->pIndexData->mobtype != MOB_RODENT && victim->pIndexData->mobtype != MOB_INSECT && victim->pIndexData->mobtype != MOB_UNDEAD && victim->pIndexData->mobtype != MOB_BIRD && victim->pIndexData->mobtype != MOB_FISH && victim->pIndexData->mobtype != MOB_STATUE && victim->pIndexData->mobtype != MOB_PLANT && victim->pIndexData->mobtype != MOB_GHOST && victim->pIndexData->mobtype != MOB_ARACHNID && victim->pIndexData->mobtype != MOB_HORSE && victim->pIndexData->mobtype != MOB_ELEMENTAL && victim->pIndexData->mobtype != MOB_DUMMY && victim->pIndexData->mobtype != MOB_MUTANT && victim->pIndexData->mobtype != MOB_FELINE && victim->pIndexData->mobtype != MOB_REPTILE && victim->pIndexData->mobtype != MOB_GENERAL_ANIMAL && IS_AWAKE (victim) && victim->desc == NULL) { switch (number_bits (4)) { /*case 0: if (can_yell(victim)) { do_say(victim,"Stop that!!"); } multi_hit( victim, ch, TYPE_UNDEFINED ); break; */ case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: act (s->others_found, victim, NULL, ch, TO_NOTVICT); act (s->char_found, victim, NULL, ch, TO_CHAR); act (s->vict_found, victim, NULL, ch, TO_VICT); break; case 9: case 10: case 11: case 12: act ("$n slaps $N.", victim, NULL, ch, TO_NOTVICT); act ("You slap $N.", victim, NULL, ch, TO_CHAR); act ("$n slaps you.", victim, NULL, ch, TO_VICT); break; } } } return TRUE; }
/*--------------------------------------------------- SMI_handle_command() */ void SMI_handle_command() { char action[64], param[128], parname[64], msg[256]; char run_number_str[64]; int n_params, ptype, psize, i; prtProfTime(NULL); smi_get_action(action,&n_params); UPPER(action); strcpy(msg,""); if(n_params != 2){ printf("# of pars received: %i. \n",n_params); //exit(8); }; for (i=1;i<=n_params;i++) { smi_get_next_par(parname,&ptype,&psize); smi_get_par_value(parname,param); printf("SMI: parname=%s param=%s \n", parname,param); if(strcmp(parname,"PARTITION") == 0) { strcpy(pname,param); } else if(strcmp(parname,"MASK") == 0){ strcpy(mask,param); } else if(strcmp(parname,"MODE") == 0){ if((strcmp(param,"NOTHING")!=0) && (strcmp(param,"PHYSICS")!=0) && (strcmp(param,"UNDEFINED")!=0)) { strcpy(partmode,param); } else { strcpy(partmode,""); }; } else if(strcmp(parname,"RUN_NUMBER") == 0) { strcpy(run_number_str,param); //run_number=atoi(run_number_str) run_number= (int) strtol(run_number_str, (char **)NULL, 10); if(run_number<=0) { printf("RUN_NUMBER <=0\n"); smi_setState("ERROR"); goto RETSMI; }; } else if(strcmp(parname,"ACT_CONFIG") == 0) { strcpy(ACT_CONFIG,param); } else if(strcmp(parname,"DETECTORS") == 0) { // comma separated list of dets (e.g. "PMD,MUON_TRK") detectors= detList2bitpat(param); // "CTP" will be ignored (bit not set) if(detectors==-1) { sprintf(errorReason, "Bad list of detectors:%s...",param); smi_set_parER(); smi_setState("ERROR"); goto RETSMI; }; printf("detectors:%s= 0x%x\n",param, detectors); } else { char wmsg[200]; sprintf(wmsg,"unknown parameter from ECS:%s", param); prtWarning(wmsg); }; strcat(msg," "); strcat(msg,param); }; printf("%s Got action %s with parameters %s\n",obj,action,msg); if (strcmp(state,"RUNNING") == 0 ) { if((strcmp(action,"LOAD_PARTITION") == 0) || (strcmp(action,"INIT_PARTITION") == 0)) { char INITLOAD[8]; if(strcmp(action,"LOAD_PARTITION") == 0) { strcpy(INITLOAD,"LOAD"); } else { strcpy(INITLOAD,"INIT"); }; if(quit>0) { sprintf(msg,"%s_PARTITION ignored. ctp_proxy stopping, waiting for the stop of all partitions",INITLOAD); infolog_trgboth(LOG_FATAL, msg); } else { smi_set_parEF(pname); executectp(INITLOAD); }; } else if (strcmp(action,"START_PARTITION") == 0) { smi_set_parEF(pname); executectp(action); } else if (strcmp(action,"STOP_PARTITION") == 0) { smi_set_parEF(pname); executectp(action); } else if (strcmp(action,"PAUSE_PARTITION") == 0) { smi_set_parEF(pname); executectp(action); } else if (strcmp(action,"SYNC") == 0) { // correct: strcmp("SYNC") smi_set_parEF(pname); executectp(action); } else if (strcmp(action,"RESUME_PARTITION") == 0) { smi_set_parEF(pname); executectp(action); } else { char msg[200]; sprintf(msg, "Illegal action %s in state RUNNING ignored.\n",action); infolog_trgboth(LOG_ERROR, msg); smi_setState("RUNNING"); } } else if (strcmp(state,"EXECUTING") == 0 ) { char msg[200]; sprintf(msg, "Illegal action %s in state EXECUTING ignored.\n",action); smi_setState("EXECUTING"); } else if (strcmp(state,"LOAD_FAILURE") == 0 ) { if(strcmp(action,"ACKNOWLEDGE") == 0 ) { strcpy(errorReason,"not set"); smi_set_parER(); smi_setState("RUNNING"); } else { printf("Illegal action %s in state LOAD_FAILURE\n",action); smi_setState("LOAD_FAILURE"); } } else if (strcmp(state,"ERROR") == 0 ) { if (strcmp(action,"RESET") == 0 ) { smi_setState("RUNNING"); } else { printf("Illegal action %s in state ERROR\n",action); smi_setState("ERROR"); } }; RETSMI: prtProfTime("SMI_handle end"); return; }
char * exits2str( void * point ) { EXIT_DATA **pexitarray = (EXIT_DATA **) point; EXIT_DATA *pexit; static char buf[MSL]; char word[MIL], reset_state[MIL], tmpbuf[MIL]; char *state; int i, length, j; buf[0] = '\0'; for ( j = 0; j < MAX_DIR; j++ ) { if ((pexit = pexitarray[j]) == NULL) continue; sprintf( tmpbuf, "-%-5.5s toward [%5d] ", capitalize(dir_name[j]), pexit->u1.to_room ? pexit->u1.to_room->vnum : 0 ); strcat( buf, tmpbuf ); if (pexit->key > 0) { sprintf(tmpbuf, "Key:%d ", pexit->key); strcat(buf, tmpbuf); } /* * Format up the exit info. * Capitalize all flags that are not part of the reset info. */ strcpy( reset_state, flag_string( exit_flags, pexit->rs_flags ) ); state = flag_string( exit_flags, pexit->exit_info ); strcat( buf, "Flags: [" ); for (; ;) { state = one_argument( state, word ); if ( word[0] == '\0' ) { int end; end = strlen(buf) - 1; buf[end] = ']'; if (pexit->keyword) strcat(buf, "(K)"); if (pexit->description) strcat(buf, "(D)"); strcat( buf, "\n\r" ); break; } if ( str_infix( word, reset_state ) ) { length = strlen(word); for (i = 0; i < length; i++) word[i] = UPPER(word[i]); } strcat( buf, word ); strcat( buf, " " ); } /* if ( pexit->keyword && pexit->keyword[0] != '\0' ) { sprintf( tmpbuf, "Kwds: [%s]\n\r", pexit->keyword ); strcat( buf, tmpbuf ); } if ( pexit->description && pexit->description[0] != '\0' ) { sprintf( tmpbuf, "%s", pexit->description ); strcat( buf, tmpbuf ); } */ } return buf; }
int CLIB_ROUTINE main( int argc, char** argv) { /************************************** * * m a i n * ************************************** * * Functional description * Install or remove Firebird. * **************************************/ TEXT directory[MAXPATHLEN]; USHORT sw_command = COMMAND_NONE; bool sw_version = false; // Let's get the root directory from the instance path of this program. // argv[0] is only _mostly_ guaranteed to give this info, // so we GetModuleFileName() const USHORT len = GetModuleFileName(NULL, directory, sizeof(directory)); if (len == 0) return reg_error(GetLastError(), "GetModuleFileName", NULL); // Get to the last '\' (this one precedes the filename part). There is // always one after a call to GetModuleFileName(). TEXT* p = directory + len; do {--p;} while (*p != '\\'); *p = '\0'; const TEXT* const* const end = argv + argc; while (++argv < end) { if (**argv != '-') { const TEXT* cmd; USHORT i; for (i = 0; cmd = commands[i].name; i++) { const TEXT* q = cmd; for (p = *argv; *p && UPPER(*p) == *q; ++p, ++q) ; if (!*p && commands[i].abbrev <= (USHORT) (q - cmd)) break; } if (!cmd) { printf("Unknown command \"%s\"\n", *argv); usage_exit(); } sw_command = commands[i].code; } else { p = *argv + 1; switch (UPPER(*p)) { case 'Z': sw_version = true; break; case '?': usage_exit(); default: printf("Unknown switch \"%s\"\n", p); usage_exit(); } } } if (sw_version) printf("instreg version %s\n", FB_VERSION); if (sw_command == COMMAND_NONE) usage_exit(); HKEY hkey_node = HKEY_LOCAL_MACHINE; USHORT ret; switch (sw_command) { case COMMAND_INSTALL: ret = REGISTRY_install(hkey_node, directory, reg_error); if (ret != FB_SUCCESS) printf ("Firebird has not been installed in the registry.\n"); else printf("Firebird has been successfully installed in the registry.\n"); break; case COMMAND_REMOVE: ret = REGISTRY_remove(hkey_node, false, reg_error); if (ret != FB_SUCCESS) printf("Firebird has not been deleted from the registry.\n"); else printf("Firebird has been successfully deleted from the registry.\n"); break; default: ret = FB_SUCCESS; } if (hkey_node != HKEY_LOCAL_MACHINE) RegCloseKey(hkey_node); return (ret == FB_SUCCESS) ? FINI_OK : FINI_ERROR; }
DISC_DATA *fread_discipline( FILE * fp ) { char buf[MAX_STRING_LENGTH]; DISC_DATA *disc; bool fMatch; const char *word; CREATE( disc, DISC_DATA, 1 ); for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case '#': if( !str_cmp( word, "#Factor" ) ) { fMatch = TRUE; FACTOR_DATA *factor; CREATE( factor, FACTOR_DATA, 1 ); factor->id = fread_number( fp ); factor->factor_type = fread_number( fp ); factor->location = fread_number( fp ); factor->affect = fread_bitvector( fp ); factor->modifier = fread_float( fp ); factor->apply_type = fread_number( fp ); factor->duration = fread_float( fp ); factor->owner = disc; LINK( factor, disc->first_factor, disc->last_factor, next, prev ); break; } break; case 'C': KEY( "Cost", disc->cost, fread_bitvector( fp ) ); break; case 'D': KEY( "Damtype", disc->damtype, fread_bitvector( fp ) ); break; case 'E': if( !str_cmp( word, "End" ) ) return disc; case 'G': if( !str_cmp( word, "Gains" ) ) { fMatch = TRUE; disc->hit_gain = fread_number( fp ); disc->move_gain = fread_number( fp ); disc->mana_gain = fread_number( fp ); break; } break; case 'I': KEY( "ID", disc->id, fread_number( fp ) ); case 'M': KEY( "MinLevel", disc->min_level, fread_number( fp ) ); break; case 'N': KEY( "Name", disc->name, fread_string( fp ) ); break; case 'S': KEY( "SkillStyle", disc->skill_style, fread_bitvector( fp ) ); KEY( "SkillType", disc->skill_type, fread_bitvector( fp ) ); break; case 'T': KEY( "TargetType", disc->target_type, fread_bitvector( fp ) ); break; } if( !fMatch ) { sprintf( buf, "Fread_discipline: no match: %s", word ); bug( buf, 0 ); } } }
static opk_status_t boxsteplimits(opk_vspace_t* space, double* smin1, double* smin2, double* smax, const opk_vector_t* xvec, const void* lower, const void* upper, int bound, const opk_vector_t* dvec, int orient) { const REAL* x = DATA(xvec); const REAL* d = DATA(dvec); const REAL* xl; const REAL* xu; const REAL inf = FLOAT_CHOICE(FLT_MAX, DBL_MAX); REAL a, b; REAL s, s1, s2, s3; opk_index_t i, n; #define VALUE(addr) (*((double*)(addr))) #define BOXED(lo, hi) \ if (orient > 0) { \ for (i = 0; i < n; ++i) { \ REAL p = d[i]; \ if (p > 0) { \ s = (hi - x[i])/p; \ } else if (p < 0) { \ s = (lo - x[i])/p; \ } else { \ continue; \ } \ if (s < s1) s1 = s; \ if (s < s2 && s > 0) s2 = s; \ if (s > s3) s3 = s; \ } \ } else { \ for (i = 0; i < n; ++i) { \ REAL p = d[i]; \ if (p < 0) { \ s = (x[i] - hi)/p; \ } else if (p > 0) { \ s = (x[i] - lo)/p; \ } else { \ continue; \ } \ if (s < s1) s1 = s; \ if (s < s2 && s > 0) s2 = s; \ if (s > s3) s3 = s; \ } \ } #define LOWER(lo) \ if (orient > 0) { \ for (i = 0; i < n; ++i) { \ REAL p = d[i]; \ if (p < 0) { \ s = (lo - x[i])/p; \ if (s < s1) s1 = s; \ if (s < s2 && s > 0) s2 = s; \ if (s > s3) s3 = s; \ } else if (p > 0) { \ s3 = inf; \ } \ } \ } else { \ for (i = 0; i < n; ++i) { \ REAL p = d[i]; \ if (p > 0) { \ s = (x[i] - lo)/p; \ if (s < s1) s1 = s; \ if (s < s2 && s > 0) s2 = s; \ if (s > s3) s3 = s; \ } else if (p < 0) { \ s3 = inf; \ } \ } \ } #define UPPER(hi) \ if (orient > 0) { \ for (i = 0; i < n; ++i) { \ REAL p = d[i]; \ if (p > 0) { \ s = (hi - x[i])/p; \ if (s < s1) s1 = s; \ if (s < s2 && s > 0) s2 = s; \ if (s > s3) s3 = s; \ } else if (p < 0) { \ s3 = inf; \ } \ } \ } else { \ for (i = 0; i < n; ++i) { \ REAL p = d[i]; \ if (p < 0) { \ s = (x[i] - hi)/p; \ if (s < s1) s1 = s; \ if (s < s2 && s > 0) s2 = s; \ if (s > s3) s3 = s; \ } else if (p > 0) { \ s3 = inf; \ } \ } \ } /* Find the step limits. */ n = space->size; s1 = inf; s2 = inf; switch (bound) { case 0: s3 = inf; break; case 1: s3 = 0; a = VALUE(lower); LOWER(a); break; case 2: s3 = 0; xl = DATA(lower); LOWER(xl[i]); break; case 3: s3 = 0; b = VALUE(upper); UPPER(b); break; case 4: s3 = 0; a = VALUE(lower); b = VALUE(upper); BOXED(a, b); break; case 5: s3 = 0; xl = DATA(lower); b = VALUE(upper); BOXED(xl[i], b); break; case 6: s3 = 0; xu = DATA(upper); UPPER(xu[i]); break; case 7: s3 = 0; a = VALUE(lower); xu = DATA(upper); BOXED(a, xu[i]); break; case 8: s3 = 0; xl = DATA(lower); xu = DATA(upper); BOXED(xl[i], xu[i]); break; } #undef LOWER #undef UPPER #undef BOXED #undef VALUE if (smin1 != NULL) *smin1 = s1; if (smin2 != NULL) *smin2 = s2; if (smax != NULL) *smax = s3; return OPK_SUCCESS; }