void apply_delete(t_historic **historic) { int win_size; t_comline *tmp; if ((*historic)->copy->comline->c != '\0') { tmp = (*historic)->copy->comline->right; (*historic)->copy->comline = (*historic)->copy->comline->left; (*historic)->copy->comline->right = tmp; if (tmp) tmp->left = (*historic)->copy->comline; if ((win_size = check_beginning((*historic)->copy->comline))) { tputs(tgetstr("up", NULL), 1, aff_c); tputs(tgoto(tgetstr("ch", NULL), 0, win_size), 1, aff_c); } else tputs(tgetstr("le", NULL), 1, aff_c); tputs(tgetstr("dc", NULL), 1, aff_c); (*historic)->copy->size--; edit_line(historic); update_linecol(historic); print_comline(historic); } }
int main(int argc, char * argv[]) { if(argc != 2) { fprintf(stderr,"Error : Please enter the name of the edit file\n"); return EXIT_FAILURE; } else { FILE* edit_file = fopen(argv[1],"r"); edits_array my_edits; int i = 1; long_string current_line; char * c = current_line; fill_edits_array(my_edits,edit_file); while ( 1 ) { c = my_gets(current_line, stdin); if ( c == NULL ) break; edit_line(my_edits,current_line,i); i+=1; } free_edits_array(my_edits); free(edit_file); return EXIT_SUCCESS; } }
void enter_emote(User *usr) { char name[MAX_NAME], line[MAX_LINE], *p, *endp; XMsg *x; int sent; if ((x = new_XMsg()) == NULL) { Put(usr, "<red>Due to an error, you can not send messages now\n"); return; } if (edit_recipients(usr, multi_x_access) == -1) { destroy_XMsg(x); return; } if (usr->recipients.len <= 0) { destroy_XMsg(x); return; } check_recipients(usr); if (usr->recipients.len <= 0) { destroy_XMsg(x); return; } /* enter the message text */ Print(usr, "<cyan>* <white>%s <yellow>", usr->name); if (edit_line(usr, line, MAX_LINE) == -1 || !line[0]) { Put(usr, "<red>Message not sent\n"); destroy_XMsg(x); return; } ctrim_line(line); if (!line[0]) { Put(usr, "<red>Message not sent\n"); destroy_XMsg(x); return; } if (add_XMsg_line(x, line) == -1) { Put(usr, "<red>Due to an error, you can not send messages now\n"); destroy_XMsg(x); return; } check_recipients(usr); if (usr->recipients.len <= 0) { destroy_XMsg(x); return; } set_XMsg(x, XMSG_EMOTE, usr->name, usr->recipients.str, time(NULL)); sent = 0; p = usr->recipients.str; while((endp = cstrchr(p, ',')) != NULL) { *endp = 0; cstrcpy(name, p, MAX_NAME); *endp = ','; endp++; p = endp; sent += send_xmsg(usr, x, name); } cstrcpy(name, p, MAX_NAME); sent += send_xmsg(usr, x, name); if (sent) send_xmsg_bcc(usr, x); /* remember message as sent in 'this' user */ else destroy_XMsg(x); }