• PUDN用户
    了解作者
  • Borland C++
    开发工具
  • 30KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 3
    下载次数
  • 2009-11-25 01:07
    上传日期
my very old helper project to make some RTF template from a BCPP resource (.rc) file automatically. it was designed to aid in WinHelp (hlp) creation.
rc2rtf.rar
  • TEST.RTF
    1.9KB
  • TEST1.RTF
    2KB
  • rc2rtf.exe
    40KB
  • test.HPJ
    311B
  • rc2rtf.cpp
    6.8KB
  • ttt.rtf
    29.7KB
  • test.cnt
    59B
  • TTT1.RTF
    30.1KB
内容介绍
#include <string.h> #include <windows.h> #include <windowsx.h> #include <commctrl.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <process.h> FILE *out; #define MAX_SBUF 4096 // finds 1st word in a string s // returns TRUE if it is the same as word w int first_word(char *s, char *w) { while (*s == ' ' || *s =='\t') s++; while (*s == *w) { if (! *s) return 1; // both strings ends at same time s++; w++; } if (*w == 0) // word end { if (*s == ' ' || *s == '\t') return 1; else return 0; } return 0; } int second_word(char *s, char *w) { while (*s == ' ' || *s =='\t') s++; if (*s ==0) return 0; // no 1st word exists while (*s != ' ' && *s !='\t' && *s != 0) s++; // skip 1st word if (*s ==0) return 0; // no 2nd word exists while (*s == ' ' || *s =='\t') s++; while (*s == *w) { if (! *s) return 1; // both strings ends at same time s++; w++; } if (*w == 0) // word end { if (*s == ' ' || *s == '\t') return 1; else return 0; } return 0; } #define MAX_TOPIC 1024 typedef struct { char *topic, *id; } TOPIC; TOPIC *tpc=NULL; int topics=0; void add_topic( char *topic, char *id ) { if (!tpc) { tpc=(TOPIC*)malloc(MAX_TOPIC*sizeof(TOPIC)); if (tpc) { memset(tpc, 0, MAX_TOPIC*sizeof(TOPIC)); } else return; } if (topics<MAX_TOPIC-1) { tpc[topics].topic=strdup(topic); tpc[topics].id=strdup(id); if (tpc[topics].topic && tpc[topics].id) { topics++; } } } int load_rc(char *file) { FILE *in; char *buf, *t, *s, *p; int i, in_menu=0, level=0; char str[128]; if ((buf=(char *)malloc(MAX_SBUF))==NULL) { printf("malloc failed %s %d\n", __FILE__, __LINE__ ); return 0; } if ((in=fopen(file, "rb"))==NULL) { printf("cannot open '%s'\n", file ); free(buf); return 0; } while (fgets(buf, MAX_SBUF-1, in )) { s=buf; i=strlen(buf); while (i>0 && (buf[i-1]=='\n' || buf[i-1]=='\r')) { buf[i-1]=0; i--; } if (!s[0]) continue; if (s[0]==';') continue; if (second_word(s, "MENU") || second_word(s, "menu")) { in_menu=1; continue; } if (!in_menu) continue; if (first_word(s, "{") || first_word(s, "BEGIN") || first_word(s, "begin")) { level++; continue; } if (first_word(s, "}") || first_word(s, "END") || first_word(s, "end")) { if (level) level--; continue; } t = strchr(s, '\"'); // string must start with " if (!t) continue; t++; // skip first " p = str; while (*t) { if (*t == '\\') // escape found { if (*(t+1) == '\\') { *p++ = '\\'; *p++ = '\\'; t += 2; continue; } if (*(t+1) == 'n') { *p++ = '\n'; t += 2; continue; } if (*(t+1) == 't') { *p++ = '\\'; *p++ = 't'; *p++ = 'a'; *p++ = 'b'; *p++ = ' '; t += 2; continue; } if (*(t+1) == '\"') { *p++ = '\"'; t += 2; continue; } t += 1; continue; // skip \ alone } if (*t == '&') if (*(t+1) == '&') { *p++ = '&'; t += 2; continue; } else { t++; continue; } if (*t == '\"') break; // last " *p++ = *t++; } *p = 0; while (*t == '\"' || *t == ' ' || *t == '\t' || *t == ',') t++; if (first_word(s, "POPUP") || first_word(s, "popup")) { fprintf(out, "\n\\pard\\par {\\f2\\fs30 %s}\\par ", str ); continue; } if (first_word(s, "MENUITEM") || first_word(s, "menuitem")) { fprintf(out, "\n\\trowd \\trgaph70\\trleft-70 \\cellx3131\\cellx7667\\pard \\intbl "); fprintf(out, "\n{\\uldb %s}{\\v %s}\\cell \n", str, t ); add_topic( str, t ); fprintf(out, "\n%s\\cell \n", t ); fprintf(out, "\n\\row \n" ); continue; } } fclose(in); free(buf); return 1; } #pragma argsused void main(int argc, char *argv[] ) { int i; if (argc<3) { printf("usage: %s infile.rc outfile.rtf\n", argv[0] ); exit(1); } if ((out=fopen(argv[2], "wb"))==NULL) { printf("cannot create '%s'\n", argv[2] ); exit(1); } fprintf(out, "{\\rtf1\\ansi \\deff0"); fprintf(out, "\n{\\fonttbl"); fprintf(out, "\n{\\f0\\froman Times New Roman;}"); fprintf(out, "\n{\\f1\\froman Symbol;}"); fprintf(out, "\n{\\f2\\fswiss Arial;}"); fprintf(out, "\n}"); fprintf(out, "\n{\\colortbl;"); fprintf(out, "\n\\red0\\green0\\blue0;"); fprintf(out, "\n\\red0\\green0\\blue255;"); fprintf(out, "\n\\red0\\green255\\blue255;"); fprintf(out, "\n\\red0\\green255\\blue0;"); fprintf(out, "\n\\red255\\green0\\blue255;"); fprintf(out, "\n\\red255\\green0\\blue0;"); fprintf(out, "\n\\red255\\green255\\blue0;"); fprintf(out, "\n\\red255\\green255\\blue255;"); fprintf(out, "\n\\red0\\green0\\blue127;"); fprintf(out, "\n\\red0\\green127\\blue127;"); fprintf(out, "\n\\red0\\green127\\blue0;"); fprintf(out, "\n\\red127\\green0\\blue127;"); fprintf(out, "\n\\red127\\green0\\blue0;"); fprintf(out, "\n\\red127\\green127\\blue0;"); fprintf(out, "\n\\red127\\green127\\blue127;"); fprintf(out, "\n\\red192\\green192\\blue192;"); fprintf(out, "\n}"); fprintf(out, "\n{\\info"); fprintf(out, "\n{\\version1}"); fprintf(out, "\n{\\edmins0}"); fprintf(out, "\n{\\nofpages0}"); fprintf(out, "\n{\\nofwords0}"); fprintf(out, "\n{\\nofchars0}"); fprintf(out, "\n{\\vern16433}"); fprintf(out, "\n}"); fprintf(out, "\n\\paperw11906\\paperh16838\\margl1417\\margr1417\\margt1417\\margb567\\gutter0"); fprintf(out, "\n\\deftab708"); fprintf(out, "\n\\widowctrl\\ftnbj\\hyphhotz425 \\sectd"); fprintf(out, "\n\\linex0\\headery709\\footery709\\colsx709\\endnhere\n\n"); load_rc( argv[1] ); fprintf(out, "\n\\pard"); fprintf(out, "\n\\par "); for(i=0; i<topics; i++) { fprintf(out, "\n\\page " ); fprintf(out, "\n{#{\\footnote %s}}", tpc[i].id ); fprintf(out, "{${\\footnote %s}}", tpc[i].topic ); fprintf(out, "{K{\\footnote %s}}", tpc[i].topic ); fprintf(out, "\n{\\f2\\fs30 %s} \\par \\par \\par ", tpc[i].topic ); } fprintf(out, "\n\\par }"); fclose(out); exit(1); }
评论
    相关推荐
    • Trans_Magnetics_template.rar
      Trans_Magneti_template.doc
    • IEEE论文word模板
      This template, modified in MS Word 2003 and saved as “Word 97-2003 & 6.0/95 – RTF” for the PC, provides authors with most of the formatting specifications needed for preparing electronic versions ...
    • Advanced Export.Component 4.1.0.4
      You can export data into MS Access, MS Excel, MS Word (RTF), HTML, XML, PDF, TXT, DBF, CSV and more! There will be no need to waste your time on tiresome data conversion - Advanced Data Export will ...
    • EK RTF report components for Delphi
      How to make it working: Design time: ?create report template in MS Word ?save it in RTF format ?place TEkRTF component on a form or data module ?fill required properties Run time: ?prepare...
    • Backbone Fundamentals 1.2.0.zip
      这是开发 Backbone.js 应用程序的主页,这是一本关于用于构建 JavaScript 应用程序的 Backbone.js 库的开源... 您可以使用 makemake -f Makefile 构建这本书。 这将输出该书的 HTML、ePub、Mobi、PDF 和 RTF 版本。
    • WPTools.v6.29.1.Pro
      * change in unit WPWordConv to handle RTF as DOC files if they do not start with "{\rtf" * updated border dialog TWPParagraphBorderDlgEx * updated border drawing code - now supports dotted lines with ...
    • extmail 1.1
      optimize the design and archtecture, make it scalable well and run faster than common php/perl webmail system. Feature: ======== o Fully support Maildir++, reference URL: ...
    • myBase Desktop 6.3.3 12/1/2013 绿色 完美破解版
      Added: The viewer program is now shiped within the desktop package, so you don't need to manually download and copy it to the setup folder for creating the standalone .exe databases, and the 'Make exe...
    • qpopper2.53.tar.Z
      pop3 server