//**************************************************************************** int CTerminal::save_terminal_contents(char *outfile, file_type_e file_type) { FILE *fd = NULL ; int lcount = 0 ; term_lview_item_p lvptr ; char msgstr[260] ; char dbuffer [9]; char tbuffer [9]; _strdate( dbuffer ); _strtime( tbuffer ); switch (file_type) { case FTYP_TEXT: fd = fopen(outfile, "a+t") ; if (fd == NULL) { return -(int)GetLastError(); } fseek(fd, 0, SEEK_END) ; fprintf(fd, "***********************************************************************\n") ; fprintf(fd, "Date/Time of report: %s, %s\n", dbuffer, tbuffer) ; for (lvptr = tlv_top; lvptr != NULL; lvptr = lvptr->next) { lcount++ ; fprintf(fd, "%s\n", lvptr->msg) ; } break; case FTYP_HTML: if (file_exists(outfile)) { // from January 1999 MSDN: // When a file is opened with the "a" or "a+" access type, // all write operations occur at the end of the file. // The file pointer can be repositioned using fseek or rewind, // but is always moved back to the end of the file before any // write operation is carried out. // Thus, existing data cannot be overwritten. // syslog("appending to existing file\n") ; fd = fopen(outfile, "r+t") ; if (fd == NULL) { return -(int)GetLastError(); } fseek(fd, 0, SEEK_END) ; // back up pointer to over-write closing HTML tags fseek(fd, (long) -16, SEEK_CUR) ; } else { // syslog("writing to html file\n") ; fd = fopen(outfile, "wt") ; if (fd == NULL) { return -(int)GetLastError(); } fprintf(fd, "<html><head><title>%s</title>" // STYLE was not needed once I converted to using PRE tag. // "<STYLE type='text/css'>\n" // "* { font-family: Courier, monospace }\n" // "</STYLE>\n" "</head><body>\n", outfile) ; } fprintf(fd, "<pre>\n") ; html_output(fd, WIN_BGREEN, WIN_GREY, "***********************************************************************") ; sprintf(msgstr, "Date/Time of report: %s, %s", dbuffer, tbuffer) ; html_output(fd, WIN_BGREEN, WIN_GREY, msgstr) ; for (lvptr = tlv_top; lvptr != NULL; lvptr = lvptr->next) { lcount++ ; // fprintf(fd, "%s\n", lvptr->msg) ; html_output(fd, lvptr->fgnd, lvptr->bgnd, lvptr->msg) ; } fprintf(fd, "</pre>\n") ; fprintf(fd, "</body></html>\n") ; break; // default: // return -(int)ERROR_INVALID_DATA; // break; } if (fd != NULL) { fflush(fd) ; fclose(fd) ; clear_message_area(); return lcount ; } termout("invalid file_type [%u]", (uint) file_type) ; return -(int) ERROR_INVALID_DATA; }
void rotate_atoms(double *axis, double phi, Boolean store_g, Boolean rot_subset) { void adjust_current_frame(void); void canvas_cb(Widget, XtPointer, XtPointer); void clear_message_area (void); void deactivate_region(void); void normalize_vec(double *); void rotate(double *); void rotate_vectors(double *, double); void set_rotate_axis(double *); void set_rotate_angle(double); void set_rotate_origin(double *); void store_coords(void); void update_bbox(void); void update_bond_matrix(Boolean); void update_lengths_dialog(Boolean); void vector_product(double *, double *, double *); int i,all_rotated; double local_com[3], local_mass; double atom_coords[3]; all_rotated = 1; local_com[0] = local_com[1] = local_com[2] = 0; local_mass = 0; changing_frame = False; if((rotate_about == ROTATE_ABOUT_ORIGIN) || changing_frame) { set_rotate_origin(NULL); for(i = 0; i < no_atoms; i++) { if(atoms[i].edit == 0) { all_rotated = 0; atoms_sorted = 0; /* Depths have changed */ } } } else if(rotate_about == ROTATE_ABOUT_LOCAL_COM) { for(i = 0; i < no_atoms; i++) { if(atoms[i].edit == 1) { local_com[0] += atoms[i].mass * atoms[i].x; local_com[1] += atoms[i].mass * atoms[i].y; local_com[2] += atoms[i].mass * atoms[i].z; local_mass += atoms[i].mass; } else { all_rotated = 0; atoms_sorted = 0; /* Depths have changed */ } } for(i = 0; i < 3; i++) { if (local_mass == 0) { /* All dummy atoms? */ local_com[i] = 0; } else { local_com[i] /= local_mass; } } set_rotate_origin(local_com); } set_rotate_axis(axis); set_rotate_angle(phi); for(i = 0; i < no_atoms; i++) { if((atoms[i].edit == 1) || (rot_subset == 0)) { atom_coords[0] = atoms[i].x; atom_coords[1] = atoms[i].y; atom_coords[2] = atoms[i].z; rotate(atom_coords); atoms[i].x = atom_coords[0]; atoms[i].y = atom_coords[1]; atoms[i].z = atom_coords[2]; } } if (bbox_available) { for (i = 0; i < 8; i++) { rotate (file_bbox.v[i]); } } if(store_g && all_rotated){ /* modify global vectors describing current orientation of frame */ set_rotate_origin(NULL); for(i=0;i<3;i++){ rotate(global_matrix[i]); } } if(!all_rotated){ update_bond_matrix(True); } rotate_vectors(axis, phi); update_bbox (); deactivate_region(); clear_message_area (); canvas_cb(canvas,NULL,NULL); update_lengths_dialog(False); }
//******************************************************************** void find_anagrams(HWND hwnd) { char msgstr[81] ; // read data out of hwnd:IDC_PHRASE char input_bfr[MAX_PKT_CHARS+1] ; uint input_bfr_len = GetWindowTextA (GetDlgItem(hwnd,IDC_PHRASE) , input_bfr, MAX_PKT_CHARS); if (input_bfr_len > MAX_PKT_CHARS) input_bfr_len = MAX_PKT_CHARS ; input_bfr[MAX_PKT_CHARS] = 0 ; if (vflag) //lint !e506 !e774 syslog("find_anagrams: [%u] [%s]\n", input_bfr_len, input_bfr) ; // scan for separator char excl_idx = 0 ; // reset exclusions list char *hd ; char *tl = strchr(input_bfr, '!'); if (tl != NULL) { *tl++ = 0 ; // NULL-term word list, point to exclusions list while (LOOP_FOREVER) { tl = strip_leading_spaces(tl); if (*tl != 0) { hd = tl ; tl = strchr(hd, ' '); if (tl != NULL) { *tl++ = 0 ; // hd points to one exclusion arg } add_to_excl_list(hd); if (tl == NULL) { break; } } } } status_message("Begin new anagram search") ; // clear_message_area(&this_term); clear_message_area(); if (excl_idx == 0) { status_message("excl: <none>", 1); } else { uint slen = sprintf(msgstr, "excl: "); for (uint idx=0; idx<excl_idx; idx++) { slen += (uint) sprintf(msgstr+slen, "%s ", excl_list[idx]); } status_message(msgstr, 1); } delete_wordlist() ; ZeroMemory((char *) &freq[0], sizeof(freq)) ; nletters = 0 ; for (char *p = input_bfr; *p != 0; p++) { if (*p != ' ') { freq[(uint) (u8) *p]++ ; nletters++; } } if (maxgen == 0) maxgen = nletters; wordlist = buildwordlist (); if (wordlist == NULL) { syslog("Empty dictionary or no suitable words.\n"); return ; } wordlist = sort (wordlist); initfind (wordlist); solutions_found = 0 ; findanags (0, forgelinks (wordlist), nletters); if (solutions_found == 0) { status_message("no anagrams found for input string !") ; } else { // reverse_list_entries() ; // InsertListViewItems(solutions_found); // This triggers drawing of listview myTerminal->reverse_list_entries() ; update_listview(); wsprintf(msgstr, "%u anagrams found", solutions_found) ; status_message(msgstr) ; } }