annotate archive/patch1 @ 402:37cd2aea5d4a

update x_python.m4 to detect python 3.9
author Carl Byington <carl@five-ten-sg.com>
date Thu, 26 Mar 2020 09:22:43 -0700
parents de3753c3160a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
57
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 diff -Naur ../orig/libpst-0.5.1/define.h libpst64-060926/define.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 --- ../orig/libpst-0.5.1/define.h 2004-11-17 07:48:03.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 +++ libpst64-060926/define.h 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 @@ -5,7 +5,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 * dave.s@earthcorp.com
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 -//#define DEBUG_ALL
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 +#define DEBUG_ALL
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 #ifndef DEFINEH_H
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 #define DEFINEH_H
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 diff -Naur ../orig/libpst-0.5.1/generic.c libpst64-060926/generic.c
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 --- ../orig/libpst-0.5.1/generic.c 1969-12-31 17:00:00.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 +++ libpst64-060926/generic.c 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 @@ -0,0 +1,110 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 +// {{{ includes
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 +#include <ctype.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 +#include <errno.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 +#include <malloc.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 +#include <signal.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 +#include <stdarg.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 +#include <stdio.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 +#include <stdlib.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 +#include <string.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 +#include "generic.h"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 +#ifdef WITH_DMALLOC
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 +#include <dmalloc.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 +#endif
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 +// {{{ Macros: ASSERT(), DIE(), F_MALLOC()
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 +void pDIE( char *fmt, ... ) // {{{ Cough...cough
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 + va_list ap;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 + va_start( ap, fmt );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40 + //fprintf( stderr, "Fatal error (will segfault): ");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41 + vfprintf( stderr, fmt, ap );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
42 + fprintf( stderr, "\n" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
43 + va_end(ap);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
44 + raise( SIGSEGV );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47 +void pWARN( char *fmt, ... ) // {{{ Cough...cough
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
48 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
49 + va_list ap;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
50 + va_start( ap, fmt );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51 + fprintf( stderr, "WARNING: ");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
52 + vfprintf( stderr, fmt, ap );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
53 + fprintf( stderr, "\n" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
54 + va_end(ap);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
55 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
56 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
57 +void *F_MALLOC( size_t size ) // {{{ malloc() but dumps core when it fails
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
58 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
59 + void *result;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
60 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
61 + result = malloc( size );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
62 + ASSERT( NULL != result, "malloc() failure." );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
64 + return result;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
65 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
66 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
67 +void *F_REALLOC( void *p, size_t size ) // {{{ realloc() but dumps core when it fails
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
68 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
69 + void *result;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
70 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
71 + //if( NULL != p ) hexdump((char*)p - 128, 0, 128, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
72 + if(!p) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
73 + ASSERT( NULL != ( result = malloc( size ) ), "malloc() failure." );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
74 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
75 + else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
76 + ASSERT( NULL != ( result = realloc( p, size ) ), "realloc() failure." );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
78 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
79 + //hexdump((char*)result - 128, 0, 128, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
80 + fflush(stderr);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
81 + return result;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
82 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
83 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
84 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
85 +// {{{ Program logging/debug output
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
86 +int DEBUG_LEVEL = DB_INFO;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
87 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
88 +void db_default( char *file, int line, int level, char *fmt, ... ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
89 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
90 + va_list ap;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
91 + if( level <= DEBUG_LEVEL ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
92 + switch( level ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
93 + case DB_CRASH:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
94 + fprintf(stderr, "CRASH");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
95 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
96 + case DB_ERR:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
97 + fprintf(stderr, "ERROR");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
98 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
99 + case DB_WARN:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
100 + fprintf(stderr, "WARNING");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
101 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
102 + case DB_INFO:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
103 + case DB_VERB:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
104 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
105 + default:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
106 + fprintf(stderr, "DEBUG(%d)", level );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
107 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
108 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
109 + if( level <= DB_WARN )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
110 + fprintf(stderr, " (%s:%d)", file, line );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
111 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
112 + if( DB_INFO != level && DB_VERB != level )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
113 + fprintf(stderr, ": ");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
114 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
115 + va_start( ap, fmt );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
116 + vfprintf(stderr, fmt, ap );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
117 + fprintf(stderr, "\n" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
118 + va_end( ap );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
119 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
120 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
121 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
122 +void (*dbfunc)(char *file, int line, int level, char *fmt, ...) = &db_default;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
123 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
124 +//#define DEBUG(x) { x; }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
125 +//#define DEBUG(x) ;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
126 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
127 diff -Naur ../orig/libpst-0.5.1/generic.h libpst64-060926/generic.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
128 --- ../orig/libpst-0.5.1/generic.h 1969-12-31 17:00:00.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
129 +++ libpst64-060926/generic.h 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
130 @@ -0,0 +1,48 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
131 +/* {{{ Generic.h - thigns every program does:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
132 + *
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
133 + * - user output (log, debug, etc)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
134 + * - crash and burn
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
135 + * - allocate memory (or explode)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
136 + * }}} */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
137 +#ifndef GENERIC_H
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
138 +#define GENERIC_H
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
139 +#include <stdlib.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
140 +#include <stdio.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
141 +#include <stdarg.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
142 +/***************************************************/
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
143 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
144 +#define LOAD_DEBUG 1
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
145 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
146 +#define DIE(...) { fprintf(stderr, "Fatal Error at %s,%d: ", __FILE__, __LINE__); pDIE(__VA_ARGS__); }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
147 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
148 +//#define WARN(...) { fprintf(stderr, "WARN: %s,%d: ", __FILE__, __LINE__); pWARN(__VA_ARGS__); }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
149 +void pDIE( char *fmt, ... );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
150 +//void pWARN( char *fmt, ... );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
151 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
152 +#define WARN(...) DB( DB_WARN, __VA_ARGS__ )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
153 +#define ASSERT(x,...) { if( !(x) ) DIE( __VA_ARGS__ ); }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
154 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
155 +void *F_MALLOC( size_t size );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
156 +void *F_REALLOC( void *p, size_t size );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
157 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
158 +#define DO_DEBUG 0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
159 +#define DEBUG(x) if( DO_DEBUG ) { x; }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
160 +#define STUPID_CR "\r\n"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
161 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
162 +#define DB_CRASH 0 // crashing
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
163 +#define DB_ERR 1 // error
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
164 +#define DB_WARN 2 // warning
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
165 +#define DB_INFO 3 // normal, but significant, condition
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
166 +#define DB_VERB 4 // verbose information
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
167 +#define DB_0 5 // debug-level message
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
168 +#define DB_1 6 // debug-level message
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
169 +#define DB_2 7 // debug-level message
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
170 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
171 +extern int DEBUG_LEVEL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
172 +extern void (*dbfunc)(char *file, int line, int level, char *fmt, ...);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
173 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
174 +#define DB(...) { dbfunc( __FILE__, __LINE__, __VA_ARGS__ ); }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
175 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
176 +int set_db_function( void (*func)( char *file, int line, int level, char *fmt, ...) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
177 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
178 +#endif
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
179 diff -Naur ../orig/libpst-0.5.1/libpst.c libpst64-060926/libpst.c
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
180 --- ../orig/libpst-0.5.1/libpst.c 2004-11-17 07:48:04.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
181 +++ libpst64-060926/libpst.c 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
182 @@ -4,6 +4,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
183 * Written by David Smith
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
184 * dave.s@earthcorp.com
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
185 */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
186 +//{{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
187 #include <stdio.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
188 #include <stdlib.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
189 #include <time.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
190 @@ -12,11 +13,15 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
191 #include <limits.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
192 #include <wchar.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
193
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
194 +#include <signal.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
195 #include <errno.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
196 #include <sys/stat.h> //mkdir
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
197 #include <fcntl.h> // for Win32 definition of _O_BINARY
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
198 #include "define.h"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
199 #include "libstrfunc.h"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
200 +#include "vbuf.h"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
201 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
202 +#define ASSERT(x) { if(!(x)) raise( SIGSEGV ); }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
203
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
204 #ifdef _MSC_VER
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
205 # include <windows.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
206 @@ -45,30 +50,54 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
207 //#define LE32_CPU(x) {}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
208 //#define LE16_CPU(x) {}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
209 //#endif // _MSC_VER
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
210 -
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
211 -#define FILE_SIZE_POINTER 0xA8
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
212 -#define INDEX_POINTER 0xC4
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
213 -#define SECOND_POINTER 0xBC
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
214 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
215 +#define FILE_SIZE_POINTER32 0xA8
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
216 +#define INDEX_POINTER32 0xC4
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
217 +#define INDEX_COUNT32 0xC0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
218 +#define SECOND_POINTER32 0xBC
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
219 +#define SECOND_COUNT32 0xB8
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
220 #define INDEX_DEPTH 0x4C
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
221 #define SECOND_DEPTH 0x5C
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
222 // the encryption setting could be at 0x1CC. Will require field testing
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
223 -#define ENC_OFFSET 0x1CD
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
224 +#define ENC_OFFSET32 0x1CD
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
225 // says the type of index we have
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
226 -#define INDEX_TYPE_OFFSET 0x0A
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
227 +#define INDEX_TYPE_OFFSET32 0x0A
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
228 +#define INDEX_TYPE32 0x0E
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
229 +#define INDEX_TYPE64 0x17 //I think this is wrong
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
230
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
231 // for the 64bit 2003 outlook PST we need new file offsets
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
232 // perhaps someone can figure out the header format for the pst files...
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
233 -#define FILE_SIZE_POINTER_64 0xB8
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
234 -#define INDEX_POINTER_64 0xF0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
235 -#define SECOND_POINTER_64 0xE0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
236 +#define FILE_SIZE_POINTER64 0xB8
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
237 +#define INDEX_POINTER64 0xF0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
238 +#define INDEX_COUNT64 0xE8
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
239 +#define SECOND_POINTER64 0xE0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
240 +#define SECOND_COUNT64 0xD8
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
241 +#define INDEX_TYPE_OFFSET64 0x0A
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
242 +#define ENC_OFFSET64 0x201
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
243 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
244 +#define FILE_SIZE_POINTER ((do_read64)?FILE_SIZE_POINTER64:FILE_SIZE_POINTER32)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
245 +#define INDEX_POINTER ((do_read64)?INDEX_POINTER64:INDEX_POINTER32)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
246 +#define INDEX_TYPE_OFFSET ((do_read64)?INDEX_TYPE_OFFSET64:INDEX_TYPE_OFFSET32)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
247 +#define INDEX_TYPE ((do_read64)?INDEX_TYPE64:INDEX_TYPE32)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
248 +#define SECOND_POINTER ((do_read64)?SECOND_POINTER64:SECOND_POINTER32)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
249 +#define SECOND_COUNT ((do_read64)?SECOND_COUNT64:SECOND_COUNT32)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
250 +#define ENC_OFFSET ((do_read64)?ENC_OFFSET64:ENC_OFFSET32)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
251 +#define INDEX_COUNT ((do_read64)?INDEX_COUNT64:INDEX_COUNT32)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
252
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
253 #define PST_SIGNATURE 0x4E444221
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
254
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
255 -struct _pst_table_ptr_struct{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
256 +int do_read64 = 0; //set this to 1 in order to try and read 64-bit pst files (Outlook 2003)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
257 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
258 +struct _pst_table_ptr_struct32{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
259 int32_t start;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
260 int32_t u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
261 int32_t offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
262 };
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
263 +struct _pst_table_ptr_structn{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
264 + int64_t start;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
265 + int64_t u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
266 + int64_t offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
267 +};
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
268
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
269 typedef struct _pst_block_header {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
270 int16_t type;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
271 @@ -119,6 +148,26 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
272 0xd4, 0xe1, 0x11, 0xd0, 0x08, 0x8b, 0x2a, 0xf2,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
273 0xed, 0x9a, 0x64, 0x3f, 0xc1, 0x6c, 0xf9, 0xec}; /*0xff*/
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
274
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
275 +void set_read64() { do_read64 = 1; }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
276 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
277 +void dump_desc( off_t off, int depth, int i, pst_descn *desc_rec ) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
278 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
279 + //desc_rec->d_id = 0x0102030405060708;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
280 + DEBUG_INDEX(("%08x [%i] Item(%#x) = [d_id = %#llx, desc_id = %#llx, "
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
281 + "list_id = %#llx, parent_id = %#x, u1 = %#x] %#x %p %p\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
282 + off,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
283 + depth, i, desc_rec->d_id,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
284 + desc_rec->desc_id, desc_rec->list_id, desc_rec->parent_id, desc_rec->u1));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
285 + DEBUG_HEXDUMPC( (char*)desc_rec, sizeof( pst_descn ), 0x10 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
286 + DEBUG_INDEX(("WTF? %d %x %x %x %x %x\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
287 + sizeof( u_int32_t ),
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
288 + (int)(&desc_rec->d_id) - (int)desc_rec,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
289 + (int)(&desc_rec->desc_id) - (int)desc_rec,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
290 + (int)(&desc_rec->list_id) - (int)desc_rec,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
291 + (int)(&desc_rec->parent_id) - (int)desc_rec,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
292 + (int)(&desc_rec->u1) - (int)desc_rec ));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
293 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
294 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
295 int32_t pst_open(pst_file *pf, char *name, char *mode) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
296 u_int32_t sig;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
297 // unsigned char ind_type;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
298 @@ -158,9 +207,10 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
299 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
300 return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
301 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
302 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
303 _pst_getAtPos(pf->fp, INDEX_TYPE_OFFSET, &(pf->ind_type), sizeof(unsigned char));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
304 DEBUG_INFO(("index_type = %i\n", pf->ind_type));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
305 - if (pf->ind_type != 0x0E) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
306 + if ( pf->ind_type != INDEX_TYPE) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
307 WARN(("unknown index structure. Could this be a new Outlook 2003 PST file?\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
308 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
309 return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
310 @@ -170,23 +220,18 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
311 DEBUG_INFO(("encrypt = %i\n", pf->encryption));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
312 // pf->encryption = encrypt;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
313
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
314 - _pst_getAtPos(pf->fp, SECOND_POINTER-4, &(pf->index2_count), sizeof(pf->index2_count));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
315 - _pst_getAtPos(pf->fp, SECOND_POINTER, &(pf->index2), sizeof(pf->index2));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
316 - LE32_CPU(pf->index2_count);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
317 - LE32_CPU(pf->index2);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
318 + pf->index2_count = _pst_getIntAtPos(pf->fp, SECOND_COUNT);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
319 + pf->index2 = _pst_getIntAtPos(pf->fp, SECOND_POINTER );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
320
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
321 - _pst_getAtPos(pf->fp, FILE_SIZE_POINTER, &(pf->size), sizeof(pf->size));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
322 - LE32_CPU(pf->size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
323 + pf->size = _pst_getIntAtPos( pf->fp, FILE_SIZE_POINTER );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
324
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
325 // very tempting to leave these values set way too high and let the exploration of the tables set them...
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
326 pf->index1_depth = pf->index2_depth = 255;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
327
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
328 DEBUG_INFO(("Pointer2 is %#X, count %i[%#x], depth %#x\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
329 pf->index2, pf->index2_count, pf->index2_count, pf->index2_depth));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
330 - _pst_getAtPos(pf->fp, INDEX_POINTER-4, &(pf->index1_count), sizeof(pf->index1_count));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
331 - _pst_getAtPos(pf->fp, INDEX_POINTER, &(pf->index1), sizeof(pf->index1));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
332 - LE32_CPU(pf->index1_count);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
333 - LE32_CPU(pf->index1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
334 + pf->index1_count = _pst_getIntAtPos(pf->fp, INDEX_COUNT);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
335 + pf->index1 = _pst_getIntAtPos(pf->fp, INDEX_POINTER);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
336
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
337 DEBUG_INFO(("Pointer1 is %#X, count %i[%#x], depth %#x\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
338 pf->index1, pf->index1_count, pf->index1_count, pf->index1_depth));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
339 @@ -495,18 +540,110 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
340 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
341
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
342 #define BLOCK_SIZE 516
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
343 +int _pst_decode_desc( pst_descn *desc, char *buf ) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
344 + int r;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
345 + if( do_read64 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
346 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
347 + DEBUG_INDEX(("Decoding desc64 "));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
348 + DEBUG_HEXDUMPC(buf, sizeof( pst_descn ), 0x10);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
349 + memcpy(desc, buf, sizeof( pst_descn ));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
350 + LE64_CPU(desc->d_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
351 + LE64_CPU(desc->desc_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
352 + LE64_CPU(desc->list_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
353 + LE32_CPU(desc->parent_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
354 + LE32_CPU(desc->u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
355 + r = sizeof( pst_descn );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
356 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
357 + else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
358 + pst_desc32 d32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
359 + DEBUG_INDEX(("Decoding desc32 "));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
360 + DEBUG_HEXDUMPC(buf, sizeof( d32 ), 0x10);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
361 + memcpy(&d32, buf, sizeof(d32));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
362 + LE32_CPU(d32.d_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
363 + LE32_CPU(d32.desc_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
364 + LE32_CPU(d32.list_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
365 + LE32_CPU(d32.parent_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
366 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
367 + desc->d_id = d32.d_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
368 + desc->desc_id = d32.desc_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
369 + desc->list_id = d32.list_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
370 + desc->parent_id = d32.parent_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
371 + desc->u1 = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
372 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
373 + r = sizeof( d32 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
374 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
375 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
376 + return r;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
377 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
378 +int _pst_decode_table( struct _pst_table_ptr_structn *table, char *buf ) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
379 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
380 + if( do_read64 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
381 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
382 + DEBUG_INDEX(("Decoding table64"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
383 + DEBUG_HEXDUMPC(buf, sizeof( struct _pst_table_ptr_structn ), 0x10);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
384 + memcpy(table, buf, sizeof( struct _pst_table_ptr_structn ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
385 + LE64_CPU(table->start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
386 + LE64_CPU(table->u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
387 + LE64_CPU(table->offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
388 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
389 + return sizeof( struct _pst_table_ptr_structn );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
390 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
391 + else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
392 + struct _pst_table_ptr_struct32 t32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
393 + memcpy(&t32, buf, sizeof(t32));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
394 + LE32_CPU(t32.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
395 + LE32_CPU(t32.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
396 + LE32_CPU(t32.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
397 + table->start = t32.start;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
398 + table->u1 = t32.u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
399 + table->offset = t32.offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
400 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
401 + return sizeof( struct _pst_table_ptr_struct32 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
402 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
403 + return 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
404 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
405 +int _pst_decode_index( pst_index *index, char *buf ) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
406 + if( do_read64 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
407 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
408 + DEBUG_INDEX(("Decoding index64"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
409 + DEBUG_HEXDUMPC(buf, sizeof( pst_index ), 0x10);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
410 + memcpy(index, buf, sizeof(pst_index));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
411 + LE64_CPU(index->id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
412 + LE64_CPU(index->offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
413 + LE16_CPU(index->size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
414 + LE16_CPU(index->u0);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
415 + LE16_CPU(index->u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
416 + return sizeof( pst_index );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
417 + } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
418 + pst_index32 index32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
419 + memcpy(&index32, buf, sizeof(pst_index32));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
420 + LE32_CPU(index32->id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
421 + LE32_CPU(index32->offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
422 + LE16_CPU(index32->size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
423 + LE16_CPU(index32->u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
424 + index->id = index32.id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
425 + index->offset = index32.offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
426 + index->size = index32.size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
427 + index->u1 = index32.u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
428 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
429 + return sizeof( pst_index32 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
430 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
431
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
432 -int32_t _pst_build_id_ptr(pst_file *pf, int32_t offset, int32_t depth, int32_t start_val, int32_t end_val) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
433 - struct _pst_table_ptr_struct table, table2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
434 + return 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
435 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
436 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
437 +int32_t _pst_build_id_ptr(pst_file *pf, off_t offset, int32_t depth, int32_t start_val, int32_t end_val) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
438 + struct _pst_table_ptr_structn table, table2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
439 pst_index_ll *i_ptr=NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
440 pst_index index;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
441 // int fpos = ftell(pf->fp);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
442 int32_t x, ret;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
443 int32_t old = start_val;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
444 + off_t roff;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
445 char *buf = NULL, *bptr = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
446
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
447 DEBUG_ENT("_pst_build_id_ptr");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
448 - if (pf->index1_depth - depth == 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
449 + if (pf->index1_depth - depth == 0) { // {{{ Leaf table, add indexes to linked list
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
450 // we must be at a leaf table. These are index items
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
451 DEBUG_INDEX(("Reading Items\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
452 // fseek(pf->fp, offset, SEEK_SET);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
453 @@ -519,15 +656,14 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
454 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
455 bptr = buf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
456 // DEBUG_HEXDUMPC(buf, BLOCK_SIZE, 12);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
457 - memcpy(&index, bptr, sizeof(index));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
458 - LE32_CPU(index.id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
459 - LE32_CPU(index.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
460 - LE16_CPU(index.size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
461 - LE16_CPU(index.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
462 - bptr += sizeof(index);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
463 + roff = offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
464 + bptr += _pst_decode_index( &index, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
465
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
466 - while(index.id != 0 && x < 42 && bptr < buf+BLOCK_SIZE && index.id < end_val) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
467 - DEBUG_INDEX(("[%i]%i Item [id = %#x, offset = %#x, u1 = %#x, size = %i(%#x)]\n", depth, ++x, index.id, index.offset, index.u1, index.size, index.size));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
468 + while(index.id != 0 && x < 42 && bptr < buf+BLOCK_SIZE && index.id < end_val) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
469 + DEBUG_INDEX(("%08x [%i]%i Item [ id = %#llx, offset = %#llx, u1 = %#x, size = %i(%#x)] %p %p\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
470 + roff,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
471 + depth, ++x, index.id, index.offset, index.u1,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
472 + index.size, index.size, buf, bptr ));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
473 if (index.id & 0x02) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
474 DEBUG_INDEX(("two-bit set!!\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
475 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
476 @@ -543,7 +679,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
477 pf->id_depth_ok = 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
478 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
479 // u1 could be a flag. if bit 0x2 is not set, it might be deleted
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
480 - // if (index.u1 & 0x2 || index.u1 & 0x4) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
481 + // if (index.u1 & 0x2 || index.u1 & 0x4)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
482 // ignore the above condition. it doesn't appear to hold
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
483 if (old > index.id) { // then we have back-slid on the new values
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
484 DEBUG_INDEX(("Back slider detected - Old value [%#x] greater than new [%#x]. Progressing to next table\n", old, index.id));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
485 @@ -551,6 +687,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
486 return 2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
487 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
488 old = index.id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
489 + // {{{ Add index to linked list
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
490 i_ptr = (pst_index_ll*) xmalloc(sizeof(pst_index_ll));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
491 i_ptr->id = index.id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
492 i_ptr->offset = index.offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
493 @@ -562,15 +699,12 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
494 if (pf->i_head == NULL)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
495 pf->i_head = i_ptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
496 pf->i_tail = i_ptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
497 - memcpy(&index, bptr, sizeof(index));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
498 - LE32_CPU(index.id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
499 - LE32_CPU(index.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
500 - LE16_CPU(index.size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
501 - LE16_CPU(index.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
502 - bptr += sizeof(index);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
503 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
504 - // fseek(pf->fp, fpos, SEEK_SET);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
505 - if (x < 42) { // we have stopped prematurley. Why?
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
506 + // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
507 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
508 + roff = offset + (bptr - buf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
509 + bptr +=_pst_decode_index( &index, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
510 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
511 + if (x < 42) { // {{{ we have stopped prematurley. Why?
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
512 if (index.id == 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
513 DEBUG_INDEX(("Found index.id == 0\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
514 } else if (!(bptr < buf+BLOCK_SIZE)) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
515 @@ -581,12 +715,12 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
516 } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
517 DEBUG_INDEX(("Stopped for unknown reason\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
518 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
519 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
520 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
521 if (buf) free (buf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
522 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
523 return 2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
524 - } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
525 - // this is then probably a table of offsets to more tables.
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
526 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
527 + else { // {{{ probably a table of offsets to tables, recurse
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
528 DEBUG_INDEX(("Reading Table Items\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
529
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
530 x = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
531 @@ -600,15 +734,10 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
532 bptr = buf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
533 // DEBUG_HEXDUMPC(buf, BLOCK_SIZE, 12);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
534
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
535 - memcpy(&table, bptr, sizeof(table));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
536 - LE32_CPU(table.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
537 - LE32_CPU(table.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
538 - LE32_CPU(table.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
539 - bptr += sizeof(table);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
540 - memcpy(&table2, bptr, sizeof(table));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
541 - LE32_CPU(table2.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
542 - LE32_CPU(table2.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
543 - LE32_CPU(table2.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
544 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
545 + roff = offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
546 + bptr += _pst_decode_table( &table, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
547 + _pst_decode_table( &table2, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
548
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
549 if (start_val != -1 && table.start != start_val) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
550 DEBUG_WARN(("This table isn't right. Must be corruption, or I got it wrong!\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
551 @@ -619,7 +748,9 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
552 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
553
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
554 while (table.start != 0 && bptr < buf+BLOCK_SIZE && table.start < end_val) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
555 - DEBUG_INDEX(("[%i] %i Table [start id = %#x, u1 = %#x, offset = %#x]\n", depth, ++x, table.start, table.u1, table.offset));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
556 + DEBUG_INDEX(("%08x [%i] %i Table [start id = %#x, u1 = %#x, offset = %#x]\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
557 + roff,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
558 + depth, ++x, table.start, table.u1, table.offset));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
559
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
560 if (table2.start <= table.start)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
561 // this should only be the case when we come to the end of the table
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
562 @@ -643,15 +774,9 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
563 } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
564 DEBUG_INDEX(("child has returned without a known error [%i]\n", ret));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
565 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
566 - memcpy(&table, bptr, sizeof(table));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
567 - LE32_CPU(table.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
568 - LE32_CPU(table.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
569 - LE32_CPU(table.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
570 - bptr += sizeof(table);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
571 - memcpy(&table2, bptr, sizeof(table));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
572 - LE32_CPU(table2.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
573 - LE32_CPU(table2.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
574 - LE32_CPU(table2.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
575 + bptr += _pst_decode_table( &table, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
576 + roff = offset + ( bptr - buf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
577 + _pst_decode_table( &table2, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
578 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
579
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
580 if (table.start == 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
581 @@ -669,21 +794,23 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
582 DEBUG_INDEX(("End of table of pointers\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
583 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
584 return 3;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
585 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
586 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
587 DEBUG_WARN(("ERROR ** Shouldn't be here!\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
588
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
589 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
590 return 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
591 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
592
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
593 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
594 #define DESC_BLOCK_SIZE 520
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
595 -int32_t _pst_build_desc_ptr (pst_file *pf, int32_t offset, int32_t depth, int32_t *high_id, int32_t start_id,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
596 +int32_t _pst_build_desc_ptr (pst_file *pf, off_t offset, int32_t depth, int32_t *high_id, int32_t start_id,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
597 int32_t end_val) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
598 - struct _pst_table_ptr_struct table, table2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
599 - pst_desc desc_rec;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
600 + struct _pst_table_ptr_structn table, table2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
601 + pst_descn desc_rec;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
602 pst_desc_ll *d_ptr=NULL, *d_par=NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
603 int32_t i = 0, y, prev_id=-1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
604 char *buf = NULL, *bptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
605 + off_t roff;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
606
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
607 struct _pst_d_ptr_ll {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
608 pst_desc_ll * ptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
609 @@ -696,8 +823,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
610
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
611 int32_t d_ptr_count = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
612 DEBUG_ENT("_pst_build_desc_ptr");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
613 - if (pf->index2_depth-depth == 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
614 - // leaf node
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
615 + if (pf->index2_depth-depth == 0) { // {{{ leaf node, index it
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
616 if (_pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, &buf, 0, 0) < DESC_BLOCK_SIZE) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
617 DEBUG_WARN(("I didn't get all the index that I wanted. _pst_read_block_size returned less than requested\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
618 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
619 @@ -707,22 +833,17 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
620
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
621 //DEBUG_HEXDUMPC(buf, DESC_BLOCK_SIZE, 16);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
622
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
623 - memcpy(&desc_rec, bptr, sizeof(desc_rec));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
624 - LE32_CPU(desc_rec.d_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
625 - LE32_CPU(desc_rec.desc_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
626 - LE32_CPU(desc_rec.list_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
627 - LE32_CPU(desc_rec.parent_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
628 - bptr+= sizeof(desc_rec);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
629 + roff = offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
630 + bptr += _pst_decode_desc( &desc_rec, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
631
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
632 if (end_val <= start_id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
633 DEBUG_WARN(("The end value is BEFORE the start value. This function will quit. Soz. [start:%#x, end:%#x]\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
634 start_id, end_val));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
635 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
636
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
637 - while (i < 0x1F && desc_rec.d_id < end_val && (prev_id == -1 || desc_rec.d_id > prev_id)) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
638 - DEBUG_INDEX(("[%i] Item(%#x) = [d_id = %#x, desc_id = %#x, "
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
639 - "list_id = %#x, parent_id = %#x]\n", depth, i, desc_rec.d_id,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
640 - desc_rec.desc_id, desc_rec.list_id, desc_rec.parent_id));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
641 + while (i < 0x1F && desc_rec.d_id < end_val && (prev_id == -1 || desc_rec.d_id > prev_id)) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
642 + DEBUG_INDEX(("Bliss %d: %llx %p %p %p ", i, offset, buf, bptr, bptr ));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
643 + dump_desc( roff, depth, i, &desc_rec );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
644 i++;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
645
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
646 if (start_id != -1 && desc_rec.d_id != start_id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
647 @@ -737,20 +858,16 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
648 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
649
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
650 if (desc_rec.d_id == 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
651 - memcpy(&desc_rec, bptr, sizeof(desc_rec));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
652 - LE32_CPU(desc_rec.d_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
653 - LE32_CPU(desc_rec.desc_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
654 - LE32_CPU(desc_rec.list_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
655 - LE32_CPU(desc_rec.parent_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
656 - bptr+=sizeof(desc_rec);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
657 - continue;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
658 + roff = offset + ( bptr - buf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
659 + bptr+=_pst_decode_desc( &desc_rec, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
660 + continue;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
661 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
662 prev_id = desc_rec.d_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
663
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
664 // When duplicates found, just update the info.... perhaps this is correct functionality
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
665 DEBUG_INDEX(("Searching for existing record\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
666
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
667 - if (desc_rec.d_id <= *high_id && (d_ptr = _pst_getDptr(pf, desc_rec.d_id)) != NULL) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
668 + if (desc_rec.d_id <= *high_id && (d_ptr = _pst_getDptr(pf, desc_rec.d_id)) != NULL) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
669 DEBUG_INDEX(("Updating Existing Values\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
670 d_ptr->list_index = _pst_getID(pf, desc_rec.list_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
671 d_ptr->desc = _pst_getID(pf, desc_rec.desc_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
672 @@ -802,7 +919,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
673 d_ptr_ptr = d_ptr_ptr->next;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
674 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
675
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
676 - if (d_ptr_ptr == NULL && (d_par = _pst_getDptr(pf, desc_rec.parent_id)) == NULL) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
677 + if (d_ptr_ptr == NULL && (d_par = _pst_getDptr(pf, desc_rec.parent_id)) == NULL) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
678 // check in the lost/found list
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
679 lf_ptr = lf_head;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
680 while (lf_ptr != NULL && lf_ptr->ptr->id != desc_rec.parent_id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
681 @@ -820,7 +937,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
682 d_par = lf_ptr->ptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
683 DEBUG_INDEX(("Found parent (%#x) in Lost and Found\n", d_par->id));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
684 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
685 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
686 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
687
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
688 if (d_ptr_ptr != NULL || d_par != NULL) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
689 if (d_ptr_ptr != NULL)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
690 @@ -857,7 +974,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
691 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
692 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
693
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
694 - } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
695 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
696 + else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
697 if (*high_id < desc_rec.d_id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
698 DEBUG_INDEX(("Updating New High\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
699 *high_id = desc_rec.d_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
700 @@ -866,8 +984,10 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
701 d_ptr = (pst_desc_ll*) xmalloc(sizeof(pst_desc_ll));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
702 // DEBUG_INDEX(("Item pointer is %p\n", d_ptr));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
703 d_ptr->id = desc_rec.d_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
704 + DEBUG_INDEX(("Weird %llx moo", desc_rec.list_id ));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
705 d_ptr->list_index = _pst_getID(pf, desc_rec.list_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
706 d_ptr->desc = _pst_getID(pf, desc_rec.desc_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
707 + //ASSERT( d_ptr->desc != NULL );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
708 d_ptr->prev = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
709 d_ptr->next = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
710 d_ptr->parent = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
711 @@ -876,7 +996,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
712 d_ptr->no_child = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
713
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
714 DEBUG_INDEX(("Searching for parent\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
715 - if (desc_rec.parent_id == 0 || desc_rec.parent_id == desc_rec.d_id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
716 + if (desc_rec.parent_id == 0 || desc_rec.parent_id == desc_rec.d_id) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
717 if (desc_rec.parent_id == 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
718 DEBUG_INDEX(("No Parent\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
719 } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
720 @@ -888,7 +1008,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
721 pf->d_head = d_ptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
722 d_ptr->prev = pf->d_tail;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
723 pf->d_tail = d_ptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
724 - } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
725 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
726 + else { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
727 d_ptr_ptr = d_ptr_head;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
728 while (d_ptr_ptr != NULL && d_ptr_ptr->ptr->id != desc_rec.parent_id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
729 d_ptr_ptr = d_ptr_ptr->next;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
730 @@ -947,7 +1068,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
731 d_ptr->prev = d_par->child_tail;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
732 d_par->child_tail = d_ptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
733 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
734 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
735 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
736 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
737 // check here to see if d_ptr is the parent of any of the items in the lost / found list
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
738 lf_ptr = lf_head; lf_shd = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
739 @@ -977,16 +1098,13 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
740 lf_ptr = lf_ptr->next;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
741 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
742 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
743 - memcpy(&desc_rec, bptr, sizeof(desc_rec));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
744 - LE32_CPU(desc_rec.d_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
745 - LE32_CPU(desc_rec.desc_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
746 - LE32_CPU(desc_rec.list_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
747 - LE32_CPU(desc_rec.parent_id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
748 - bptr+= sizeof(desc_rec);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
749 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
750 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
751 + roff = offset + ( bptr - buf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
752 + bptr+= _pst_decode_desc( &desc_rec, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
753 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
754 // fseek(pf->fp, fpos, SEEK_SET);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
755 - } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
756 - // hopefully a table of offsets to more tables
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
757 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
758 + else { // {{{ table of offsets to more tables, recurse
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
759 if (_pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, &buf, 0, 0) < DESC_BLOCK_SIZE) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
760 DEBUG_WARN(("didn't read enough desc index. _pst_read_block_size returned less than requested\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
761 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
762 @@ -995,15 +1113,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
763 bptr = buf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
764 // DEBUG_HEXDUMPC(buf, DESC_BLOCK_SIZE, 12);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
765
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
766 - memcpy(&table, bptr, sizeof(table));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
767 - LE32_CPU(table.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
768 - LE32_CPU(table.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
769 - LE32_CPU(table.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
770 - bptr+=sizeof(table);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
771 - memcpy(&table2, bptr, sizeof(table));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
772 - LE32_CPU(table2.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
773 - LE32_CPU(table2.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
774 - LE32_CPU(table2.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
775 + bptr+=_pst_decode_table( &table, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
776 + _pst_decode_table( &table2, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
777
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
778 if (start_id != -1 && table.start != start_id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
779 DEBUG_WARN(("This table isn't right. Perhaps we are too deep, or corruption\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
780 @@ -1034,20 +1145,13 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
781 _pst_build_desc_ptr(pf, table.offset, depth+1, high_id, table.start, table2.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
782 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
783
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
784 - memcpy(&table, bptr, sizeof(table));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
785 - LE32_CPU(table.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
786 - LE32_CPU(table.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
787 - LE32_CPU(table.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
788 - bptr+=sizeof(table);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
789 - memcpy(&table2, bptr, sizeof(table));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
790 - LE32_CPU(table2.start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
791 - LE32_CPU(table2.u1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
792 - LE32_CPU(table2.offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
793 + bptr+=_pst_decode_table( &table, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
794 + _pst_decode_table( &table2, bptr );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
795 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
796 if (buf) free(buf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
797 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
798 return 3;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
799 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
800 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
801 // ok, lets try freeing the d_ptr_head cache here
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
802 while (d_ptr_head != NULL) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
803 d_ptr_ptr = d_ptr_head->next;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
804 @@ -1183,7 +1287,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
805 return item;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
806 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
807
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
808 -pst_num_array * _pst_parse_block(pst_file *pf, u_int32_t block_id, pst_index2_ll *i2_head) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
809 +pst_num_array * _pst_parse_block(pst_file *pf, u_int32_t block_id, pst_index2_ll *i2_head) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
810 unsigned char *buf = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
811 pst_num_array *na_ptr = NULL, *na_head = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
812 pst_block_offset block_offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
813 @@ -1194,6 +1298,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
814 size_t read_size=0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
815 pst_x_attrib_ll *mapptr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
816
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
817 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
818 struct {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
819 u_int16_t type;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
820 u_int16_t ref_type;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
821 @@ -1238,13 +1343,13 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
822
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
823 // DEBUG_EMAIL(("About to read %i bytes from offset %#x\n", block->size, block->offset));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
824
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
825 - if ((read_size = _pst_ff_getIDblock_dec(pf, block_id, &buf)) == 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
826 - // if (_pst_read_block_size(pf, block->offset, block->size, &buf, PST_ENC, 0) < block->size) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
827 + if ((read_size = _pst_ff_getIDblock_dec(pf, block_id, &buf)) == 0) { // {{{ error
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
828 + // if (_pst_read_block_size(pf, block->offset, block->size, &buf, PST_ENC, 0) < block->size)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
829 WARN(("Error reading block id %#x\n", block_id));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
830 if (buf) free (buf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
831 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
832 return NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
833 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
834 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
835 DEBUG_EMAIL(("pointer to buf is %p\n", buf));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
836
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
837 memcpy(&block_hdr, &(buf[0]), sizeof(block_hdr));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
838 @@ -1255,7 +1360,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
839
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
840 ind_ptr = block_hdr.index_offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
841
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
842 - if (block_hdr.type == 0xBCEC) { //type 1
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
843 + if (block_hdr.type == 0xBCEC) { // {{{ type 1, populate block_offset
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
844 block_type = 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
845
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
846 _pst_getBlockOffset(buf, ind_ptr, block_hdr.offset, &block_offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
847 @@ -1281,7 +1386,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
848 num_list = (to_ptr - fr_ptr)/sizeof(table_rec);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
849 num_recs = 1; // only going to one object in these blocks
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
850 rec_size = 0; // doesn't matter cause there is only one object
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
851 - } else if (block_hdr.type == 0x7CEC) { //type 2
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
852 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
853 + else if (block_hdr.type == 0x7CEC) { // {{{ type 2, populate block_offset from seven_c_blk
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
854 block_type = 2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
855
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
856 _pst_getBlockOffset(buf, ind_ptr, block_hdr.offset, &block_offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
857 @@ -1340,16 +1446,17 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
858
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
859 _pst_getBlockOffset(buf, ind_ptr, seven_c_blk.ind2_offset, &block_offset);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
860 ind2_ptr = block_offset.from;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
861 - } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
862 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
863 + else { // {{{ error
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
864 WARN(("ERROR: Unknown block constant - %#X for id %#x\n", block_hdr.type, block_id));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
865 DEBUG_HEXDUMPC(buf, read_size,0x10);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
866 if (buf) free(buf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
867 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
868 return NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
869 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
870 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
871
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
872 DEBUG_EMAIL(("Mallocing number of items %i\n", num_recs));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
873 - while (count_rec < num_recs) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
874 + while (count_rec < num_recs) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
875 na_ptr = (pst_num_array*) xmalloc(sizeof(pst_num_array));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
876 memset(na_ptr, 0, sizeof(pst_num_array));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
877 if (na_head == NULL) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
878 @@ -1371,13 +1478,14 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
879 fr_ptr = list_start; // init fr_ptr to the start of the list.
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
880 cur_list = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
881 stop = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
882 - while (!stop && cur_list < num_list) { //we will increase fr_ptr as we progress through index
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
883 - if (block_type == 1) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
884 + while (!stop && cur_list < num_list) { //{{{ we will increase fr_ptr as we progress through index
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
885 + if (block_type == 1) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
886 memcpy(&table_rec, &(buf[fr_ptr]), sizeof(table_rec));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
887 LE16_CPU(table_rec.type);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
888 LE16_CPU(table_rec.ref_type);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
889 fr_ptr += sizeof(table_rec);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
890 - } else if (block_type == 2) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
891 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
892 + else if (block_type == 2) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
893 // we will copy the table2_rec values into a table_rec record so that we can keep the rest of the code
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
894 memcpy(&table2_rec, &(buf[fr_ptr]), sizeof(table2_rec));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
895 LE16_CPU(table2_rec.ref_type);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
896 @@ -1398,12 +1506,13 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
897 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
898
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
899 fr_ptr += sizeof(table2_rec);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
900 - } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
901 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
902 + else { // {{{ ERROR
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
903 WARN(("Missing code for block_type %i\n", block_type));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
904 if (buf) free(buf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
905 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
906 return NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
907 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
908 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
909 cur_list++; // get ready to read next bit from list
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
910 DEBUG_EMAIL(("reading block %i (type=%#x, ref_type=%#x, value=%#x)\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
911 x, table_rec.type, table_rec.ref_type, table_rec.value));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
912 @@ -1466,10 +1575,10 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
913 || table_rec.ref_type == 0x001E || table_rec.ref_type == 0x0102
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
914 || table_rec.ref_type == 0x0040 || table_rec.ref_type == 0x101E
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
915 || table_rec.ref_type == 0x0048 || table_rec.ref_type == 0x1102
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
916 - || table_rec.ref_type == 0x1014) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
917 + || table_rec.ref_type == 0x1014 || table_rec.ref_type == 0x001F ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
918 //contains index_ref to data
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
919 LE32_CPU(table_rec.value);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
920 - if ((table_rec.value & 0x0000000F) == 0xF) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
921 + if ((table_rec.value & 0x0000000F) == 0xF) { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
922 // if value ends in 'F' then this should be an id2 value
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
923 DEBUG_EMAIL(("Found id2 [%#x] value. Will follow it\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
924 table_rec.value));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
925 @@ -1483,7 +1592,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
926 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
927 DEBUG_EMAIL(("Read %i bytes to a buffer at %p\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
928 na_ptr->items[x]->size, na_ptr->items[x]->data));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
929 - } else if (table_rec.value != 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
930 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
931 + else if (table_rec.value != 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
932 if ((table_rec.value >> 4)+ind_ptr > read_size) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
933 // check that we will not be outside the buffer we have read
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
934 DEBUG_WARN(("table_rec.value [%#x] is outside of block [%#x]\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
935 @@ -1507,10 +1617,30 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
936 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
937
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
938 // plus one for good luck (and strings) we will null terminate all reads
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
939 - na_ptr->items[x]->data = (char*) xmalloc(size+1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
940 - memcpy(na_ptr->items[x]->data, &(buf[t_ptr]), size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
941 - na_ptr->items[x]->data[size] = '\0'; // null terminate buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
942 + if( 0x001F == table_rec.ref_type ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
943 + VBUF_STATIC( strbuf, 1024 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
944 + VBUF_STATIC( unibuf, 1024 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
945 + //need UTF-16 zero-termination
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
946 + vbset( strbuf, &(buf[t_ptr]), size );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
947 + vbappend( strbuf, "\0\0", 2 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
948 + DEBUG_INDEX(("Iconv in: "));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
949 + DEBUG_HEXDUMPC( strbuf->b, strbuf->dlen, 0x10 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
950 + vb_utf16to8( unibuf, strbuf->b, strbuf->dlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
951 + na_ptr->items[x]->data = (char*) xmalloc(unibuf->dlen);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
952 + memcpy(na_ptr->items[x]->data, unibuf->b, unibuf->dlen);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
953 + na_ptr->items[x]->size = unibuf->dlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
954 + DEBUG_INDEX(("Iconv out: "));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
955 + DEBUG_HEXDUMPC(na_ptr->items[x]->data, na_ptr->items[x]->size, 0x10 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
956 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
957 + else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
958 + na_ptr->items[x]->data = (char*) xmalloc(size+1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
959 + memcpy(na_ptr->items[x]->data, &(buf[t_ptr]), size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
960 + na_ptr->items[x]->data[size] = '\0'; // null terminate buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
961 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
962
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
963 + DEBUG_INDEX(("Item Puke: type: %x, ref_type: %x, value: %x\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
964 + table_rec.type, table_rec.ref_type, table_rec.value ));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
965 + DEBUG_HEXDUMPC(na_ptr->items[x]->data, size, 0x10 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
966 if (table_rec.ref_type == 0xd) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
967 // there is still more to do for the type of 0xD
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
968 type_d_rec = (struct _type_d_rec*) na_ptr->items[x]->data;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
969 @@ -1526,7 +1656,6 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
970 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
971 DEBUG_EMAIL(("Read %i bytes into a buffer at %p\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
972 na_ptr->items[x]->size, na_ptr->items[x]->data));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
973 - // }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
974 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
975 } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
976 DEBUG_EMAIL(("Ignoring 0 value in offset\n"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
977 @@ -1548,18 +1677,18 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
978 return NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
979 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
980 x++;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
981 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
982 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
983 DEBUG_EMAIL(("increasing ind2_ptr by %i [%#x] bytes. Was %#x, Now %#x\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
984 rec_size, rec_size, ind2_ptr,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
985 ind2_ptr+rec_size));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
986 ind2_ptr += rec_size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
987 count_rec++;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
988 - }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
989 + } // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
990 if (buf != NULL)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
991 free(buf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
992 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
993 return na_head;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
994 -}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
995 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
996
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
997 // check if item->email is NULL, and init if so
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
998 #define MALLOC_EMAIL(x) { if (x->email == NULL) { x->email = (pst_item_email*) xmalloc(sizeof(pst_item_email)); memset (x->email, 0, sizeof(pst_item_email));} }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
999 @@ -3384,7 +3513,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1000 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1001 if (_pst_read_block_size(pf, list->offset, list->size, &buf, PST_NO_ENC,0) < list->size) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1002 //an error occured in block read
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1003 - WARN(("block read error occured. offset = %#x, size = %#x\n", list->offset, list->size));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1004 + WARN(("block read error occured. offset = %#llx, size = %#llx\n", list->offset, list->size));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1005 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1006 return NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1007 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1008 @@ -3394,7 +3523,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1009 LE16_CPU(block_head.count);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1010
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1011 if (block_head.type != 0x0002) { // some sort of constant?
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1012 - WARN(("Unknown constant [%#x] at start of id2 values [offset %#x].\n", block_head.type, list->offset));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1013 + WARN(("Unknown constant [%#x] at start of id2 values [offset %#llx].\n", block_head.type, list->offset));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1014 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1015 return NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1016 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1017 @@ -3678,7 +3807,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1018 return 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1019 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1020
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1021 -pst_index_ll * _pst_getID(pst_file* pf, u_int32_t id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1022 +pst_index_ll * _pst_getID(pst_file* pf, u_int64_t id) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1023 // static pst_index_ll *old_val = NULL; //this should make it quicker
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1024 pst_index_ll *ptr = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1025 DEBUG_ENT("_pst_getID");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1026 @@ -3693,9 +3822,10 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1027 // Dave: I don't think I should do this. next bit. I really think it doesn't work
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1028 // it isn't based on sound principles either.
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1029 // update: seems that the last two sig bits are flags. u tell me!
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1030 - id &= 0xFFFFFFFE; // remove least sig. bit. seems that it might work if I do this
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1031 + //id &= 0xFFFFFFFE; // remove least sig. bit. seems that it might work if I do this
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1032 + id -= (id & 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1033
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1034 - DEBUG_INDEX(("Trying to find %#x\n", id));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1035 + DEBUG_INDEX(("Trying to find %#llx\n", id));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1036
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1037 if (ptr == NULL)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1038 ptr = pf->i_head;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1039 @@ -3927,6 +4057,9 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1040 return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1041 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1042
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1043 + DEBUG_INDEX(("_pst_decrypt()"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1044 + DEBUG_HEXDUMPC(buf, size, 0x10 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1045 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1046 if (type == PST_COMP_ENCRYPT) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1047 x = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1048 while (x < size) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1049 @@ -3935,6 +4068,9 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1050 buf[x] = comp_enc[y]; // transpose from encrypt array
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1051 x++;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1052 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1053 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1054 + DEBUG_INDEX(("_pst_decrypt() result"));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1055 + DEBUG_HEXDUMPC(buf, size, 0x10 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1056 } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1057 WARN(("Unknown encryption: %i. Cannot decrypt\n", type));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1058 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1059 @@ -3944,7 +4080,23 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1060 return 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1061 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1062
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1063 -int32_t _pst_getAtPos(FILE *fp, int32_t pos, void* buf, u_int32_t size) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1064 +int64_t _pst_getIntAtPos(FILE *fp, off_t pos ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1065 + int64_t buf64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1066 + int32_t buf32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1067 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1068 + if(do_read64) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1069 + _pst_getAtPos(fp, pos, &buf64, sizeof( buf64 ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1070 + LE64_CPU(buf64);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1071 + return buf64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1072 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1073 + else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1074 + _pst_getAtPos(fp, pos, &buf32, sizeof( buf32 ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1075 + LE32_CPU(buf32);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1076 + return buf32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1077 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1078 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1079 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1080 +int32_t _pst_getAtPos(FILE *fp, off_t pos, void* buf, u_int32_t size) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1081 DEBUG_ENT("_pst_getAtPos");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1082 if (fseek(fp, pos, SEEK_SET) == -1) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1083 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1084 diff -Naur ../orig/libpst-0.5.1/libpst.h libpst64-060926/libpst.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1085 --- ../orig/libpst-0.5.1/libpst.h 2004-11-17 07:48:03.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1086 +++ libpst64-060926/libpst.h 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1087 @@ -117,6 +117,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1088 #define PST_APP_LABEL_ANNIVERSARY 9 // Anniversary
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1089 #define PST_APP_LABEL_PHONE_CALL 10// Phone Call
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1090
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1091 +extern int do_read64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1092 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1093 typedef struct _pst_misc_6_struct {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1094 int32_t i1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1095 int32_t i2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1096 @@ -132,26 +134,72 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1097 int32_t id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1098 } pst_entryid;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1099
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1100 -typedef struct _pst_desc_struct {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1101 +typedef struct _pst_desc_struct32 {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1102 u_int32_t d_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1103 u_int32_t desc_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1104 u_int32_t list_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1105 u_int32_t parent_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1106 -} pst_desc;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1107 +} pst_desc32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1108
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1109 -typedef struct _pst_index_struct{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1110 +typedef struct _pst_desc_structn {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1111 + u_int64_t d_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1112 + u_int64_t desc_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1113 + u_int64_t list_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1114 +// u_int64_t parent_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1115 + u_int32_t parent_id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1116 + u_int32_t u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1117 +} pst_descn;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1118 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1119 +typedef struct _pst_index_struct32{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1120 u_int32_t id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1121 int32_t offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1122 u_int16_t size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1123 int16_t u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1124 +} pst_index32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1125 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1126 +/*
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1127 +typedef struct _pst_index_struct64{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1128 + u_int64_t id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1129 + int64_t offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1130 + u_int16_t size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1131 + int16_t u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1132 +} pst_index64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1133 +*/
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1134 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1135 +typedef struct _pst_index_struct{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1136 + u_int64_t id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1137 + int64_t offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1138 + u_int16_t size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1139 + int16_t u0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1140 + int32_t u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1141 } pst_index;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1142
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1143 -typedef struct _pst_index_tree {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1144 +/*
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1145 +typedef union _pst_index_struct {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1146 + pst_index32 i32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1147 + pst_index64 i64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1148 +} pst_index;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1149 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1150 +#define INDEX_ID(x) ((do_read64)?x.i64.id:x.i32.id)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1151 +#define INDEX_OFFSET(x) ((do_read64)?x.i64.offset:x.i32.offset)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1152 +#define INDEX_SIZE(x) ((do_read64)?x.i64.size:x.i32.size)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1153 +#define INDEX_U1(x) ((do_read64)?x.i64.u1:x.i32.u1)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1154 +*/
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1155 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1156 +typedef struct _pst_index_tree32 {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1157 u_int32_t id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1158 int32_t offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1159 - size_t size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1160 + int32_t size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1161 int32_t u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1162 struct _pst_index_tree * next;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1163 +} pst_index_ll32;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1164 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1165 +typedef struct _pst_index_tree {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1166 + u_int64_t id;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1167 + int64_t offset;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1168 + int64_t size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1169 + int64_t u1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1170 + struct _pst_index_tree * next;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1171 } pst_index_ll;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1172
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1173 typedef struct _pst_index2_tree {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1174 @@ -421,6 +469,10 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1175 int32_t index1_count;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1176 int32_t index2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1177 int32_t index2_count;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1178 + int64_t index1_64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1179 + int64_t index1_count_64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1180 + int64_t index2_64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1181 + int64_t index2_count_64;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1182 FILE * fp;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1183 size_t size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1184 unsigned char index1_depth;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1185 @@ -460,6 +512,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1186 };
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1187
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1188 // prototypes
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1189 +void set_read64();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1190 int32_t pst_open(pst_file *pf, char *name, char *mode);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1191 int32_t pst_close(pst_file *pf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1192 pst_desc_ll * pst_getTopOfFolders(pst_file *pf, pst_item *root);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1193 @@ -470,8 +523,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1194 pst_desc_ll* pst_getNextDptr(pst_desc_ll* d);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1195 int32_t pst_load_extended_attributes(pst_file *pf);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1196
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1197 -int32_t _pst_build_id_ptr(pst_file *pf, int32_t offset, int32_t depth, int32_t start_val, int32_t end_val);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1198 -int32_t _pst_build_desc_ptr (pst_file *pf, int32_t offset, int32_t depth, int32_t *high_id,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1199 +int32_t _pst_build_id_ptr(pst_file *pf, off_t offset, int32_t depth, int32_t start_val, int32_t end_val);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1200 +int32_t _pst_build_desc_ptr (pst_file *pf, off_t offset, int32_t depth, int32_t *high_id,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1201 int32_t start_id, int32_t end_val);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1202 pst_item* _pst_getItem(pst_file *pf, pst_desc_ll *d_ptr);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1203 void * _pst_parse_item (pst_file *pf, pst_desc_ll *d_ptr);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1204 @@ -485,13 +538,14 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1205 int32_t _pst_free_xattrib(pst_x_attrib_ll *x);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1206 int32_t _pst_getBlockOffset(char *buf, int32_t i_offset, int32_t offset, pst_block_offset *p);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1207 pst_index2_ll * _pst_build_id2(pst_file *pf, pst_index_ll* list, pst_index2_ll* head_ptr);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1208 -pst_index_ll * _pst_getID(pst_file* pf, u_int32_t id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1209 +pst_index_ll * _pst_getID(pst_file* pf, u_int64_t id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1210 pst_index_ll * _pst_getID2(pst_index2_ll * ptr, u_int32_t id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1211 pst_desc_ll * _pst_getDptr(pst_file *pf, u_int32_t id);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1212 size_t _pst_read_block_size(pst_file *pf, int32_t offset, size_t size, char ** buf, int32_t do_enc,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1213 unsigned char is_index);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1214 int32_t _pst_decrypt(unsigned char *buf, size_t size, int32_t type);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1215 -int32_t _pst_getAtPos(FILE *fp, int32_t pos, void* buf, u_int32_t size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1216 +int64_t _pst_getIntAtPos(FILE *fp, off_t pos);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1217 +int32_t _pst_getAtPos(FILE *fp, off_t pos, void* buf, u_int32_t size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1218 int32_t _pst_get (FILE *fp, void *buf, u_int32_t size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1219 size_t _pst_ff_getIDblock_dec(pst_file *pf, u_int32_t id, unsigned char **b);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1220 size_t _pst_ff_getIDblock(pst_file *pf, u_int32_t id, unsigned char** b);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1221 diff -Naur ../orig/libpst-0.5.1/libstrfunc.c libpst64-060926/libstrfunc.c
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1222 --- ../orig/libpst-0.5.1/libstrfunc.c 2004-11-17 07:48:03.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1223 +++ libpst64-060926/libstrfunc.c 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1224 @@ -67,3 +67,30 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1225 return _sf_b64_buf=output;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1226 };
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1227
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1228 +void hexdump(char *hbuf, int start, int stop, int ascii) /* {{{ HexDump all or a part of some buffer */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1229 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1230 + char c;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1231 + int diff,i;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1232 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1233 + while (start < stop ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1234 + diff = stop - start;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1235 + if (diff > 16) diff = 16;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1236 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1237 + fprintf(stderr, ":%08X ",start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1238 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1239 + for (i = 0; i < diff; i++) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1240 + if( 8 == i ) fprintf( stderr, " " );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1241 + fprintf(stderr, "%02X ",(unsigned char)*(hbuf+start+i));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1242 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1243 + if (ascii) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1244 + for (i = diff; i < 16; i++) fprintf(stderr, " ");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1245 + for (i = 0; i < diff; i++) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1246 + c = *(hbuf+start+i);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1247 + fprintf(stderr, "%c", isprint(c) ? c : '.');
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1248 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1249 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1250 + fprintf(stderr, "\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1251 + start += 16;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1252 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1253 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1254 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1255 diff -Naur ../orig/libpst-0.5.1/libstrfunc.h libpst64-060926/libstrfunc.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1256 --- ../orig/libpst-0.5.1/libstrfunc.h 2004-11-17 07:48:03.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1257 +++ libpst64-060926/libstrfunc.h 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1258 @@ -1,2 +1,4 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1259
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1260 char * base64_encode(void *data, size_t size);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1261 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1262 +void hexdump(char *hbuf, int start, int stop, int ascii);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1263 diff -Naur ../orig/libpst-0.5.1/lspst.c libpst64-060926/lspst.c
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1264 --- ../orig/libpst-0.5.1/lspst.c 2004-11-17 07:48:03.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1265 +++ libpst64-060926/lspst.c 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1266 @@ -37,6 +37,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1267 char *rfc2426_escape(char *str);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1268 char *rfc2445_datetime_format(FILETIME *ft);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1269 // }}}1
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1270 +#undef DEBUG_MAIN
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1271 #define DEBUG_MAIN(x) debug_print x;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1272 // int main(int argc, char** argv) {{{1
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1273 int main(int argc, char** argv) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1274 diff -Naur ../orig/libpst-0.5.1/Makefile libpst64-060926/Makefile
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1275 --- ../orig/libpst-0.5.1/Makefile 2004-11-17 09:16:02.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1276 +++ libpst64-060926/Makefile 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1277 @@ -1,9 +1,12 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1278 #!/usr/bin/make -f
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1279
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1280 -CFLAGS ?= -g -Wall
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1281 +CFLAGS ?= -g -Wall
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1282 PREFIX ?= /usr/local
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1283 INSTALL ?= install
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1284
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1285 +# You might need this
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1286 +#LDLIBS ?= -liconv
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1287 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1288 #---------------- Do not modify below this point ------------------
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1289
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1290 INSTALL_DIR := $(INSTALL) -p -d -o root -g root -m 0755
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1291 @@ -39,9 +42,11 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1292 readpstlog.o: XGetopt.h define.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1293 testdebug.o: define.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1294 timeconv.o: timeconv.h common.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1295 +vbuf.o: vbuf.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1296 +generic.o: generic.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1297
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1298 -readpst: readpst.o libpst.o timeconv.o libstrfunc.o debug.o lzfu.o
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1299 -lspst: debug.o libpst.o libstrfunc.o lspst.o timeconv.o
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1300 +readpst: readpst.o libpst.o timeconv.o libstrfunc.o debug.o lzfu.o vbuf.o generic.o
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1301 +lspst: debug.o libpst.o libstrfunc.o lspst.o timeconv.o vbuf.o generic.o
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1302 getidblock: getidblock.o libpst.o debug.o libstrfunc.o
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1303 testdebug: testdebug.o debug.o
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1304 readpstlog: readpstlog.o debug.o
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1305 diff -Naur ../orig/libpst-0.5.1/readpst.c libpst64-060926/readpst.c
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1306 --- ../orig/libpst-0.5.1/readpst.c 2004-11-17 07:48:03.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1307 +++ libpst64-060926/readpst.c 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1308 @@ -13,6 +13,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1309 #include <limits.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1310 #include <errno.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1311
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1312 +#include "vbuf.h"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1313 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1314 #ifndef _WIN32
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1315 # include <unistd.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1316 # include <sys/stat.h> //mkdir
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1317 @@ -70,19 +72,19 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1318 // Function Declarations {{{1
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1319 void write_email_body(FILE *f, char *body);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1320 char *removeCR (char *c);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1321 -int32_t usage();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1322 -int32_t version();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1323 +int usage();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1324 +int version();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1325 char *mk_kmail_dir(char*);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1326 -int32_t close_kmail_dir();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1327 +int close_kmail_dir();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1328 char *mk_recurse_dir(char*);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1329 -int32_t close_recurse_dir();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1330 +int close_recurse_dir();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1331 char *mk_seperate_dir(char *dir, int overwrite);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1332 -int32_t close_seperate_dir();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1333 -int32_t mk_seperate_file(struct file_ll *f);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1334 +int close_seperate_dir();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1335 +int mk_seperate_file(struct file_ll *f);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1336 char *my_stristr(char *haystack, char *needle);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1337 char *check_filename(char *fname);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1338 char *rfc2426_escape(char *str);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1339 -int32_t chr_count(char *str, char x);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1340 +int chr_count(char *str, char x);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1341 char *rfc2425_datetime_format(FILETIME *ft);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1342 char *rfc2445_datetime_format(FILETIME *ft);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1343 char *skip_header_prologue(char *headers);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1344 @@ -107,6 +109,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1345 // saved as email_no-filename (e.g. 1-samplefile.doc or 000001-Attachment2.zip)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1346 #define MODE_SEPERATE 3
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1347
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1348 +// Decrypt the whole file (even the parts that aren't encrypted) and ralph it to stdout
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1349 +#define MODE_DECSPEW 4
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1350
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1351 // Output Normal just prints the standard information about what is going on
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1352 #define OUTPUT_NORMAL 0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1353 @@ -153,7 +157,7 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1354 prog_name = argv[0];
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1355 // }}}2
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1356
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1357 - while ((c = getopt(argc, argv, "d:hko:qrSVwc:"))!= -1) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1358 + while ((c = getopt(argc, argv, "C6d:hko:qrSVwc:"))!= -1) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1359 switch (c) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1360 case 'c':
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1361 if (optarg!=NULL && optarg[0]=='v')
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1362 @@ -168,6 +172,9 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1363 case 'd':
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1364 d_log = optarg;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1365 break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1366 + case '6':
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1367 + set_read64();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1368 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1369 case 'h':
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1370 usage();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1371 exit(0);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1372 @@ -191,6 +198,9 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1373 case 'S':
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1374 mode = MODE_SEPERATE;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1375 break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1376 + case 'C':
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1377 + mode = MODE_DECSPEW;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1378 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1379 case 'w':
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1380 overwrite = 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1381 break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1382 @@ -201,6 +211,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1383 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1384 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1385
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1386 + unicode_init();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1387 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1388 #ifdef DEBUG_ALL
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1389 // initialize log file
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1390 if (d_log == NULL)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1391 @@ -218,6 +230,29 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1392 exit(2);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1393 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1394
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1395 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1396 + if ( mode == MODE_DECSPEW ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1397 + FILE *fp;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1398 + char buf[1024];
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1399 + int l=0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1400 + if( NULL == ( fp = fopen(fname, "rb" ) ) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1401 + fprintf(stderr, "Couldn't open file %s\n", fname );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1402 + return 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1403 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1404 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1405 + while( 0 != ( l = fread( buf, 1, 1024, fp ) ) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1406 + if( 0 != _pst_decrypt( buf, l, PST_COMP_ENCRYPT ) )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1407 + fprintf(stderr, "_pst_decrypt() failed (I'll try to continue)\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1408 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1409 + if( l != fwrite( buf, 1, l, stdout ) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1410 + fprintf(stderr, "Couldn't output to stdout?\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1411 + return 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1412 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1413 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1414 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1415 + return 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1416 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1417 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1418 if (output_mode != OUTPUT_QUIET) printf("Opening PST file and indexes...\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1419
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1420 DEBUG_MAIN(("main: Opening PST file '%s'\n", fname));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1421 @@ -1139,6 +1174,8 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1422 printf("\t-S\t- Seperate. Write emails in the seperate format\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1423 printf("\t-V\t- Version. Display program version\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1424 printf("\t-w\t- Overwrite any output mbox files\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1425 + printf("\t-6\t- Attempt to read 64-bit Outlook file (Outlook 2003)\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1426 + printf("\t-C\t- Decrypt the entire file and output on stdout (not typically useful)\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1427 DEBUG_RET();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1428 return 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1429 }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1430 diff -Naur ../orig/libpst-0.5.1/vbuf.c libpst64-060926/vbuf.c
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1431 --- ../orig/libpst-0.5.1/vbuf.c 1969-12-31 17:00:00.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1432 +++ libpst64-060926/vbuf.c 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1433 @@ -0,0 +1,932 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1434 +// {{{ includes
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1435 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1436 +#include <ctype.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1437 +//#include "defines.h"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1438 +#include <errno.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1439 +#include <iconv.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1440 +#include <malloc.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1441 +#include <signal.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1442 +#include <stdarg.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1443 +#include <stdio.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1444 +#include <stdlib.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1445 +#include <string.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1446 +#include "vbuf.h"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1447 +#include "generic.h"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1448 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1449 +#ifdef WITH_DMALLOC
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1450 +#include <dmalloc.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1451 +#endif
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1452 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1453 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1454 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1455 +int skip_nl( char *s ) // {{{ returns the width of the newline at s[0]
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1456 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1457 + if( s[0] == '\n' ) return 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1458 + if( s[0] == '\r' && s[1] == '\n' ) return 2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1459 + if( s[0] == '\0' ) return 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1460 + return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1461 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1462 +int find_nl( vstr *vs ) // {{{ find newline of type type in b
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1463 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1464 + char *nextr, *nextn;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1465 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1466 + nextr = memchr( vs->b, '\r', vs->dlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1467 + nextn = memchr( vs->b, '\n', vs->dlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1468 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1469 + //case 1: UNIX, we find \n first
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1470 + if( nextn && (nextr == NULL || nextr > nextn ) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1471 + return nextn - vs->b;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1472 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1473 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1474 + //case 2: DOS, we find \r\n
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1475 + if( NULL != nextr && NULL != nextn && 1 == (char*)nextn - (char*)nextr ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1476 + return nextr - vs->b;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1477 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1478 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1479 + //case 3: we find nothing
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1480 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1481 + return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1482 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1483 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1484 +// {{{ UTF8 <-> UTF16 <-> ISO8859 Character set conversion functions and (ack) their globals
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1485 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1486 +//TODO: the following should not be
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1487 +char *wwbuf=NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1488 +size_t nwwbuf=0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1489 +static int unicode_up=0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1490 +iconv_t i16to8, i8to16, i8859_1to8, i8toi8859_1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1491 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1492 +void unicode_init() // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1493 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1494 + char *wipe = "";
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1495 + char dump[4];
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1496 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1497 + if( unicode_up ) unicode_close();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1498 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1499 + if( (iconv_t)-1 == (i16to8 = iconv_open( "UTF-8", "UTF-16" ) ) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1500 + fprintf(stderr, "doexport(): Couldn't open iconv descriptor for UTF-16 to UTF-8.\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1501 + exit( 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1502 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1503 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1504 + if( (iconv_t)-1 == (i8to16 = iconv_open( "UTF-16", "UTF-8" ) ) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1505 + fprintf(stderr, "doexport(): Couldn't open iconv descriptor for UTF-8 to UTF-16.\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1506 + exit( 2 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1507 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1508 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1509 + //iconv will prefix output with an FF FE (utf-16 start seq), the following dumps that.
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1510 + memset( dump, 'x', 4 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1511 + ASSERT( 0 == utf8to16( wipe, 1, dump, 4 ), "unicode_init(): attempt to dump FF FE failed." );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1512 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1513 + if( (iconv_t)-1 == (i8859_1to8 = iconv_open( "UTF-8", "ISO_8859-1" ) ) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1514 + fprintf(stderr, "doexport(): Couldn't open iconv descriptor for ASCII to UTF-8.\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1515 + exit( 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1516 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1517 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1518 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1519 + if( (iconv_t)-1 == (i8toi8859_1 = iconv_open( "ISO_8859-1", "UTF-8" ) ) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1520 + fprintf(stderr, "doexport(): Couldn't open iconv descriptor for UTF-8 to ASCII.\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1521 + exit( 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1522 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1523 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1524 + unicode_up = 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1525 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1526 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1527 +void unicode_close() // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1528 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1529 + unicode_up = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1530 + iconv_close( i8to16 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1531 + iconv_close( i16to8 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1532 + iconv_close( i8859_1to8 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1533 + iconv_close( i8toi8859_1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1534 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1535 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1536 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1537 +//int utf16_write( FILE* stream, const void *buf, size_t count ) // {{{ write utf-8 or iso_8869-1 to stream after converting it to utf-16
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1538 +//{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1539 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1540 +// //TODO: if anything big comes through here we are sunk, should do it
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1541 +// //bit-by-bit, not one-big-gulp
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1542 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1543 +// size_t inbytesleft, outbytesleft;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1544 +// char *inbuf, *outbuf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1545 +// size_t icresult;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1546 +// size_t rl;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1547 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1548 +// //do we have enough buffer space?
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1549 +// if( !wwbuf || nwwbuf < (count * 2 + 2) ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1550 +// wwbuf = F_REALLOC( wwbuf, count * 2 +2 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1551 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1552 +// nwwbuf = count * 2 + 2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1553 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1554 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1555 +// inbytesleft = count; outbytesleft = nwwbuf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1556 +// inbuf = (char*)buf; outbuf = wwbuf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1557 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1558 +//// fprintf(stderr, "X%s, %dX", (char*)buf, strlen( buf ));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1559 +//// fflush(stderr);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1560 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1561 +// if( (rl = strlen( buf ) + 1) != count ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1562 +// fprintf(stderr, "utf16_write(): reported buffer size (%d) does not match string length (%d)\n",
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1563 +// count,
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1564 +// rl);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1565 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1566 +// //hexdump( (char*)buf, 0, count, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1567 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1568 +// raise( SIGSEGV );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1569 +// inbytesleft = rl;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1570 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1571 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1572 +//// fprintf(stderr, " attempting to convert:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1573 +//// hexdump( (char*)inbuf, 0, count, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1574 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1575 +// icresult = iconv( i8to16, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1576 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1577 +//// fprintf(stderr, " converted:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1578 +//// hexdump( (char*)buf, 0, count, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1579 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1580 +//// fprintf(stderr, " to:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1581 +//// hexdump( (char*)wwbuf, 0, nwwbuf, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1582 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1583 +// if( (size_t)-1 == icresult ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1584 +// fprintf(stderr, "utf16_write(): iconv failure(%d): %s\n", errno, strerror( errno ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1585 +// fprintf(stderr, " attempted to convert:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1586 +// hexdump( (char*)inbuf, 0, count, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1587 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1588 +// fprintf(stderr, " result:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1589 +// hexdump( (char*)outbuf, 0, count, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1590 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1591 +// fprintf(stderr, "I'm going to segfault now.\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1592 +// raise( SIGSEGV );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1593 +// exit(1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1594 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1595 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1596 +// if( inbytesleft > 0 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1597 +// fprintf(stderr, "utf16_write(): iconv returned a short count.\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1598 +// exit(1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1599 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1600 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1601 +// return fwrite( wwbuf, nwwbuf - outbytesleft - 2, 1, stream );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1602 +//}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1603 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1604 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1605 +//char *utf16buf = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1606 +//int utf16buf_len = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1607 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1608 +//int utf16_fprintf( FILE* stream, const char *fmt, ... ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1609 +//{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1610 +// int result=0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1611 +// va_list ap;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1612 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1613 +// if( utf16buf == NULL ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1614 +// utf16buf = (char*)F_MALLOC( SZ_MAX + 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1615 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1616 +// utf16buf_len = SZ_MAX + 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1617 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1618 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1619 +// va_start( ap, fmt );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1620 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1621 +// result = vsnprintf( utf16buf, utf16buf_len, fmt, ap );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1622 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1623 +// if( result + 1 > utf16buf_len ) { //didn't have space, realloc() and try again
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1624 +// fprintf(stderr, "utf16_fprintf(): buffer too small (%d), F_MALLOC(%d)\n", utf16buf_len, result);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1625 +// free( utf16buf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1626 +// utf16buf_len = result + 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1627 +// utf16buf = (char*)F_MALLOC( utf16buf_len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1628 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1629 +// result = vsnprintf( utf16buf, utf16buf_len, fmt, ap );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1630 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1631 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1632 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1633 +// //didn't have space...again...something weird is going on...
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1634 +// ASSERT( result + 1 <= utf16buf_len, "utf16_fprintf(): Unpossible error!\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1635 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1636 +// if( 1 != utf16_write( stream, utf16buf, result + 1 ) )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1637 +// DIE( "Write error? -> %s or %s\n", strerror( errno ), uerr_str( uerr_get() ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1638 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1639 +// return result;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1640 +//}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1641 +//// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1642 +//int utf16to8( char *inbuf_o, char *outbuf_o, int length ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1643 +//{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1644 +// int inbytesleft = length;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1645 +// int outbytesleft = length;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1646 +// char *inbuf = inbuf_o;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1647 +// char *outbuf = outbuf_o;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1648 +// int rlen = -1, tlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1649 +// int icresult = -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1650 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1651 +// int i, strlen=-1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1652 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1653 +// DEBUG(
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1654 +// fprintf(stderr, " utf16to8(): attempting to convert:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1655 +// //hexdump( (char*)inbuf_o, 0, length, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1656 +// fflush(stderr);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1657 +// );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1658 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1659 +// for( i=0; i<length ; i+=2 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1660 +// if( inbuf_o[i] == 0 && inbuf_o[i + 1] == 0 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1661 +// //fprintf(stderr, "End of string found at: %d\n", i );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1662 +// strlen = i;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1663 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1664 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1665 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1666 +// //hexdump( (char*)inbuf_o, 0, strlen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1667 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1668 +// if( -1 == strlen ) WARN("String is not zero-terminated.");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1669 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1670 +// //iconv does not like it when the inbytesleft > actual string length
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1671 +// //enum: zero terminated, length valid
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1672 +// // zero terminated, length short //we won't go beyond length ever, so this is same as NZT case
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1673 +// // zero terminated, length long
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1674 +// // not zero terminated
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1675 +// // TODO: MEMORY BUG HERE!
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1676 +// for( tlen = 0; tlen <= inbytesleft - 2; tlen+=2 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1677 +// if( inbuf_o[tlen] == 0 && inbuf_o[tlen+1] == 0 ){
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1678 +// rlen = tlen + 2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1679 +// tlen = rlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1680 +// break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1681 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1682 +// if( tlen == inbytesleft )fprintf(stderr, "Space allocated for string > actual string length. Go windows!\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1683 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1684 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1685 +// if( rlen >= 0 )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1686 +// icresult = iconv( i16to8, &inbuf, &rlen, &outbuf, &outbytesleft );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1687 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1688 +// if( icresult == (size_t)-1 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1689 +// fprintf(stderr, "utf16to8(): iconv failure(%d): %s\n", errno, strerror( errno ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1690 +// fprintf(stderr, " attempted to convert:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1691 +// hexdump( (char*)inbuf_o, 0, length, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1692 +// fprintf(stderr, " result:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1693 +// hexdump( (char*)outbuf_o, 0, length, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1694 +// fprintf(stderr, " MyDirtyOut:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1695 +// for( i=0; i<length; i++) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1696 +// if( inbuf_o[i] != '\0' ) fprintf(stderr, "%c", inbuf_o[i] );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1697 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1698 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1699 +// fprintf( stderr, "\n" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1700 +// raise( SIGSEGV );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1701 +// exit(1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1702 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1703 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1704 +// DEBUG(
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1705 +// fprintf(stderr, " result:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1706 +// hexdump( (char*)outbuf_o, 0, length, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1707 +// )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1708 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1709 +// //fprintf(stderr, "utf16to8() returning %s\n", outbuf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1710 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1711 +// return icresult;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1712 +//}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1713 +//// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1714 +int utf16_is_terminated( char *str, int length ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1715 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1716 + VSTR_STATIC( errbuf, 100 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1717 + int len = -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1718 + int i;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1719 + for( i=0; i<length ; i+=2 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1720 + if( str[i] == 0 && str[i + 1] == 0 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1721 + //fprintf(stderr, "End of string found at: %d\n", i );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1722 + len = i;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1723 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1724 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1725 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1726 + //hexdump( (char*)inbuf_o, 0, len, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1727 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1728 + if( -1 == len ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1729 + vshexdump( errbuf, str, 0, length, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1730 + WARN("String is not zero terminated (probably broken data from registry) %s.", errbuf->b);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1731 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1732 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1733 + return (-1 == len )?0:1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1734 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1735 +int vb_utf16to8( vbuf *dest, char *buf, int len ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1736 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1737 + int inbytesleft = len;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1738 + char *inbuf = buf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1739 + //int rlen = -1, tlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1740 + int icresult = -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1741 + VBUF_STATIC( dumpster, 100 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1742 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1743 + //int i; //, strlen=-1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1744 + int outbytesleft;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1745 + char *outbuf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1746 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1747 + ASSERT( unicode_up, "vb_utf16to8() called before unicode started." );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1748 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1749 + if( 2 > dest->blen ) vbresize( dest, 2 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1750 + dest->dlen = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1751 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1752 + //Bad Things can happen if a non-zero-terminated utf16 string comes through here
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1753 + if( !utf16_is_terminated( buf, len ) ) return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1754 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1755 + do {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1756 + outbytesleft = dest->blen - dest->dlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1757 + outbuf = dest->b + dest->dlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1758 + icresult = iconv( i16to8, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1759 + dest->dlen = outbuf - dest->b;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1760 + vbgrow( dest, inbytesleft);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1761 + } while( (size_t)-1 == icresult && E2BIG == errno );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1762 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1763 + if( 0 != vb_utf8to16T( dumpster, dest->b, dest->dlen ) )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1764 + DIE("Reverse conversion failed.");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1765 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1766 + if( icresult == (size_t)-1 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1767 + //TODO: error
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1768 + //ERR_UNIX( errno, "vb_utf16to8():iconv failure: %s", strerror( errno ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1769 + unicode_init();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1770 + return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1771 + /*
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1772 + fprintf(stderr, " attempted to convert:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1773 + hexdump( (char*)cin, 0, inlen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1774 + fprintf(stderr, " result:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1775 + hexdump( (char*)bout->b, 0, bout->dlen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1776 + fprintf(stderr, " MyDirtyOut:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1777 + for( i=0; i<inlen; i++) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1778 + if( inbuf[i] != '\0' ) fprintf(stderr, "%c", inbuf[i] );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1779 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1780 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1781 + fprintf( stderr, "\n" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1782 + raise( SIGSEGV );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1783 + exit(1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1784 + */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1785 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1786 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1787 + if( icresult ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1788 + //ERR_UNIX( EILSEQ, "Uhhhh...vb_utf16to8() returning icresult == %d", icresult );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1789 + return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1790 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1791 + return icresult;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1792 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1793 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1794 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1795 +int utf8to16( char *inbuf_o, int iblen, char *outbuf_o, int oblen) // {{{ iblen, oblen: bytes including \0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1796 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1797 + //TODO: this is *only* used to dump the utf16 preamble now...
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1798 + //TODO: This (and 8to16) are the most horrible things I have ever seen...
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1799 + int inbytesleft;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1800 + int outbytesleft = oblen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1801 + char *inbuf = inbuf_o;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1802 + char *outbuf = outbuf_o;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1803 + //int rlen = -1, tlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1804 + int icresult = -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1805 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1806 + char *stend;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1807 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1808 + //int i; //, strlen=-1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1809 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1810 + DEBUG(
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1811 + fprintf(stderr, " utf8to16(): attempting to convert:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1812 + //hexdump( (char*)inbuf_o, 0, length, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1813 + fflush(stderr);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1814 + );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1815 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1816 + stend = memchr( inbuf_o, '\0', iblen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1817 + ASSERT( NULL != stend, "utf8to16(): in string not zero terminated." );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1818 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1819 + inbytesleft = ( stend - inbuf_o + 1 < iblen )? stend - inbuf_o + 1: iblen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1820 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1821 + //iconv does not like it when the inbytesleft > actual string length
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1822 + //enum: zero terminated, length valid
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1823 + // zero terminated, length short //we won't go beyond length ever, so this is same as NZT case
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1824 + // zero terminated, length long
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1825 + // not zero terminated
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1826 + // TODO: MEMORY BUG HERE!
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1827 + //
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1828 + /*
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1829 + for( tlen = 0; tlen <= inbytesleft - 2; tlen+=2 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1830 + if( inbuf_o[tlen] == 0 && inbuf_o[tlen+1] == 0 ){
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1831 + rlen = tlen + 2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1832 + tlen = rlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1833 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1834 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1835 + if( tlen == inbytesleft )fprintf(stderr, "Space allocated for string > actual string length. Go windows!\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1836 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1837 + */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1838 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1839 + //if( rlen >= 0 )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1840 + icresult = iconv( i8to16, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1841 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1842 + if( icresult == (size_t)-1 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1843 + DIE("iconv failure(%d): %s\n", errno, strerror( errno ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1844 + //fprintf(stderr, " attempted to convert:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1845 + //hexdump( (char*)inbuf_o, 0, iblen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1846 + //fprintf(stderr, " result:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1847 + //hexdump( (char*)outbuf_o, 0, oblen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1848 + //fprintf(stderr, " MyDirtyOut:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1849 +// for( i=0; i<iblen; i++) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1850 +// if( inbuf_o[i] != '\0' ) fprintf(stderr, "%c", inbuf_o[i] );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1851 +// }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1852 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1853 +// fprintf( stderr, "\n" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1854 +// raise( SIGSEGV );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1855 +// exit(1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1856 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1857 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1858 +// DEBUG(
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1859 +// fprintf(stderr, " result:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1860 +// hexdump( (char*)outbuf_o, 0, oblen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1861 +// )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1862 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1863 + //fprintf(stderr, "utf8to16() returning %s\n", outbuf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1864 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1865 + //TODO: error
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1866 + if( icresult ) printf("Uhhhh...utf8to16() returning icresult == %d\n", icresult );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1867 + return icresult;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1868 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1869 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1870 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1871 +int vb_utf8to16T( vbuf *bout, char *cin, int inlen ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1872 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1873 + //TODO: This (and 8to16) are the most horrible things I have ever seen...
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1874 + int inbytesleft = inlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1875 + char *inbuf = cin;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1876 + //int rlen = -1, tlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1877 + int icresult = -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1878 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1879 + //int i; //, strlen=-1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1880 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1881 + //if( rlen >= 0 )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1882 + int outbytesleft;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1883 + char *outbuf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1884 + if( 2 > bout->blen ) vbresize( bout, 2 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1885 + bout->dlen = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1886 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1887 + do {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1888 + outbytesleft = bout->blen - bout->dlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1889 + outbuf = bout->b + bout->dlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1890 + icresult = iconv( i8to16, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1891 + bout->dlen = outbuf - bout->b;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1892 + vbgrow( bout, 20 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1893 + } while( (size_t)-1 == icresult && E2BIG == errno );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1894 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1895 + if( icresult == (size_t)-1 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1896 + WARN("iconv failure: %s", strerror( errno ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1897 + //ERR_UNIX( errno, "vb_utf8to16():iconv failure: %s", strerror( errno ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1898 + unicode_init();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1899 + return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1900 + /*
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1901 + fprintf(stderr, "vb_utf8to16(): iconv failure(%d == %d?): %s\n", errno, E2BIG, strerror( errno ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1902 + fprintf(stderr, " attempted to convert:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1903 + hexdump( (char*)cin, 0, inlen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1904 + fprintf(stderr, " result:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1905 + hexdump( (char*)bout->b, 0, bout->dlen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1906 + fprintf(stderr, " MyDirtyOut:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1907 + for( i=0; i<inlen; i++) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1908 + if( inbuf[i] != '\0' ) fprintf(stderr, "%c", inbuf[i] );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1909 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1910 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1911 + fprintf( stderr, "\n" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1912 + raise( SIGSEGV );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1913 + exit(1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1914 + */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1915 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1916 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1917 + //TODO: error
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1918 + if( icresult ) printf("Uhhhh...vb_utf8to16() returning icresult == %d\n", icresult );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1919 + return icresult;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1920 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1921 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1922 +#if 1
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1923 +void cheap_uni2ascii(char *src, char *dest, int l) /* {{{ Quick and dirty UNICODE to std. ascii */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1924 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1925 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1926 + for (; l > 0; l -=2) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1927 + *dest = *src;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1928 + dest++; src +=2;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1929 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1930 + *dest = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1931 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1932 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1933 +#endif
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1934 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1935 +void cheap_ascii2uni(char *src, char *dest, int l) /* {{{ Quick and dirty ascii to unicode */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1936 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1937 + for (; l > 0; l--) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1938 + *dest++ = *src++;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1939 + *dest++ = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1940 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1941 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1942 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1943 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1944 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1945 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1946 +// {{{ VARBUF Functions
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1947 +vbuf *vballoc( size_t len ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1948 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1949 + struct varbuf *result;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1950 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1951 + result = F_MALLOC( sizeof( struct varbuf ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1952 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1953 + result->dlen = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1954 + result->blen = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1955 + result->buf = NULL;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1956 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1957 + vbresize( result, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1958 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1959 + return result;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1960 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1961 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1962 +void vbcheck( vbuf *vb ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1963 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1964 + ASSERT( vb->b - vb->buf <= vb->blen, "vbcheck(): vb->b outside of buffer range.");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1965 + ASSERT( vb->dlen <= vb->blen, "vbcheck(): data length > buffer length.");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1966 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1967 + ASSERT( vb->blen < 1024*1024, "vbcheck(): blen is a bit large...hmmm.");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1968 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1969 +void vbfree( vbuf *vb ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1970 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1971 + free( vb->buf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1972 + free( vb );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1973 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1974 +void vbclear( struct varbuf *vb ) // {{{ditch the data, keep the buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1975 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1976 + vbresize( vb, 0 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1977 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1978 +void vbresize( struct varbuf *vb, size_t len ) // {{{ DESTRUCTIVELY grow or shrink buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1979 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1980 + vb->dlen = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1981 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1982 + if( vb->blen >= len ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1983 + vb->b = vb->buf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1984 + return;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1985 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1986 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1987 + vb->buf = F_REALLOC( vb->buf, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1988 + vb->b = vb->buf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1989 + vb->blen = len;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1990 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1991 +int vbavail( vbuf *vb ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1992 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1993 + return vb->blen - ((char*)vb->b - (char*)vb->buf + vb->dlen);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1994 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1995 +//void vbdump( vbuf *vb ) // {{{ TODO: to stdout? Yuck
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1996 +//{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1997 +// printf("vb dump-------------\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1998 +// printf("dlen: %d\n", vb->dlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1999 +// printf("blen: %d\n", vb->blen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2000 +// printf("b - buf: %d\n", vb->b - vb->buf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2001 +// printf("buf:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2002 +// hexdump( vb->buf, 0, vb->blen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2003 +// printf("b:\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2004 +// hexdump( vb->b, 0, vb->dlen, 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2005 +// printf("^^^^^^^^^^^^^^^^^^^^\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2006 +//} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2007 +void vbgrow( struct varbuf *vb, size_t len ) // {{{ out: vbavail(vb) >= len, data are preserved
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2008 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2009 + if( 0 == len ) return;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2010 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2011 + if( 0 == vb->blen ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2012 + vbresize( vb, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2013 + return;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2014 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2015 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2016 + if( vb->dlen + len > vb->blen ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2017 + if( vb->dlen + len < vb->blen * 1.5 ) len = vb->blen * 1.5;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2018 + char *nb = F_MALLOC( vb->blen + len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2019 + //printf("vbgrow() got %p back from malloc(%d)\n", nb, vb->blen + len);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2020 + vb->blen = vb->blen + len;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2021 + memcpy( nb, vb->b, vb->dlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2022 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2023 + //printf("vbgrow() I am going to free %p\n", vb->buf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2024 + free( vb->buf );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2025 + vb->buf = nb;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2026 + vb->b = vb->buf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2027 + } else {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2028 + if( vb->b != vb->buf )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2029 + memcpy( vb->buf, vb->b, vb->dlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2030 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2031 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2032 + vb->b = vb->buf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2033 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2034 + ASSERT( vbavail( vb ) >= len, "vbgrow(): I have failed in my mission." );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2035 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2036 +void vbset( vbuf *vb, void *b, size_t len ) // {{{ set vbuf b size=len, resize if necessary, relen = how much to over-allocate
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2037 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2038 + vbresize( vb, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2039 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2040 + memcpy( vb->b, b, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2041 + vb->dlen = len;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2042 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2043 +void vsskipws( vstr *vs ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2044 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2045 + char *p = vs->b;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2046 + while( p - vs->b < vs->dlen && isspace( p[0] ) ) p++;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2047 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2048 + vbskip( (vbuf*)vs, p - vs->b );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2049 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2050 +void vbappend( struct varbuf *vb, void *b, size_t len ) // {{{ append len bytes of b to vbuf, resize if necessary
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2051 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2052 + if( 0 == vb->dlen ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2053 + vbset( vb, b, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2054 + return;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2055 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2056 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2057 + vbgrow( vb, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2058 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2059 + memcpy( vb->b + vb->dlen, b, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2060 + vb->dlen += len;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2061 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2062 + //printf("vbappend() end: >%s/%d<\n", vbuf->b, vbuf->dlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2063 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2064 +void vbskip( struct varbuf *vb, size_t skip ) // {{{ dumps the first skip bytes from vbuf
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2065 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2066 + ASSERT( skip <= vb->dlen, "vbskip(): Attempt to seek past end of buffer." );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2067 + //memmove( vbuf->b, vbuf->b + skip, vbuf->dlen - skip );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2068 + vb->b += skip;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2069 + vb->dlen -= skip;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2070 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2071 +void vboverwrite( struct varbuf *vbdest, struct varbuf *vbsrc ) // {{{ overwrite vbdest with vbsrc
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2072 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2073 + vbresize( vbdest, vbsrc->blen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2074 + memcpy( vbdest->b, vbsrc->b, vbsrc->dlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2075 + vbdest->blen = vbsrc->blen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2076 + vbdest->dlen = vbsrc->dlen;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2077 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2078 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2079 +// {{{ VARSTR Functions
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2080 +vstr *vsalloc( size_t len ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2081 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2082 + vstr *result = (vstr*)vballoc( len + 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2083 + vsset( result, "" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2084 + return result;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2085 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2086 +char *vsstr( vstr *vs ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2087 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2088 + return vs->b;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2089 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2090 +size_t vslen( vstr *vs ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2091 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2092 + return strlen( vsstr( vs ));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2093 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2094 +void vsfree( vstr *vs ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2095 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2096 + vbfree( (vbuf*)vs );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2097 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2098 +void vscharcat( vstr *vb, int ch ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2099 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2100 + vbgrow( (vbuf*)vb, 1);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2101 + vb->b[vb->dlen-1] = ch;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2102 + vb->b[vb->dlen] = '\0';
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2103 + vb->dlen++;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2104 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2105 +void vsnprepend( vstr *vb, char *str, size_t len ) // {{{ prependappend string str to vbuf, vbuf must already contain a valid string
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2106 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2107 + ASSERT( vb->b[vb->dlen-1] == '\0', "vsncat(): attempt to append string to non-string.");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2108 + int sl = strlen( str );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2109 + int n = (sl<len)?sl:len;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2110 + //string append
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2111 + vbgrow( (vbuf*)vb, n + 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2112 + memmove( vb->b + n, vb->b, vb->dlen - 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2113 + memcpy( vb->b, str, n );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2114 + //strncat( vb->b, str, n );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2115 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2116 + vb->dlen += n;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2117 + vb->b[ vb->dlen - 1 ] = '\0';
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2118 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2119 +void vsskip( vstr *vs, size_t len ) // {{{ len < dlen-1 -> skip len chars, else DIE
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2120 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2121 + ASSERT( len < vs->dlen - 1, "Attempt to skip past end of string" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2122 + vbskip( (vbuf*)vs, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2123 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2124 +int vsskipline( vstr *vs ) // {{{ in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2125 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2126 + int nloff = find_nl( vs );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2127 + int nll = skip_nl( vs->b + nloff );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2128 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2129 + if( nloff < 0 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2130 + //TODO: error
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2131 + printf("vb_skipline(): there seems to be no newline here.\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2132 + return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2133 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2134 + if( skip_nl < 0 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2135 + //TODO: error
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2136 + printf("vb_skipline(): there seems to be no newline here...except there should be. :P\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2137 + return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2138 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2139 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2140 + memmove( vs->b, vs->b + nloff + nll, vs->dlen - nloff - nll );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2141 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2142 + vs->dlen -= nloff + nll;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2143 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2144 + return 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2145 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2146 +int vscatprintf( vstr *vs, char *fmt, ... ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2147 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2148 + int size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2149 + va_list ap;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2150 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2151 + /* Guess we need no more than 100 bytes. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2152 + //vsresize( vb, 100 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2153 + if(!vs->b || vs->dlen == 0) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2154 + vsset( vs, "" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2155 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2156 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2157 + while (1) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2158 + /* Try to print in the allocated space. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2159 + va_start(ap, fmt);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2160 + size = vsnprintf (vs->b + vs->dlen - 1, vs->blen - vs->dlen, fmt, ap);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2161 + va_end(ap);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2162 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2163 + /* If that worked, return the string. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2164 + if (size > -1 && size < vs->blen - vs->dlen ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2165 + vs->dlen += size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2166 + return size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2167 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2168 + /* Else try again with more space. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2169 + if ( size >= 0 ) /* glibc 2.1 */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2170 + vbgrow( (vbuf*)vs, size+1 ); /* precisely what is needed */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2171 + else /* glibc 2.0 */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2172 + vbgrow( (vbuf*)vs, vs->blen);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2173 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2174 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2175 +int vslast( vstr *vs ) // {{{ returns the last character stored in a vstr
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2176 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2177 + if( vs->dlen < 1 ) return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2178 + if( vs->b[vs->dlen-1] != '\0' ) return -1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2179 + if( vs->dlen == 1 ) return '\0';
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2180 + return vs->b[vs->dlen-2];
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2181 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2182 +void vs_printf( vstr *vs, char *fmt, ... ) // {{{ print over vb
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2183 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2184 + int size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2185 + va_list ap;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2186 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2187 + /* Guess we need no more than 100 bytes. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2188 + vbresize( (vbuf*)vs, 100 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2189 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2190 + while (1) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2191 + /* Try to print in the allocated space. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2192 + va_start(ap, fmt);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2193 + size = vsnprintf (vs->b, vs->blen, fmt, ap);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2194 + va_end(ap);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2195 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2196 + /* If that worked, return the string. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2197 + if (size > -1 && size < vs->blen) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2198 + vs->dlen = size + 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2199 + return;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2200 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2201 + /* Else try again with more space. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2202 + if ( size >= 0 ) /* glibc 2.1 */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2203 + vbresize( (vbuf*)vs, size+1 ); /* precisely what is needed */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2204 + else /* glibc 2.0 */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2205 + vbresize( (vbuf*)vs, vs->blen*2);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2206 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2207 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2208 +void vs_printfa( vstr *vs, char *fmt, ... ) // {{{ printf append to vs
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2209 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2210 + int size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2211 + va_list ap;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2212 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2213 + if( vs->blen - vs->dlen < 50 )
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2214 + vbgrow( (vbuf*)vs, 100 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2215 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2216 + while (1) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2217 + /* Try to print in the allocated space. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2218 + va_start(ap, fmt);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2219 + size = vsnprintf (vs->b + vs->dlen - 1, vs->blen - vs->dlen + 1, fmt, ap);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2220 + va_end(ap);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2221 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2222 + /* If that worked, return the string. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2223 + if (size > -1 && size < vs->blen) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2224 + vs->dlen += size;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2225 + return;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2226 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2227 + /* Else try again with more space. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2228 + if ( size >= 0 ) /* glibc 2.1 */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2229 + vbgrow( (vbuf*)vs, size+1 - vs->dlen ); /* precisely what is needed */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2230 + else /* glibc 2.0 */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2231 + vbgrow( (vbuf*)vs, size );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2232 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2233 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2234 +void vshexdump( vstr *vs, char *b, size_t start, size_t stop, int ascii ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2235 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2236 + char c;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2237 + int diff,i;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2238 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2239 + while (start < stop ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2240 + diff = stop - start;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2241 + if (diff > 16) diff = 16;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2242 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2243 + vs_printfa(vs, ":%08X ",start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2244 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2245 + for (i = 0; i < diff; i++) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2246 + if( 8 == i ) vs_printfa( vs, " " );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2247 + vs_printfa(vs, "%02X ",(unsigned char)*(b+start+i));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2248 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2249 + if (ascii) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2250 + for (i = diff; i < 16; i++) vs_printfa(vs, " ");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2251 + for (i = 0; i < diff; i++) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2252 + c = *(b+start+i);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2253 + vs_printfa(vs, "%c", isprint(c) ? c : '.');
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2254 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2255 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2256 + vs_printfa(vs, "\n");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2257 + start += 16;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2258 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2259 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2260 +void vsset( vstr *vs, char *s ) // {{{ Store string s in vs
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2261 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2262 + vsnset( vs, s, strlen( s ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2263 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2264 +void vsnset( vstr *vs, char *s, size_t n ) // {{{ Store string s in vs
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2265 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2266 + vbresize( (vbuf*)vs, n + 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2267 + memcpy( vs->b, s, n);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2268 + vs->b[n] = '\0';
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2269 + vs->dlen = n+1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2270 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2271 +void vsgrow( vstr *vs, size_t len ) // {{{ grow buffer by len bytes, data are preserved
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2272 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2273 + vbgrow( (vbuf*)vs, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2274 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2275 +size_t vsavail( vstr *vs ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2276 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2277 + return vbavail( (vbuf*)vs );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2278 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2279 +void vsnset16( vstr *vs, char *s, size_t len ) // {{{ Like vbstrnset, but for UTF16
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2280 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2281 + vbresize( (vbuf*)vs, len+1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2282 + memcpy( vs->b, s, len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2283 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2284 + vs->b[len] = '\0';
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2285 + vs->dlen = len+1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2286 + vs->b[len] = '\0';
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2287 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2288 +void vscat( vstr *vs, char *str ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2289 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2290 + vsncat( vs, str, strlen(str ) );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2291 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2292 +int vscmp( vstr *vs, char *str ) // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2293 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2294 + return strcmp( vs->b, str );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2295 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2296 +void vsncat( vstr *vs, char *str, size_t len ) // {{{ append string str to vstr, vstr must already contain a valid string
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2297 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2298 + ASSERT( vs->b[vs->dlen-1] == '\0', "vsncat(): attempt to append string to non-string.");
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2299 + int sl = strlen( str );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2300 + int n = (sl<len)?sl:len;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2301 + //string append
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2302 + vbgrow( (vbuf*)vs, n + 1 );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2303 + memcpy( vs->b + vs->dlen - 1, str, n );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2304 + //strncat( vs->b, str, n );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2305 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2306 + vs->dlen += n;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2307 + vs->b[ vs->dlen - 1 ] = '\0';
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2308 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2309 +void vstrunc( vstr *v, int off ) // {{{ Drop chars [off..dlen]
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2310 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2311 + if( off >= v->dlen - 1 ) return; //nothing to do
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2312 + v->b[off] = '\0';
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2313 + v->dlen = off + 1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2314 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2315 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2316 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2317 +// {{{ User input
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2318 +// TODO: not sure how useful this stuff is here
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2319 +int fmyinput(char *prmpt, char *ibuf, int maxlen) /* {{{ get user input */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2320 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2321 + printf("%s",prmpt);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2322 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2323 + fgets(ibuf,maxlen+1,stdin);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2324 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2325 + ibuf[strlen(ibuf)-1] = 0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2326 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2327 + return(strlen(ibuf));
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2328 +}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2329 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2330 +//}}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2331 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2332 +//
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2333 +//{{{ String formatting and output to FILE *stream or just stdout, etc
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2334 +// TODO: a lot of old, unused stuff in here
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2335 +void vswinhex8(vstr *vs, unsigned char *hbuf, int start, int stop, int loff ) // {{{ Produce regedit-style hex output */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2336 +{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2337 + int i;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2338 + int lineflag=0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2339 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2340 + for( i=start; i<stop; i++)
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2341 + {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2342 + loff += vscatprintf( vs, "%02x", hbuf[i] );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2343 + if( i < stop - 1 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2344 + loff+=vscatprintf( vs, "," );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2345 + switch( lineflag ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2346 + case 0:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2347 + if( loff >= 77) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2348 + lineflag=1;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2349 + loff=0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2350 + vscatprintf( vs, "\\%s ", STUPID_CR );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2351 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2352 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2353 + case 1:
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2354 + if( loff >= 75 ) {
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2355 + loff=0;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2356 + vscatprintf( vs, "\\%s ", STUPID_CR );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2357 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2358 + break;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2359 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2360 + // if( 24 < i || 0 == (i - 17) % 25 ) fprintf( stream, "\\\n " );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2361 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2362 + }
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2363 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2364 + // fprintf( stream, "\n" );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2365 +} // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2366 diff -Naur ../orig/libpst-0.5.1/vbuf.h libpst64-060926/vbuf.h
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2367 --- ../orig/libpst-0.5.1/vbuf.h 1969-12-31 17:00:00.000000000 -0700
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2368 +++ libpst64-060926/vbuf.h 2006-09-26 14:09:55.000000000 -0600
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2369 @@ -0,0 +1,142 @@
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2370 +/* {{{ vbuf.h - variable length buffer functions
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2371 + *
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2372 + * Functions that try to make dealing with buffers easier.
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2373 + *
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2374 + * vbuf
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2375 + *
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2376 + * vstr
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2377 + * - should always contain a valid string
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2378 + *
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2379 + * }}} */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2380 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2381 +#ifndef VBUF_H
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2382 +#define VBUF_H
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2383 +#define SZ_MAX 4096
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2384 +#include <stdlib.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2385 +#include <stdio.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2386 +#include <stdarg.h>
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2387 +/***************************************************/
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2388 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2389 +// {{{ Tokenizer const TOK_EMPTY, TOK_ELEMENT, DELIM
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2390 +#define DELIM '\\'
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2391 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2392 +#define TOK_EMPTY 0
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2393 +#define TOK_DELIM 1
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2394 +#define TOK_PARENT 2
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2395 +#define TOK_CURRENT 3
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2396 +#define TOK_ELEMENT 4
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2397 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2398 +#define TOK_ERROR 10
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2399 +#define TOK_BUF_SMALL 11
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2400 +// }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2401 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2402 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2403 +// Variable-length buffers
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2404 +struct varbuf { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2405 + size_t dlen; //length of data stored in buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2406 + size_t blen; //length of buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2407 + char *buf; //buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2408 + char *b; //start of stored data
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2409 +}; // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2410 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2411 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2412 +// The exact same thing as a varbuf but should always contain at least '\0'
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2413 +struct varstr { // {{{
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2414 + size_t dlen; //length of data stored in buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2415 + size_t blen; //length of buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2416 + char *buf; //buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2417 + char *b; //start of stored data
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2418 +}; // }}}
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2419 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2420 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2421 +typedef struct varbuf vbuf;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2422 +typedef struct varstr vstr;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2423 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2424 +#define VBUF_STATIC(x,y) static vbuf *x = NULL; if(!x) x = vballoc(y);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2425 +#define VSTR_STATIC(x,y) static vstr *x = NULL; if(!x) x = vsalloc(y);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2426 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2427 +// vbuf functions
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2428 +struct varbuf *vballoc( size_t len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2429 +void vbfree( vbuf *vb );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2430 +void vbclear( vbuf *vb ); //ditch the data, keep the buffer
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2431 +void vbresize( vbuf *vb, size_t len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2432 +int vbavail( vbuf *vb );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2433 +void vbdump( vbuf *vb );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2434 +void vbgrow( vbuf *vb, size_t len ); // grow buffer by len bytes, data are preserved
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2435 +void vbset( vbuf *vb, void *data, size_t len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2436 +void vbskipws( vbuf *vb );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2437 +void vbappend( vbuf *vb, void *data, size_t length );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2438 +void vbskip( vbuf *vb, size_t skip );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2439 +void vboverwrite( vbuf *vbdest, vbuf *vbsrc );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2440 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2441 +// vstr functions
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2442 +vstr *vsalloc( size_t len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2443 +char *vsb( vstr *vs );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2444 +size_t vslen( vstr *vs ); //strlen
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2445 +void vsfree( vstr *vs );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2446 +void vsset( vstr *vs, char *s ); // Store string s in vb
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2447 +void vsnset( vstr *vs, char *s, size_t n ); // Store string s in vb
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2448 +void vsgrow( vstr *vs, size_t len ); // grow buffer by len bytes, data are preserved
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2449 +size_t vsavail( vstr *vs );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2450 +void vscat( vstr *vs, char *str );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2451 +void vsncat( vstr *vs, char *str, size_t len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2452 +void vsnprepend( vstr *vs, char *str, size_t len ) ;
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2453 +void vsskip( vstr *vs, size_t len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2454 +int vscmp( vstr *vs, char *str );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2455 +void vsskipws( vstr *vs );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2456 +void vs_printf( vstr *vs, char *fmt, ... );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2457 +void vs_printfa( vstr *vs, char *fmt, ... );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2458 +void vshexdump( vstr *vs, char *b, size_t start, size_t stop, int ascii );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2459 +int vscatprintf( vstr *vs, char *fmt, ... );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2460 +void vsvprintf( vstr *vs, char *fmt, va_list ap );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2461 +void vstrunc( vstr *vs, int off ); // Drop chars [off..dlen]
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2462 +int vslast( vstr *vs ); // returns the last character stored in a vstr string
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2463 +void vscharcat( vstr *vs, int ch );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2464 +int vsutf16( vstr *vs, vbuf *in ); //in: in=zero-terminated utf16; out: vs=utf8; returns: 0 on success, else on fail
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2465 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2466 +int vs_parse_escaped_string( vstr *vs, char *str, size_t len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2467 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2468 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2469 +/*
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2470 + * Windows unicode output trash - this stuff sucks
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2471 + * TODO: most of this should not be here
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2472 + */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2473 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2474 +void unicode_init();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2475 +void unicode_close();
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2476 +int utf16_write( FILE* stream, const void *buf, size_t count );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2477 +int utf16_fprintf( FILE* stream, const char *fmt, ... );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2478 +int utf16to8( char *inbuf_o, char *outbuf_o, int length );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2479 +int utf8to16( char *inbuf_o, int iblen, char *outbuf_o, int oblen);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2480 +int vb_utf8to16T( vbuf *bout, char *cin, int inlen );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2481 +int vb_utf16to8( vbuf *dest, char *buf, int len );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2482 +int iso8859_1to8( char *inbuf_o, char *outbuf_o, int length );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2483 +int utf8toascii( const char *inbuf_o, char *outbuf_o, int length );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2484 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2485 +/* dump ascii hex in windoze format */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2486 +void winhex(FILE* stream, unsigned char *hbuf, int start, int stop, int loff);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2487 +void winhex8(FILE *stream, unsigned char *hbuf, int start, int stop, int loff );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2488 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2489 +void vbwinhex8(vbuf *vb, unsigned char *hbuf, int start, int stop, int loff );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2490 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2491 +/* general search routine, find something in something else */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2492 +int find_in_buf(char *buf, char *what, int sz, int len, int start);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2493 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2494 +/* Get INTEGER from memory. This is probably low-endian specific? */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2495 +int get_int( char *array );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2496 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2497 +int find_nl( vstr *vs ); // find newline of type type in b
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2498 +int skip_nl( char *s ); // returns the width of the newline at s[0]
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2499 +//int vb_readline( struct varbuf *vb, int *ctype, FILE *in ); // read *AT LEAST* one full line of data from in
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2500 +int vb_skipline( struct varbuf *vb ); // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2501 +/* Get a string of HEX bytes (space separated),
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2502 + * or if first char is ' get an ASCII string instead. */
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2503 +int gethexorstr(char **c, char *wb);
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2504 +char *esc_index( char *s, int c ); // just like index(3), but works on strings with escape sequences
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2505 +char *esc_rindex( char *s, int c ); // just like rindex(3), but works on strings with escape sequences
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2506 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2507 +char *tok_esc_char( char *s, int *is_esc, int *c );
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2508 +int vb_path_token( vbuf *tok, char **path ); // returns things like TOK_EMPTY, TOK_ERROR, complete list at top
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2509 +
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2510 +int gettoken( char *tok, int len, char **path, char delim ); // Path tokenizer: increments path, dumps token in tok
de3753c3160a add archive directory with history of alioth versions that have been merged here
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2511 +#endif