File: wvSummary.c

package info (click to toggle)
wv 1.0.2-0.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,428 kB
  • ctags: 6,733
  • sloc: ansic: 59,221; sh: 9,998; xml: 1,677; makefile: 36
file content (150 lines) | stat: -rw-r--r-- 3,394 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "wv.h"

#include "glib.h"
#include "ms-ole.h"
#include "ms-ole-summary.h"

/*
 * This is a simple example that take an ole file and prints some
 * information from the summaryinformation stream
 */

int
main (int argc, char *argv[])
{
    char *str = NULL;
    gboolean ret = FALSE;
    short s = 0;
    long l = 0;

    MsOle *ole = NULL;
    MsOleSummary *summary = NULL;

    if (argc < 2)
      {
	  fprintf (stderr, "Usage: wvSummary oledocument\n");
	  return (1);
      }

    ms_ole_open (&ole, argv[1]);
    if (!ole)
      {
	  fprintf (stderr, "sorry problem with getting ole streams from %s\n",
		   argv[1]);
	  return 1;
      }

    summary = ms_ole_summary_open (ole);
    if (!summary)
      {
	  fprintf (stderr, "Could not open summary stream\n");
	  return 1;
      }

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_TITLE, &ret);

    if (ret && str)
	printf ("The title is %s\n", str);
    else
	printf ("no title found\n");

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_SUBJECT, &ret);

    if (ret && str)
	printf ("The subject is %s\n", str);
    else
	printf ("no subject found\n");

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_AUTHOR, &ret);

    if (ret && str)
	printf ("The author is %s\n", str);
    else
	printf ("no author found\n");

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_KEYWORDS, &ret);

    if (ret && str)
	printf ("The keywords are %s\n", str);
    else
	printf ("no keywords found\n");

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_COMMENTS, &ret);

    if (ret && str)
	printf ("The comments are %s\n", str);
    else
	printf ("no comments found\n");

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_TEMPLATE, &ret);

    if (ret && str)
	printf ("The template was %s\n", str);
    else
	printf ("no template found\n");

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_LASTAUTHOR, &ret);

    if (ret && str)
	printf ("The last author was %s\n", str);
    else
	printf ("no last author found\n");

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_REVNUMBER, &ret);

    if (ret && str)
	printf ("The rev # was %s\n", str);
    else
	printf ("no rev no found\n");

    str = ms_ole_summary_get_string (summary, MS_OLE_SUMMARY_APPNAME, &ret);

    if (ret && str)
	printf ("The app name was %s\n", str);
    else
	printf ("no app name found\n");

    l = ms_ole_summary_get_long (summary, MS_OLE_SUMMARY_PAGECOUNT, &ret);

    if (ret)
	printf ("PageCount is %d\n", l);
    else
	printf ("no pagecount\n");

    l = ms_ole_summary_get_long (summary, MS_OLE_SUMMARY_WORDCOUNT, &ret);

    if (ret)
	printf ("WordCount is %d\n", l);
    else
	printf ("no wordcount\n");

    l = ms_ole_summary_get_long (summary, MS_OLE_SUMMARY_CHARCOUNT, &ret);

    if (ret)
	printf ("CharCount is %d\n", l);
    else
	printf ("no charcount\n");

    l = ms_ole_summary_get_long (summary, MS_OLE_SUMMARY_SECURITY, &ret);

    if (ret)
	printf ("Security is %d\n", l);
    else
	printf ("no security\n");

    s = ms_ole_summary_get_short (summary, MS_OLE_SUMMARY_CODEPAGE, &ret);
    if (ret)
	printf ("Codepage is 0x%x (%d)\n", s, s);
    else
	printf ("no codepage\n");

    ms_ole_summary_close (summary);
    ms_ole_destroy (&ole);

    return 0;
}