void remove_article(player *p,char *str) { note *article,*prev,*scan; char *oldstack; oldstack=stack; article=find_news_article(atoi(str)); if (!article) { sprintf(stack,"No such news article '%s'\n",str); stack=end_string(stack); tell_player(p,oldstack); stack=oldstack; return; } strcpy(stack,article->name); lower_case(stack); if (!(p->residency&(LOWER_ADMIN|ADMIN)) && strcmp(stack,p->lower_name)) { tell_player(p,"You can't remove an article that isn't yours.\n"); return; } scan=find_note(news_start); if (scan==article) news_start=article->next_sent; else { do { prev=scan; scan=find_note(scan->next_sent); } while(scan!=article); prev->next_sent=article->next_sent; } news_count--; remove_note(article); tell_player(p,"Article removed.\n"); stack=oldstack; }
note *find_news_article(int n) { int integrity=0; note *scan; if (n<1 || n>news_count) return 0; for(n--,scan=find_note(news_start);n;n--,integrity++) if (scan) scan=find_note(scan->next_sent); else { news_count=integrity; return 0; } return scan; }
void reconfigure_received_list(saved_player *sp) { int count=0; int *scan,*fill; char *oldstack; oldstack=stack; align(stack); fill=(int *)stack; scan=sp->mail_received; if (!scan) return; for(;*scan;scan++) if (((*scan)<0) || ((*scan)>65536)) { count=0; break; } else if (find_note(*scan)) { *(int *)stack=*scan; stack+=sizeof(int); count++; } FREE(sp->mail_received); if (count) { *(int *)stack=0; stack+=sizeof(int); count++; sp->mail_received=(int *)MALLOC(count*sizeof(int)); memcpy(sp->mail_received,oldstack,count*sizeof(int)); } else sp->mail_received=0; stack=oldstack; }
/* Remove a note */ static void do_nremove (CHAR_DATA *ch, char *argument) { NOTE_DATA *p; if (!is_number(argument)) { send_to_char ("Remove which note?\n\r",ch); return; } p = find_note (ch, ch->pcdata->board, atoi(argument)); if (!p) { send_to_char ("No such note.\n\r",ch); return; } if (str_cmp(ch->pcdata->switchname,p->sender) && ch->trust < MAX_LEVEL) { send_to_char ("You are not authorized to remove this note.\n\r",ch); return; } unlink_note (ch->pcdata->board,p); free_note (p); send_to_char ("Note removed!\n\r",ch); save_board(ch->pcdata->board); /* save the board */ }
/* Fills in the MAD register structure with CPU register * data read from core file. * * Parameters: * ctx - driver context * r - MAD register structure * tid - thread to return CPU registers for * * Returns: * size of CPU registers or zero in case of failure */ static size_t freebsd_regs( void *_ctx, mad_registers *r, int tid ) { ctx_freebsd *ctx = _ctx; Elf_Note note; prstatus_t status; char *note_name; /* Look for a NT_PRSTATUS note */ note.n_type = NT_PRSTATUS; note_name = find_note( ctx->fd, ctx->e_hdr, ctx->p_hdr, ctx->swap, ¬e ); if( note_name ) { free( note_name ); /* Read the program status (note descriptor data) */ if( read( ctx->fd, &status, sizeof( status ) ) == sizeof( status ) ) { r->x86.cpu.eax = status.pr_reg.r_eax; r->x86.cpu.ebx = status.pr_reg.r_ebx; r->x86.cpu.ecx = status.pr_reg.r_ecx; r->x86.cpu.edx = status.pr_reg.r_edx; r->x86.cpu.esi = status.pr_reg.r_esi; r->x86.cpu.edi = status.pr_reg.r_edi; r->x86.cpu.ebp = status.pr_reg.r_ebp; r->x86.cpu.esp = status.pr_reg.r_esp; r->x86.cpu.eip = status.pr_reg.r_eip; r->x86.cpu.efl = status.pr_reg.r_eflags; r->x86.cpu.cs = status.pr_reg.r_cs; r->x86.cpu.ds = status.pr_reg.r_ds; r->x86.cpu.ss = status.pr_reg.r_ss; r->x86.cpu.es = status.pr_reg.r_es; r->x86.cpu.fs = status.pr_reg.r_fs; r->x86.cpu.gs = status.pr_reg.r_gs; return( sizeof( struct x86_mad_registers ) ); } } return( 0 ); }
void recount_news(player *p,char *str) { int article; note *scan; news_count=0; scan=find_note(news_start); if (scan) { article=scan->next_sent; for(;scan;article=scan->next_sent,news_count++) { scan=find_note(article); if (!scan) break; } news_count++; } tell_player(p,"Tis Done ...\n"); }
void remove_any_note(note *n) { saved_player *sp; note *scan=0; char *oldstack; int *change; int recursive=0; oldstack=stack; if (n->flags&NEWS_ARTICLE) { scan=find_note(news_start); change=&news_start; while(scan && scan!=n) { change=&(scan->next_sent); scan=find_note(scan->next_sent); } if (scan==n) news_count--; } else { strcpy(stack,n->name); lower_case(stack); stack=end_string(stack); sp=find_saved_player(oldstack); if (!sp) { log("error","Bad owner name in mail(1)"); log("error",oldstack); recursive=n->next_sent; scan=0; } else { change=&(sp->mail_sent); scan=find_note(sp->mail_sent); while(scan && scan!=n) { change=&(scan->next_sent); scan=find_note(scan->next_sent); } } } if (scan==n) (*change)=n->next_sent; remove_note(n); if (recursive) unlink_mail(find_note(recursive)); stack=oldstack; }
void delete_received(player *p,char *str) { int number,count=0; int *make,*scan; char *oldstack; note *deleted; number=atoi(str); if (number<=0) { tell_player(p,"Format: delete <mail number>\n"); return; } if (!(p->saved)) { tell_player(p,"You have no save information, and therefore no mail either.\n"); return; } scan=p->saved->mail_received; if (!scan) { tell_player(p,"You have recieved no mail to delete.\n"); return; } oldstack=stack; align(stack); make=(int *)stack; for(number--;number;number--) if (*scan) { *make++=*scan++; count++; } else break; if (!*scan) { tell_player(p,"Not that many pieces of mail.\n"); stack=oldstack; return; } deleted=find_note(*scan++); while(*scan) { *make++=*scan++; count++; } *make++=0; count++; if (p->saved->mail_received) FREE(p->saved->mail_received); if (count!=1) { p->saved->mail_received=(int *)MALLOC(sizeof(int)*count); memcpy(p->saved->mail_received,stack,sizeof(int)*count); } else p->saved->mail_received=0; if (deleted) { deleted->read_count--; if (!(deleted->read_count)) unlink_mail(deleted); } tell_player(p,"Mail deleted....\n"); stack=oldstack; }
void delete_sent(player *p,char *str) { int number; note *scan; number=atoi(str); if (number<=0) { tell_player(p,"Format: remove <mail number>\n"); return; } if (!(p->saved)) { tell_player(p,"You have no save information, and therefore no mail either.\n"); return; } scan=find_note(p->saved->mail_sent); for(number--;number;number--) if (scan) scan=find_note(scan->next_sent); else break; if (!scan) { tell_player(p,"You haven't sent that many mails.\n"); return; } unlink_mail(scan); tell_player(p,"Removed mail ...\n"); }
void unlink_mail(note *m) { char *oldstack,*temp; saved_player *sp; int *change,recursive=0; note *scan,*tmp; if (!m) return; oldstack=stack; strcpy(stack,m->name); lower_case(stack); stack=end_string(stack); sp=find_saved_player(oldstack); if (!sp) { temp=stack; sprintf(stack,"(2) mail: %s - current: %s",m->name, current_player->name); stack=end_string(stack); log("error",temp); stack=temp; recursive=m->next_sent; } else { change=&(sp->mail_sent); scan=find_note(sp->mail_sent); while(scan && scan!=m) { change=&(scan->next_sent); scan=find_note(scan->next_sent); } tmp=find_note(m->next_sent); if (tmp) *change=tmp->id; else *change=0; } remove_note(m); if (recursive) unlink_mail(find_note(recursive)); stack=oldstack; }
int posted_count(player *p) { int scan,count=0; note *mail,*next ; if (!p->saved) return 0; scan=p->saved->mail_sent; mail=find_note(scan); if (!mail) { p->saved->mail_sent=0; return 0; } while(mail) { count++; scan=mail->next_sent; next=find_note(scan); if (!next && scan) { mail->next_sent=0; mail=0; } else mail=next; } return count; }
// // IDL:Calendar/find_note:1.0 // OB::DispatchStatus POA_Calendar::_OB_op_find_note(OB::Upcall_ptr _ob_up) { OB::InputStream_ptr _ob_in = _ob_up -> input_nodup(); OB::StrForStruct _ob_a0; _ob_a0 = _ob_in -> read_string(); date_var _ob_a1; _ob_up -> request(); CORBA::Boolean _ob_r = find_note(_ob_a0, _ob_a1.out()); _ob_up -> beginReply(); OB::OutputStream_ptr _ob_out = _ob_up -> output_nodup(); _ob_out -> write_boolean(_ob_r); date::_OB_marshal(_ob_a1.in(), _ob_out); return OB::DispatchStatusOK; }
void dest_note(player *p,char *str) { note *n; if (!*str) { tell_player(p,"Format: dest_note <number>\n"); return; } n=find_note(atoi(str)); if (!n) { tell_player(p,"Can't find note with that number.\n"); return; } remove_any_note(n); tell_player(p,"Note removed\n"); }
note *find_received(saved_player *sp,int n) { int *scan,count=1; note *mail; scan=sp->mail_received; if (!scan) return 0; for(;*scan;count++,scan++) if (count==n) { mail=find_note(*scan); if (!mail) { reconfigure_received_list(sp); return find_received(sp,n); } return mail; } return 0; }
/* Determine signal that killed process * * Parameters: * ctx - driver context * * Returns: * signal which killed dead process or zero if not available */ static long freebsd_qsig( void *_ctx ) { ctx_freebsd *ctx = _ctx; Elf_Note note; prstatus_t status; char *note_name; long sig = 0; note.n_type = NT_PRSTATUS; note_name = find_note( ctx->fd, ctx->e_hdr, ctx->p_hdr, ctx->swap, ¬e ); if( note_name ) { /* should we check the name string? */ free( note_name ); if( read( ctx->fd, &status, sizeof( status ) ) == sizeof( status ) ) { sig = status.pr_cursig; } } return( sig ); }
/* Attempts to determine the name of the executable from the core * file. The executable is likely to be required for determining * code segment data. * * Parameters: * ctx - driver context * name - pointer to output buffer * len - size of provided buffer * * Returns: * length of name string (sans terminating null) or zero in case of failure */ static size_t freebsd_name( void *_ctx, char *name, size_t len ) { ctx_freebsd *ctx = _ctx; Elf_Note note; prpsinfo_t info; char *note_name; note.n_type = NT_PRPSINFO; *name = '\0'; note_name = find_note( ctx->fd, ctx->e_hdr, ctx->p_hdr, ctx->swap, ¬e ); if( note_name ) { /* should we check the name string? */ free( note_name ); if( read( ctx->fd, &info, sizeof( info ) ) == sizeof( info ) ) { strncpy( name, info.pr_fname, len ); name[len - 1] = '\0'; } } return( strlen( name ) ); }
note *create_note() { note *n; int num; n=(note *)MALLOC(sizeof(note)); memset(n,0,sizeof(note)); n->flags = NOT_READY; n->date = time(0); n->next_sent=0; n->text.where=0; n->text.length=0; strcpy(n->header,"DEFUNCT"); strcpy(n->name,"system"); while(find_note(unique)) unique++; n->id=unique++; unique &= 65535; num=(n->id)%NOTE_HASH_SIZE; n->hash_next=n_hash[num]; n_hash[num]=n; nhash_update[num]=1; return n; }
void relink_note(player *p,char *str) { char *to; int id1,id2; note *n; to=next_space(str); *to++=0; id1=atoi(str); id2=atoi(to); /* if (!id1 || !id2) { tell_player(p,"Format : relink <number> <number>\n"); return; } */ n=find_note(id1); if (!n) { tell_player(p,"Can't find first note\n"); return; } n->next_sent=id2; tell_player(p,"next_sent pointer twiddled.\n"); return; }
void view_note(player *p,char *str) { note *n; char *oldstack; oldstack=stack; if (!*str) { tell_player(p,"Format: view_note <number>\n"); return; } n=find_note(atoi(str)); if (!n) { tell_player(p,"Can't find note with that number.\n"); return; } if (n->flags&NEWS_ARTICLE) strcpy(stack,"News Article.\n"); else strcpy(stack,"Mail (?).\n"); stack=strchr(stack,0); sprintf(stack,"Posted on %s, by %s.\nRead count: %d\n", convert_time(n->date),n->name,n->read_count); stack=strchr(stack,0); if (n->flags&ANONYMOUS) { strcpy(stack,"Posted anonymously.\n"); stack=strchr(stack,0); } if (n->flags&NOT_READY) { strcpy(stack,"Not ready flag set.\n"); stack=strchr(stack,0); } if (n->flags&SUPRESS_NAME) { strcpy(stack,"Name suppressed.\n"); stack=strchr(stack,0); } sprintf(stack,"Next link -> %d\n",n->next_sent); stack=end_string(stack); pager(p,oldstack,0); stack=oldstack; }
void view_sent(player *p,char *str) { char *oldstack; note *mail,*next; int count=1,scan; saved_player *sp; oldstack=stack; if (*str && p->residency&(LOWER_ADMIN|ADMIN)) { sp=find_saved_player(str); if (!sp) { tell_player(p,"No such player in save files.\n"); return; } else { scan=sp->mail_sent; mail=find_note(scan); if (!mail) { sp->mail_sent=0; tell_player(p,"You have sent no mail.\n"); return; } } } else { if (!p->saved) { tell_player(p,"You have no save file, and therefore no mail " "either.\n"); return; } scan=p->saved->mail_sent; mail=find_note(scan); if (!mail) { p->saved->mail_sent=0; tell_player(p,"You have sent no mail.\n"); return; } } strcpy(stack,"Listing mail sent...\n"); stack=strchr(stack,0); while(mail) { if (p->residency&(LOWER_ADMIN|ADMIN)) sprintf(stack,"(%d) [%d] %d - %s\n",mail->id,count, mail->read_count,mail->header); else sprintf(stack,"[%d] %d - %s\n",count,mail->read_count, mail->header); stack=strchr(stack,0); scan=mail->next_sent; count++; next=find_note(scan); if (!next && scan) { mail->next_sent=0; mail=0; } else mail=next; } sprintf(stack,"You have sent %d out of your maximum of %d mails.\n", count-1,p->max_mail); stack=end_string(stack); tell_player(p,oldstack); stack=oldstack; }
void view_received(player *p,char *str) { char *oldstack,middle[80],*page_input; int page,pages,*scan,*scan_count,mcount=0,ncount=1,n; note *mail; saved_player *sp; oldstack=stack; if (*str && !isdigit(*str) && p->residency&(LOWER_ADMIN|ADMIN)) { page_input=next_space(str); if (*page_input) *page_input++=0; sp=find_saved_player(str); if (!sp) { tell_player(p,"No such player in save files.\n"); return; } else scan=sp->mail_received; str=page_input; } else { if (!p->saved) { tell_player(p,"You have no save file, and therefore no mail either.\n"); return; } sp=p->saved; scan=sp->mail_received; } if (!scan) { tell_player(p,"You have received no mail.\n"); return; } p->saved_flags &= ~NEW_MAIL; for(scan_count=scan;*scan_count;scan_count++) mcount++; page=atoi(str); if (page<=0) page=1; page--; pages=(mcount-1)/(TERM_LINES-2); if (page>pages) page=pages; if (mcount==1) strcpy(middle,"You have received one letter"); else sprintf(middle,"You have received %s letters", number2string(mcount)); pstack_mid(middle); ncount=page*(TERM_LINES-2); scan += ncount; for(n=0,ncount++;n<(TERM_LINES-1);n++,ncount++,scan++) { if (!*scan) break; mail=find_note(*scan); if (!mail) { stack=oldstack; tell_player(p,"Found mail that owner had deleted ...\n"); reconfigure_received_list(sp); if (sp!=p->saved) { tell_player(p,"Reconfigured ... try again\n"); return; } view_received(p,str); return; } if (p->residency&(LOWER_ADMIN|ADMIN)) sprintf(stack,"(%d) [%d] ",mail->id,ncount); else sprintf(stack,"[%d] ",ncount); while(*stack) *stack++; if (ncount<10) *stack++=' '; strcpy(stack,mail->header); while(*stack) *stack++; if (mail->flags&ANONYMOUS) { if (p->residency&(LOWER_ADMIN|ADMIN)) sprintf(stack," <%s>\n",mail->name); else strcpy(stack,"\n"); } else sprintf(stack," (%s)\n",mail->name); while(*stack) *stack++; } sprintf(middle,"Page %d of %d",page+1,pages+1); pstack_mid(middle); *stack++=0; tell_player(p,oldstack); stack=oldstack; }
void list_news(player *p,char *str) { char *oldstack,middle[80]; int page,pages,count,article,ncount=1; note *scan; oldstack=stack; if (!news_count) { tell_player(p,"No news articles to view.\n"); return; } page=atoi(str); if (page<=0) page=1; page--; pages=(news_count-1)/(TERM_LINES-2); if (page>pages) page=pages; if (news_count==1) strcpy(middle,"There is one news article"); else sprintf(middle,"There are %s articles", number2string(news_count)); pstack_mid(middle); count=page*(TERM_LINES-2); for(article=news_start;count;count--,ncount++) { scan=find_note(article); if (!scan) { tell_player(p,"Bad news listing, aborted.\n"); log("error","Bad news list"); stack=oldstack; return; } article=scan->next_sent; } for(count=0;(count<(TERM_LINES-1));count++,ncount++) { scan=find_note(article); if (!scan) break; if (p->residency&(LOWER_ADMIN|ADMIN)) sprintf(stack,"(%d) [%d] ",scan->id,ncount); else sprintf(stack,"[%d] ",ncount); while(*stack) *stack++; if (ncount<10) *stack++=' '; strcpy(stack,scan->header); while(*stack) *stack++; if (scan->flags&ANONYMOUS) { if (p->residency&(LOWER_ADMIN|ADMIN)) sprintf(stack," <%s>\n",scan->name); else strcpy(stack,"\n"); } else sprintf(stack," (%s)\n",scan->name); stack=strchr(stack,0); article=scan->next_sent; } sprintf(middle,"Page %d of %d",page+1,pages+1); pstack_mid(middle); *stack++=0; tell_player(p,oldstack); stack=oldstack; }