/* This function takes the character string in ch->pnote and * creates rooms laid out in the appropriate configuration. */ void map_to_rooms( CHAR_DATA * ch, MAP_INDEX_DATA * m_index ) { struct map_stuff map[49][78]; /* size of edit buffer */ const char *newmap; int row, col, i, n, x, y, tvnum, proto_vnum = 0, leftmost, rightmost; int newx, newy; const char *l; char c; ROOM_INDEX_DATA *newrm; MAP_INDEX_DATA *map_index = NULL, *tmp; EXIT_DATA *xit; /* these are for exits */ bool getroomnext = FALSE; if( !ch->pnote ) { bug( "%s: ch->pnote==NULL!", __FUNCTION__ ); return; } /* * Make sure format is right */ newmap = check_map( ch->pnote->text ); STRFREE( ch->pnote->text ); ch->pnote->text = STRALLOC( newmap ); n = 0; row = col = 0; leftmost = rightmost = 0; /* * Check to make sure map_index exists. * If not, then make a new one. */ if( !m_index ) { /* * Make a new vnum */ for( i = ch->pcdata->area->low_r_vnum; i <= ch->pcdata->area->hi_r_vnum; i++ ) { if( ( tmp = get_map_index( i ) ) == NULL ) { map_index = make_new_map_index( i ); break; } } } else map_index = m_index; /* * */ if( !map_index ) { send_to_char( "Couldn't find or make a map_index for you!\r\n", ch ); bug( "%s", "map_to_rooms: Couldn't find or make a map_index\r\n" ); /* * do something. return failed or somesuch */ return; } for( x = 0; x < 49; x++ ) { for( y = 0; y < 78; y++ ) { map[x][y].vnum = 0; map[x][y].proto_vnum = 0; map[x][y].exits = 0; map[x][y].index = 0; } } l = ch->pnote->text; do { c = l[0]; switch ( c ) { case '\n': break; case '\r': col = 0; row++; break; } if( c != ' ' && c != '-' && c != '|' && c != '=' && c != '\\' && c != '/' && c != '^' && c != ':' && c != '[' && c != ']' && c != '^' && !getroomnext ) { l++; continue; } if( getroomnext ) { n++; /* * Actual room info */ map[row][col].vnum = add_new_room_to_map( ch, c ); map_index->map_of_vnums[row][col] = map[row][col].vnum; map[row][col].proto_vnum = proto_vnum; getroomnext = FALSE; } else { map_index->map_of_vnums[row][col] = 0; map[row][col].vnum = 0; map[row][col].exits = 0; } map[row][col].code = c; /* * Handle rooms */ if( c == '[' ) getroomnext = TRUE; col++; l++; } while( c != '\0' ); for( y = 0; y < ( row + 1 ); y++ ) { /* rows */ for( x = 0; x < 78; x++ ) { /* cols (78, i think) */ if( map[y][x].vnum == 0 ) continue; newrm = get_room_index( map[y][x].vnum ); /* * Continue if no newrm */ if( !newrm ) continue; /* * Check up */ if( y > 1 ) { newx = x; newy = y; newy--; while( newy >= 0 && ( map[newy][x].code == '^' ) ) newy--; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][x].vnum ) break; if( ( tvnum = map[newy][x].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_UP ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check down */ if( y < 48 ) { newx = x; newy = y; newy++; while( newy <= 48 && ( map[newy][x].code == '^' ) ) newy++; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][x].vnum ) break; if( ( tvnum = map[newy][x].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_DOWN ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check north */ if( y > 1 ) { newx = x; newy = y; newy--; while( newy >= 0 && ( map[newy][x].code == '|' || map[newy][x].code == ':' || map[newy][x].code == '=' ) ) newy--; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][x].vnum ) break; if( ( tvnum = map[newy][x].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTH ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; if( map[newy + 1][x].code == ':' || map[newy + 1][x].code == '=' ) { SET_BIT( xit->exit_info, EX_ISDOOR ); SET_BIT( xit->exit_info, EX_CLOSED ); } else xit->exit_info = 0; } } /* * Check south */ if( y < 48 ) { newx = x; newy = y; newy++; while( newy <= 48 && ( map[newy][x].code == '|' || map[newy][x].code == ':' || map[newy][x].code == '=' ) ) newy++; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][x].vnum ) break; if( ( tvnum = map[newy][x].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTH ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; if( map[newy - 1][x].code == ':' || map[newy - 1][x].code == '=' ) { SET_BIT( xit->exit_info, EX_ISDOOR ); SET_BIT( xit->exit_info, EX_CLOSED ); } else xit->exit_info = 0; } } /* * Check east */ if( x < 79 ) { newx = x; newy = y; newx++; while( newx <= 79 && ( map[y][newx].code == '-' || map[y][newx].code == ':' || map[y][newx].code == '=' || map[y][newx].code == '[' || map[y][newx].code == ']' ) ) newx++; /* * dont link it to itself */ if( map[y][x].vnum == map[y][newx].vnum ) break; if( ( tvnum = map[y][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_EAST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; if( map[y][newx - 2].code == ':' || map[y][newx - 2].code == '=' ) { SET_BIT( xit->exit_info, EX_ISDOOR ); SET_BIT( xit->exit_info, EX_CLOSED ); } else xit->exit_info = 0; } } /* * Check west */ if( x > 1 ) { newx = x; newy = y; newx--; while( newx >= 0 && ( map[y][newx].code == '-' || map[y][newx].code == ':' || map[y][newx].code == '=' || map[y][newx].code == '[' || map[y][newx].code == ']' ) ) newx--; /* * dont link it to itself */ if( map[y][x].vnum == map[y][newx].vnum ) break; if( ( tvnum = map[y][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_WEST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; if( map[y][newx + 2].code == ':' || map[y][newx + 2].code == '=' ) { SET_BIT( xit->exit_info, EX_ISDOOR ); SET_BIT( xit->exit_info, EX_CLOSED ); } else xit->exit_info = 0; } } /* * Check southeast */ if( y < 48 && x < 79 ) { newx = x; newy = y; newx += 2; newy++; while( newx <= 79 && newy <= 48 && ( map[newy][newx].code == '\\' || map[newy][newx].code == ':' || map[newy][newx].code == '=' ) ) { newx++; newy++; } if( map[newy][newx].code == '[' ) newx++; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][newx].vnum ) break; if( ( tvnum = map[newy][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTHEAST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check northeast */ if( y > 1 && x < 79 ) { newx = x; newy = y; newx += 2; newy--; while( newx >= 0 && newy <= 48 && ( map[newy][newx].code == '/' || map[newy][newx].code == ':' || map[newy][newx].code == '=' ) ) { newx++; newy--; } if( map[newy][newx].code == '[' ) newx++; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][newx].vnum ) break; if( ( tvnum = map[newy][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTHEAST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check northwest */ if( y > 1 && x > 1 ) { newx = x; newy = y; newx -= 2; newy--; while( newx >= 0 && newy >= 0 && ( map[newy][newx].code == '\\' || map[newy][newx].code == ':' || map[newy][newx].code == '=' ) ) { newx--; newy--; } if( map[newy][newx].code == ']' ) newx--; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][newx].vnum ) break; if( ( tvnum = map[newy][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTHWEST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check southwest */ if( y < 48 && x > 1 ) { newx = x; newy = y; newx -= 2; newy++; while( newx >= 0 && newy <= 48 && ( map[newy][newx].code == '/' || map[newy][newx].code == ':' || map[newy][newx].code == '=' ) ) { newx--; newy++; } if( map[newy][newx].code == ']' ) newx--; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][newx].vnum ) break; if( ( tvnum = map[newy][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTHWEST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } } } }
void redit_parse( DESCRIPTOR_DATA *d , char *arg ) { ROOM_DATA *room = d->character->dest_buf; ROOM_DATA *tmp; EXIT_DATA *pexit = d->character->spare_ptr; EXTRA_DESCR_DATA *ed = d->character->spare_ptr; char arg1[MIL]; char buf[MSL]; int number = 0; switch ( OLC_MODE(d) ) { case REDIT_CONFIRM_SAVESTRING: switch ( *arg ) { case 'y': case 'Y': /* redit_save_internally(d); */ send_log( NULL, LOG_OLC, "OLC: %s edits room %d", d->character->name, OLC_NUM(d) ); cleanup_olc( d ); send_to_char( d->character, "Room saved to memory.\r\n" ); break; case 'n': case 'N': cleanup_olc( d ); break; default: send_to_char( d->character, "Invalid choice!\r\n" ); send_to_char( d->character, "Do you wish to save this room internally? : " ); break; } return; case REDIT_MAIN_MENU: switch ( *arg ) { case 'q': case 'Q': /* if ( OLC_CHANGE(d) ) { *. Something has been modified .* send_to_char( d->character, "Do you wish to save this room internally? : " ); OLC_MODE(d) = REDIT_CONFIRM_SAVESTRING; } else */ cleanup_olc( d ); return; case '1': send_to_char( d->character, "Enter room name:-\r\n| " ); OLC_MODE(d) = REDIT_NAME; break; case '2': OLC_MODE(d) = REDIT_DESC; d->character->substate = SUB_ROOM_DESCR; d->character->last_cmd = do_redit_reset; send_to_char( d->character, "Enter room description:-\r\n" ); if ( !room->description ) room->description = str_dup( "" ); start_editing( d->character, room->description ); break; case '3': redit_disp_flag_menu(d); break; case '4': redit_disp_sector_menu(d); break; case '5': send_to_char( d->character, "How many people can fit in the room? " ); OLC_MODE(d) = REDIT_TUNNEL; break; case '6': send_to_char( d->character, "How long before people are teleported out? " ); OLC_MODE(d) = REDIT_TELEDELAY; break; case '7': send_to_char( d->character, "Where are they teleported to? " ); OLC_MODE(d) = REDIT_TELEVNUM; break; case 'a': case 'A': redit_disp_exit_menu(d); break; case 'b': case 'B': redit_disp_extradesc_menu(d); break; default: send_to_char( d->character, "Invalid choice!" ); redit_disp_menu(d); break; } return; case REDIT_NAME: DISPOSE( room->name ); room->name = str_dup( arg ); olc_log( d, "Changed name to %s", room->name ); break; case REDIT_DESC: /* we will NEVER get here */ send_log( NULL, LOG_OLC, "redit_parse: reached REDIT_DESC case in redit_parse" ); break; case REDIT_FLAGS: if ( is_number(arg) ) { number = atoi( arg ); if ( number == 0 ) break; else if ( number < 0 || number >= MAX_ROOM ) { send_to_char( d->character, "Invalid flag, try again: " ); return; } else { number--; /* Offset for 0 */ TOGGLE_BIT( room->flags, number ); olc_log( d, "%s the room flag %s", HAS_BIT( room->flags, number ) ? "Added" : "Removed", code_name(NULL, number, CODE_ROOM) ); } } else { while ( VALID_STR(arg) ) { arg = one_argument( arg, arg1 ); number = code_num( NULL, arg1, CODE_ROOM ); if ( number > 0 ) { TOGGLE_BIT( room->flags, number ); olc_log( d, "%s the room flag %s", HAS_BIT( room->flags, number ) ? "Added" : "Removed", code_name( NULL, number, CODE_ROOM) ); } } } redit_disp_flag_menu(d); return; case REDIT_SECTOR: number = atoi( arg ); if ( number < 0 || number >= MAX_SECTOR ) { send_to_char( d->character, "Invalid choice!" ); redit_disp_sector_menu(d); return; } else room->sector = number; olc_log( d, "Changed sector to %s", code_name(NULL, number, CODE_SECTOR) ); break; case REDIT_TUNNEL: number = atoi( arg ); room->tunnel = URANGE( 0, number, 1000 ); olc_log( d, "Changed tunnel amount to %d", room->tunnel ); break; case REDIT_TELEDELAY: number = atoi( arg ); room->tele_delay = number; olc_log( d, "Changed teleportation delay to %d", room->tele_delay ); break; case REDIT_TELEVNUM: number = atoi( arg ); room->tele_vnum = URANGE( 1, number, MAX_VNUM-1 ); olc_log( d, "Changed teleportation vnum to %d", room->tele_vnum ); break; case REDIT_EXIT_MENU: switch ( toupper(arg[0]) ) { default: if ( is_number(arg) ) { number = atoi( arg ); pexit = get_exit_num( room, number ); d->character->spare_ptr = pexit; redit_disp_exit_edit(d); return; } redit_disp_exit_menu( d ); return; case 'A': OLC_MODE(d) = REDIT_EXIT_ADD; redit_disp_exit_dirs( d ); return; case 'R': OLC_MODE(d) = REDIT_EXIT_DELETE; send_to_char( d->character, "Delete which exit? " ); return; case 'Q': d->character->spare_ptr = NULL; break; } break; case REDIT_EXIT_EDIT: switch ( toupper(arg[0]) ) { case 'Q': d->character->spare_ptr = NULL; redit_disp_exit_menu(d); return; case '1': /* OLC_MODE(d) = REDIT_EXIT_DIR; redit_disp_exit_dirs(d); */ send_to_char( d->character, "This option can only be changed by remaking the exit.\r\n" ); break; case '2': OLC_MODE(d) = REDIT_EXIT_VNUM; send_to_char( d->character, "Which room does this exit go to? " ); return; case '3': OLC_MODE(d) = REDIT_EXIT_KEY; send_to_char( d->character, "What is the vnum of the key to this exit? " ); return; case '4': OLC_MODE(d) = REDIT_EXIT_KEYWORD; send_to_char( d->character, "What is the keyword to this exit? " ); return; case '5': OLC_MODE(d) = REDIT_EXIT_FLAGS; redit_disp_exit_flag_menu(d); return; case '6': OLC_MODE(d) = REDIT_EXIT_DESC; send_to_char( d->character, "Description:\r\n] " ); return; } redit_disp_exit_edit(d); return; case REDIT_EXIT_DESC: if ( !VALID_STR(arg) ) { DISPOSE( pexit->description ); pexit->description = str_dup( "" ); } else { sprintf( buf, "%s\r\n", arg ); DISPOSE( pexit->description ); pexit->description = str_dup( buf ); } olc_log( d, "Changed %s description to %s", code_name( NULL, pexit->vdir, CODE_DIR), arg ? arg : "none" ); redit_disp_exit_edit(d); return; case REDIT_EXIT_ADD: if ( is_number( arg ) ) { number = atoi( arg ); if ( number < 0 || number >= MAX_DIR ) { send_to_char( d->character, "Invalid direction, try again: " ); return; } d->character->tempnum = number; } else { number = get_dir(arg); pexit = get_exit( room, number ); if ( pexit ) { send_to_char( d->character, "An exit in that direction already exists.\r\n" ); redit_disp_exit_menu(d); return; } d->character->tempnum = number; } OLC_MODE(d) = REDIT_EXIT_ADD_VNUM; send_to_char( d->character, "Which room does this exit go to? " ); return; case REDIT_EXIT_ADD_VNUM: number = atoi( arg ); if ( (tmp = get_room_index(NULL, number)) == NULL ) { send_to_char( d->character, "Non-existant room.\r\n" ); OLC_MODE(d) = REDIT_EXIT_MENU; redit_disp_exit_menu(d); return; } pexit = make_exit( room, tmp, d->character->tempnum ); DISPOSE( pexit->keyword ); DISPOSE( pexit->description ); pexit->keyword = str_dup( "" ); pexit->description = str_dup( "" ); pexit->key = -1; pexit->flags = 0; act( AT_ADMIN, "$n reveals a hidden passage!", d->character, NULL, NULL, TO_ROOM ); d->character->spare_ptr = pexit; olc_log( d, "Added %s exit to %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->vnum ); OLC_MODE(d) = REDIT_EXIT_EDIT; redit_disp_exit_edit(d); return; case REDIT_EXIT_DELETE: if ( !is_number( arg ) ) { send_to_char( d->character, "Exit must be specified in a number.\r\n" ); redit_disp_exit_menu(d); } number = atoi( arg ); pexit = get_exit_num( room, number ); if ( !pexit ) { send_to_char( d->character, "That exit does not exist.\r\n" ); redit_disp_exit_menu(d); } olc_log( d, "Removed %s exit", code_name( NULL, pexit->vdir, CODE_DIR) ); extract_exit( room, pexit ); redit_disp_exit_menu( d ); return; case REDIT_EXIT_VNUM: number = atoi( arg ); if ( number < 1 || number >= MAX_VNUM ) { send_to_char( d->character, "Invalid room number, try again : " ); return; } if ( get_room_index(NULL, number) == NULL ) { send_to_char( d->character, "That room does not exist, try again: " ); return; } pexit->vnum = number; olc_log( d, "%s exit vnum changed to %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->vnum ); redit_disp_exit_menu( d ); return; case REDIT_EXIT_KEYWORD: DISPOSE( pexit->keyword ); pexit->keyword = str_dup( arg ); olc_log( d, "Changed %s keyword to %s", code_name( NULL, pexit->vdir, CODE_DIR), pexit->keyword ); redit_disp_exit_edit( d ); return; case REDIT_EXIT_KEY: number = atoi( arg ); if ( number < 1 || number >= MAX_VNUM ) send_to_char( d->character, "Invalid vnum, try again: " ); else { pexit->key = number; redit_disp_exit_edit( d ); } olc_log( d, "%s key vnum is now %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->key ); return; case REDIT_EXIT_FLAGS: number = atoi( arg ); if ( number == 0 ) { redit_disp_exit_edit( d ); return; } if ( number < 0 || number >= MAX_EXIT || ((number-1) == EXIT_RES1) || ((number-1) == EXIT_RES2) || ((number-1) == EXIT_PORTAL) ) { send_to_char( d->character, "That's not a valid choice!\r\n" ); redit_disp_exit_flag_menu( d ); } number -= 1; TOGGLE_BIT( pexit->flags, number ); olc_log( d, "%s %s to %s exit", HAS_BIT(pexit->flags, number) ? "Added" : "Removed", code_name(NULL, number, CODE_EXIT), code_name(NULL, pexit->vdir, CODE_DIR) ); redit_disp_exit_flag_menu( d ); return; case REDIT_EXTRADESC_DELETE: ed = redit_find_extradesc( room, atoi(arg) ); if ( !ed ) { send_to_char( d->character, "Not found, try again: " ); return; } olc_log( d, "Deleted exdesc %s", ed->keyword ); UNLINK( ed, room->first_extradescr, room->last_extradescr, next, prev ); DISPOSE( ed->keyword ); DISPOSE( ed->description ); DISPOSE( ed ); top_ed--; redit_disp_extradesc_menu(d); return; case REDIT_EXTRADESC_CHOICE: switch ( toupper( arg[0] ) ) { case 'Q': if ( !ed->keyword || !ed->description ) { send_to_char( d->character, "No keyword and/or description, junking..." ); UNLINK( ed, room->first_extradescr, room->last_extradescr, next, prev ); DISPOSE( ed->keyword ); DISPOSE( ed->keyword ); DISPOSE( ed ); top_ed--; } d->character->spare_ptr = NULL; redit_disp_extradesc_menu(d); return; case '1': OLC_MODE(d) = REDIT_EXTRADESC_KEY; send_to_char( d->character, "Keywords, seperated by spaces: " ); return; case '2': OLC_MODE(d) = REDIT_EXTRADESC_DESCRIPTION; d->character->substate = SUB_ROOM_EXTRA; d->character->last_cmd = do_redit_reset; send_to_char( d->character, "Enter new extradesc description: \r\n" ); start_editing( d->character, ed->description ); return; } break; case REDIT_EXTRADESC_KEY: /* if ( SetRExtra( room, arg ) ) { send_to_char( d->character, "A extradesc with that keyword already exists.\r\n" ); redit_disp_extradesc_menu(d); return; } */ olc_log( d, "Changed exkey %s to %s", ed->keyword, arg ); DISPOSE( ed->keyword ); ed->keyword = str_dup( arg ); oedit_disp_extra_choice(d); OLC_MODE(d) = REDIT_EXTRADESC_CHOICE; return; case REDIT_EXTRADESC_MENU: switch ( toupper( arg[0] ) ) { case 'Q': break; case 'A': CREATE( ed, EXTRA_DESCR_DATA, 1 ); LINK( ed, room->first_extradescr, room->last_extradescr, next, prev ); ed->keyword = str_dup( "" ); ed->description = str_dup( "" ); top_ed++; d->character->spare_ptr = ed; olc_log( d, "Added new exdesc" ); oedit_disp_extra_choice(d); OLC_MODE(d) = REDIT_EXTRADESC_CHOICE; return; case 'R': OLC_MODE(d) = REDIT_EXTRADESC_DELETE; send_to_char( d->character, "Delete which extra description? " ); return; default: if ( is_number(arg) ) { ed = redit_find_extradesc( room, atoi(arg) ); if ( !ed ) { send_to_char( d->character, "Not found, try again: " ); return; } d->character->spare_ptr = ed; oedit_disp_extra_choice(d); OLC_MODE(d) = REDIT_EXTRADESC_CHOICE; } else redit_disp_extradesc_menu(d); return; } break; default: /* we should never get here */ send_log( NULL, LOG_OLC, "redit_parse: reached default case in parse_redit" ); break; } /* chiude lo switch */ /* Log the changes, so we can keep track of those sneaky bastards */ /* Don't log on the flags cause it does that above */ /* if ( OLC_MODE(d) != REDIT_FLAGS ) olc_log( d, arg ); */ /*. If we get this far, something has be changed .*/ OLC_CHANGE(d) = TRUE; redit_disp_menu(d); }
int main(int argc, char *argv[]) /* usage: mod_syslog mode ownpath syslogconf */ { int syslogd_pid, n_lines_copied=0; int otp_sw, find_sw=FALSE; char buf[BUFFER_SIZE], pipename[MAXNAME_SIZE], srcname[MAXNAME_SIZE]; FILE *srcfile, *destfile, *pidfile; void make_exit(int); /* enough arguments? */ if(argc < NARG+1) make_exit(ARG_ERROR); /* enable OTP or not */ if(strcmp(argv[MODE], "otp") == 0) otp_sw = TRUE; else if(strcmp(argv[MODE], "nootp") == 0) otp_sw = FALSE; else make_exit(ARG_ERROR); /* make pipename */ strcpy(pipename, argv[OWNPATH]); strcat(pipename, "/"); strcat(pipename, PIPENAME); /* remove old pipe and make a new one */ if(otp_sw){ /* remove */ unlink(pipename); /* make a new */ if(mknod(pipename, S_IFIFO | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, (dev_t)0) != 0) make_exit(FILE_ERROR); } /* make source filename */ strcpy(srcname, argv[OWNPATH]); strcat(srcname, "/"); strcat(srcname, otp_sw?SYSLOGCONF_OTP:SYSLOGCONF_ORIG); /* open source and destination, exit if error */ if((srcfile = fopen(srcname, "r")) == NULL || (destfile = fopen(argv[SYSLOGCONF], "w")) == NULL) make_exit(FILE_ERROR); /* copy source and destination, exit if error */ while(fgets(buf, BUFFER_SIZE-1, srcfile) != NULL){ /* find_sw |= strstr(buf, PIPENAME) != NULL; */ n_lines_copied++; if(fputs(buf, destfile) == EOF) make_exit(FILE_ERROR); } if(ferror(srcfile) || n_lines_copied == 0) make_exit(FILE_ERROR); /* open pidfile, exit if error */ if((pidfile = fopen(SYSLOG_PID, "r")) == NULL) make_exit(FILE_ERROR); /* read pid for syslogd, exit if error */ if(fscanf(pidfile, "%d", &syslogd_pid) == 0) make_exit(FILE_ERROR); /* send HUP to syslogd, exit if error */ if(syslogd_pid < 0 || kill((pid_t)syslogd_pid, SIGHUP) != 0) make_exit(KILL_ERROR); /* remove pipe */ if(!otp_sw){ sleep((unsigned)WAIT); unlink(pipename); } /* ending successful or with warning */ /* if(!find_sw && otp_sw) make_exit(PIPE_NOT_FOUND); else */ make_exit(OK); return 0; }