author | erik <erik> | 2007-01-19 01:20:57 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-19 01:20:57 (UTC) |
commit | f60301bab1f8aa3693089036a3791a01ae6f9db8 (patch) (unidiff) | |
tree | 876aef9930a5f85762bcc17e0310921617a568da | |
parent | 32343107b30904806d02672955c57ed53d39fe79 (diff) | |
download | opie-f60301bab1f8aa3693089036a3791a01ae6f9db8.zip opie-f60301bab1f8aa3693089036a3791a01ae6f9db8.tar.gz opie-f60301bab1f8aa3693089036a3791a01ae6f9db8.tar.bz2 |
core/opie-login/loginwindowimpl.cpp has a fix to properly free strings
that were dup'ed.
noncore/apps/opie-reader/Bkmks.cpp deletes a temporary pointer that
was not being properly disposed of.
-rw-r--r-- | core/opie-login/loginwindowimpl.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 1 |
2 files changed, 22 insertions, 4 deletions
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index 547a9b3..b9a286d 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp | |||
@@ -100,160 +100,177 @@ LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_C | |||
100 | if ( !last. isEmpty ( )) | 100 | if ( !last. isEmpty ( )) |
101 | m_user-> setEditText ( last ); | 101 | m_user-> setEditText ( last ); |
102 | 102 | ||
103 | calcMaxWindowRect ( ); | 103 | calcMaxWindowRect ( ); |
104 | 104 | ||
105 | if ( PasswordDialogImpl::needDialog() ) | 105 | if ( PasswordDialogImpl::needDialog() ) |
106 | QTimer::singleShot(10, this, SLOT(showPasswordDialog()) ); | 106 | QTimer::singleShot(10, this, SLOT(showPasswordDialog()) ); |
107 | 107 | ||
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | LoginWindowImpl::~LoginWindowImpl ( ) | 111 | LoginWindowImpl::~LoginWindowImpl ( ) |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) | 116 | void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) |
117 | { | 117 | { |
118 | QDataStream stream ( data, IO_ReadOnly ); | 118 | QDataStream stream ( data, IO_ReadOnly ); |
119 | 119 | ||
120 | if ( msg == "hideInputMethod()" ) | 120 | if ( msg == "hideInputMethod()" ) |
121 | m_input-> hideInputMethod ( ); | 121 | m_input-> hideInputMethod ( ); |
122 | else if ( msg == "showInputMethod()" ) | 122 | else if ( msg == "showInputMethod()" ) |
123 | m_input-> showInputMethod ( ); | 123 | m_input-> showInputMethod ( ); |
124 | else if ( msg == "reloadInputMethods()" ) | 124 | else if ( msg == "reloadInputMethods()" ) |
125 | m_input-> loadInputMethods ( ); | 125 | m_input-> loadInputMethods ( ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void LoginWindowImpl::calcMaxWindowRect ( ) | 128 | void LoginWindowImpl::calcMaxWindowRect ( ) |
129 | { | 129 | { |
130 | #ifdef Q_WS_QWS | 130 | #ifdef Q_WS_QWS |
131 | QRect wr; | 131 | QRect wr; |
132 | int displayWidth = qApp-> desktop ( )-> width ( ); | 132 | int displayWidth = qApp-> desktop ( )-> width ( ); |
133 | QRect ir = m_input-> inputRect ( ); | 133 | QRect ir = m_input-> inputRect ( ); |
134 | if ( ir.isValid() ) | 134 | if ( ir.isValid() ) |
135 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 135 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
136 | else | 136 | else |
137 | wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); | 137 | wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); |
138 | 138 | ||
139 | #if QT_VERSION < 0x030000 | 139 | #if QT_VERSION < 0x030000 |
140 | wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 140 | wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
141 | #endif | 141 | #endif |
142 | 142 | ||
143 | QWSServer::setMaxWindowRect( wr ); | 143 | QWSServer::setMaxWindowRect( wr ); |
144 | #endif | 144 | #endif |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) | 148 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) |
149 | { | 149 | { |
150 | switch ( e-> key ( )) { | 150 | switch ( e-> key ( )) { |
151 | case HardKey_Suspend: suspend ( ); | 151 | case HardKey_Suspend: suspend ( ); |
152 | break; | 152 | break; |
153 | case HardKey_Backlight: backlight ( ); | 153 | case HardKey_Backlight: backlight ( ); |
154 | break; | 154 | break; |
155 | default: e-> ignore ( ); | 155 | default: e-> ignore ( ); |
156 | break; | 156 | break; |
157 | } | 157 | } |
158 | LoginWindow::keyPressEvent ( e ); | 158 | LoginWindow::keyPressEvent ( e ); |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void LoginWindowImpl::toggleEchoMode ( bool t ) | 162 | void LoginWindowImpl::toggleEchoMode ( bool t ) |
163 | { | 163 | { |
164 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); | 164 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); |
165 | } | 165 | } |
166 | 166 | ||
167 | void LoginWindowImpl::showIM ( ) | 167 | void LoginWindowImpl::showIM ( ) |
168 | { | 168 | { |
169 | m_input-> showInputMethod ( ); | 169 | m_input-> showInputMethod ( ); |
170 | } | 170 | } |
171 | 171 | ||
172 | void LoginWindowImpl::restart ( ) | 172 | void LoginWindowImpl::restart ( ) |
173 | { | 173 | { |
174 | qApp-> quit ( ); | 174 | qApp-> quit ( ); |
175 | } | 175 | } |
176 | 176 | ||
177 | void LoginWindowImpl::quit ( ) | 177 | void LoginWindowImpl::quit ( ) |
178 | { | 178 | { |
179 | lApp-> quitToConsole ( ); | 179 | lApp-> quitToConsole ( ); |
180 | } | 180 | } |
181 | 181 | ||
182 | void LoginWindowImpl::suspend ( ) | 182 | void LoginWindowImpl::suspend ( ) |
183 | { | 183 | { |
184 | ODevice::inst ( )-> suspend ( ); | 184 | ODevice::inst ( )-> suspend ( ); |
185 | 185 | ||
186 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 186 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
187 | e << -3; // Force on | 187 | e << -3; // Force on |
188 | } | 188 | } |
189 | 189 | ||
190 | void LoginWindowImpl::backlight ( ) | 190 | void LoginWindowImpl::backlight ( ) |
191 | { | 191 | { |
192 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 192 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
193 | e << -2; // toggle | 193 | e << -2; // toggle |
194 | } | 194 | } |
195 | 195 | ||
196 | class WaitLogo : public QLabel { | 196 | class WaitLogo : public QLabel { |
197 | public: | 197 | public: |
198 | WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) | 198 | WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) |
199 | { | 199 | { |
200 | setPixmap( Opie::Core::OResource::loadPixmap( "launcher/new_wait" ) ); | 200 | setPixmap( Opie::Core::OResource::loadPixmap( "launcher/new_wait" ) ); |
201 | setAlignment ( AlignCenter ); | 201 | setAlignment ( AlignCenter ); |
202 | move ( 0, 0 ); | 202 | move ( 0, 0 ); |
203 | resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); | 203 | resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); |
204 | 204 | ||
205 | m_visible = false; | 205 | m_visible = false; |
206 | show ( ); | 206 | show ( ); |
207 | } | 207 | } |
208 | 208 | ||
209 | virtual void showEvent ( QShowEvent *e ) | 209 | virtual void showEvent ( QShowEvent *e ) |
210 | { | 210 | { |
211 | QLabel::showEvent ( e ); | 211 | QLabel::showEvent ( e ); |
212 | m_visible = true; | 212 | m_visible = true; |
213 | } | 213 | } |
214 | 214 | ||
215 | virtual void paintEvent ( QPaintEvent *e ) | 215 | virtual void paintEvent ( QPaintEvent *e ) |
216 | { | 216 | { |
217 | QLabel::paintEvent ( e ); | 217 | QLabel::paintEvent ( e ); |
218 | if ( m_visible ) | 218 | if ( m_visible ) |
219 | qApp-> quit ( ); | 219 | qApp-> quit ( ); |
220 | } | 220 | } |
221 | 221 | ||
222 | private: | 222 | private: |
223 | bool m_visible; | 223 | bool m_visible; |
224 | }; | 224 | }; |
225 | 225 | ||
226 | void LoginWindowImpl::login ( ) | 226 | void LoginWindowImpl::login ( ) |
227 | { | 227 | { |
228 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); | 228 | char *const user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); |
229 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); | 229 | char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); |
230 | 230 | ||
231 | if ( !user || !user [0] ) | 231 | if ( !user ) { |
232 | if ( pass ) | ||
233 | free( pass ); | ||
232 | return; | 234 | return; |
233 | if ( !pass ) | 235 | } |
236 | if ( !user [0] ) { | ||
237 | free( user ); | ||
238 | if ( pass ) | ||
239 | free( pass ); | ||
240 | return; | ||
241 | } | ||
242 | bool passwordIsEmpty = false; | ||
243 | if ( !pass ) { | ||
244 | passwordIsEmpty = true; | ||
234 | pass = ""; | 245 | pass = ""; |
246 | } | ||
235 | 247 | ||
236 | if ( lApp-> checkPassword ( user, pass )) { | 248 | if ( lApp-> checkPassword ( user, pass )) { |
249 | if ( !passwordIsEmpty ) | ||
250 | free(pass); | ||
237 | Config cfg ( "opie-login" ); | 251 | Config cfg ( "opie-login" ); |
238 | cfg. setGroup ( "General" ); | 252 | cfg. setGroup ( "General" ); |
239 | cfg. writeEntry ( "LastLogin", user ); | 253 | cfg. writeEntry ( "LastLogin", user ); |
240 | cfg. write ( ); | 254 | cfg. write ( ); |
241 | 255 | ||
242 | lApp-> setLoginAs ( user ); | 256 | lApp-> setLoginAs ( user ); |
243 | 257 | ||
244 | // Draw a big wait icon, the image can be altered in later revisions | 258 | // Draw a big wait icon, the image can be altered in later revisions |
245 | m_input-> hideInputMethod ( ); | 259 | m_input-> hideInputMethod ( ); |
246 | new WaitLogo ( ); | 260 | new WaitLogo ( ); |
247 | // WaitLogo::showEvent() calls qApp-> quit() | 261 | // WaitLogo::showEvent() calls qApp-> quit() |
248 | } | 262 | } |
249 | else { | 263 | else { |
250 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); | 264 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); |
251 | m_password-> clear ( ); | 265 | m_password-> clear ( ); |
266 | free( user ); | ||
267 | if ( !passwordIsEmpty ) | ||
268 | free( pass ); | ||
252 | } | 269 | } |
253 | } | 270 | } |
254 | 271 | ||
255 | void LoginWindowImpl::showPasswordDialog() { | 272 | void LoginWindowImpl::showPasswordDialog() { |
256 | PasswordDialogImpl dia( this ); | 273 | PasswordDialogImpl dia( this ); |
257 | dia.showMaximized(); | 274 | dia.showMaximized(); |
258 | dia.exec(); | 275 | dia.exec(); |
259 | } | 276 | } |
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 28f6318..00141a3 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp | |||
@@ -194,222 +194,223 @@ BkmkFile::BkmkFile(const char *fnm, bool w, bool _x) | |||
194 | { | 194 | { |
195 | f = fopen(fnm, "wb"); | 195 | f = fopen(fnm, "wb"); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | f = fopen(fnm, "rb"); | 199 | f = fopen(fnm, "rb"); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | BkmkFile::~BkmkFile() | 203 | BkmkFile::~BkmkFile() |
204 | { | 204 | { |
205 | if (f != NULL) fclose(f); | 205 | if (f != NULL) fclose(f); |
206 | } | 206 | } |
207 | 207 | ||
208 | void BkmkFile::write(const Bkmk& b) | 208 | void BkmkFile::write(const Bkmk& b) |
209 | { | 209 | { |
210 | if (f != NULL) | 210 | if (f != NULL) |
211 | { | 211 | { |
212 | fwrite(&b.m_namelen, sizeof(b.m_namelen),1,f); | 212 | fwrite(&b.m_namelen, sizeof(b.m_namelen),1,f); |
213 | fwrite(b.m_name,1,b.m_namelen,f); | 213 | fwrite(b.m_name,1,b.m_namelen,f); |
214 | fwrite(&b.m_annolen, sizeof(b.m_annolen),1,f); | 214 | fwrite(&b.m_annolen, sizeof(b.m_annolen),1,f); |
215 | fwrite(b.m_anno,1,b.m_annolen,f); | 215 | fwrite(b.m_anno,1,b.m_annolen,f); |
216 | fwrite(&b.m_position,sizeof(b.m_position),1,f); | 216 | fwrite(&b.m_position,sizeof(b.m_position),1,f); |
217 | if (m_extras) | 217 | if (m_extras) |
218 | { | 218 | { |
219 | fwrite(&b.m_position2,sizeof(b.m_position2),1,f); | 219 | fwrite(&b.m_position2,sizeof(b.m_position2),1,f); |
220 | fwrite(&b.m_red,sizeof(b.m_red),1,f); | 220 | fwrite(&b.m_red,sizeof(b.m_red),1,f); |
221 | fwrite(&b.m_green,sizeof(b.m_green),1,f); | 221 | fwrite(&b.m_green,sizeof(b.m_green),1,f); |
222 | fwrite(&b.m_blue,sizeof(b.m_blue),1,f); | 222 | fwrite(&b.m_blue,sizeof(b.m_blue),1,f); |
223 | fwrite(&b.m_level,sizeof(b.m_level),1,f); | 223 | fwrite(&b.m_level,sizeof(b.m_level),1,f); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | void BkmkFile::write(CList<Bkmk>& bl) | 228 | void BkmkFile::write(CList<Bkmk>& bl) |
229 | { | 229 | { |
230 | if (f != NULL) | 230 | if (f != NULL) |
231 | { | 231 | { |
232 | fwrite(&magic, sizeof(magic), 1, f); | 232 | fwrite(&magic, sizeof(magic), 1, f); |
233 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) | 233 | for (CList<Bkmk>::iterator i = bl.begin(); i != bl.end(); i++) |
234 | { | 234 | { |
235 | write(*i); | 235 | write(*i); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | CList<Bkmk>* BkmkFile::readall() | 240 | CList<Bkmk>* BkmkFile::readall() |
241 | { | 241 | { |
242 | CList<Bkmk>* bl = NULL; | 242 | CList<Bkmk>* bl = NULL; |
243 | if (f != NULL) | 243 | if (f != NULL) |
244 | { | 244 | { |
245 | unsigned long newmagic; | 245 | unsigned long newmagic; |
246 | fread(&newmagic, sizeof(newmagic), 1, f); | 246 | fread(&newmagic, sizeof(newmagic), 1, f); |
247 | if ((newmagic & 0xffffff00) != (magic & 0xffffff00)) | 247 | if ((newmagic & 0xffffff00) != (magic & 0xffffff00)) |
248 | { | 248 | { |
249 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of " PROGNAME "\ndid you upgrade from?", "0_4*", "Any other version") == 0) | 249 | if (QMessageBox::warning(NULL, "Old bookmark file!", "Which version of " PROGNAME "\ndid you upgrade from?", "0_4*", "Any other version") == 0) |
250 | { | 250 | { |
251 | fseek(f,0,SEEK_SET); | 251 | fseek(f,0,SEEK_SET); |
252 | bl = readall00(&read05); | 252 | bl = readall00(&read05); |
253 | } | 253 | } |
254 | else | 254 | else |
255 | { | 255 | { |
256 | fseek(f,0,SEEK_SET); | 256 | fseek(f,0,SEEK_SET); |
257 | bl = readall00(&read03); | 257 | bl = readall00(&read03); |
258 | } | 258 | } |
259 | isUpgraded = true; | 259 | isUpgraded = true; |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | switch(newmagic & 0xff) | 263 | switch(newmagic & 0xff) |
264 | { | 264 | { |
265 | case 7: | 265 | case 7: |
266 | isUpgraded = false; | 266 | isUpgraded = false; |
267 | bl = readall00(read07); | 267 | bl = readall00(read07); |
268 | // qDebug("Correct version!"); | 268 | // qDebug("Correct version!"); |
269 | break; | 269 | break; |
270 | case 6: | 270 | case 6: |
271 | isUpgraded = true; | 271 | isUpgraded = true; |
272 | bl = readall00(read06); | 272 | bl = readall00(read06); |
273 | // qDebug("Correct version!"); | 273 | // qDebug("Correct version!"); |
274 | break; | 274 | break; |
275 | case 5: | 275 | case 5: |
276 | isUpgraded = true; | 276 | isUpgraded = true; |
277 | bl = readall00(read05); | 277 | bl = readall00(read05); |
278 | // qDebug("Known version!"); | 278 | // qDebug("Known version!"); |
279 | break; | 279 | break; |
280 | default: | 280 | default: |
281 | // qDebug("Unknown version!"); | 281 | // qDebug("Unknown version!"); |
282 | isUpgraded = true; | 282 | isUpgraded = true; |
283 | bl = readall00(read05); | 283 | bl = readall00(read05); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | } | 286 | } |
287 | return bl; | 287 | return bl; |
288 | } | 288 | } |
289 | 289 | ||
290 | CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(BkmkFile*, FILE*)) | 290 | CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(BkmkFile*, FILE*)) |
291 | { | 291 | { |
292 | CList<Bkmk>* bl = new CList<Bkmk>; | 292 | CList<Bkmk>* bl = new CList<Bkmk>; |
293 | while (1) | 293 | while (1) |
294 | { | 294 | { |
295 | Bkmk* b = (*readfn)(this, f); | 295 | Bkmk* b = (*readfn)(this, f); |
296 | if (b == NULL) break; | 296 | if (b == NULL) break; |
297 | bl->push_back(*b); | 297 | bl->push_back(*b); |
298 | delete b; | 298 | delete b; |
299 | } | 299 | } |
300 | return bl; | 300 | return bl; |
301 | } | 301 | } |
302 | 302 | ||
303 | Bkmk* BkmkFile::read03(BkmkFile* /*_this*/, FILE* f) | 303 | Bkmk* BkmkFile::read03(BkmkFile* /*_this*/, FILE* f) |
304 | { | 304 | { |
305 | Bkmk* b = NULL; | 305 | Bkmk* b = NULL; |
306 | if (f != NULL) | 306 | if (f != NULL) |
307 | { | 307 | { |
308 | unsigned short ln; | 308 | unsigned short ln; |
309 | if (fread(&ln,sizeof(ln),1,f) == 1) | 309 | if (fread(&ln,sizeof(ln),1,f) == 1) |
310 | { | 310 | { |
311 | tchar* name = new tchar[ln+1]; | 311 | tchar* name = new tchar[ln+1]; |
312 | fread(name,sizeof(tchar),ln,f); | 312 | fread(name,sizeof(tchar),ln,f); |
313 | name[ln] = 0; | 313 | name[ln] = 0; |
314 | 314 | ||
315 | ln = 0; | 315 | ln = 0; |
316 | tchar* anno = new tchar[ln+1]; | 316 | tchar* anno = new tchar[ln+1]; |
317 | anno[ln] = 0; | 317 | anno[ln] = 0; |
318 | 318 | ||
319 | unsigned int pos; | 319 | unsigned int pos; |
320 | fread(&pos,sizeof(pos),1,f); | 320 | fread(&pos,sizeof(pos),1,f); |
321 | b = new Bkmk(name,anno,pos); | 321 | b = new Bkmk(name,anno,pos); |
322 | delete [] anno; | ||
322 | } | 323 | } |
323 | } | 324 | } |
324 | return b; | 325 | return b; |
325 | } | 326 | } |
326 | 327 | ||
327 | Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) | 328 | Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) |
328 | { | 329 | { |
329 | Bkmk* b = NULL; | 330 | Bkmk* b = NULL; |
330 | if (f != NULL) | 331 | if (f != NULL) |
331 | { | 332 | { |
332 | unsigned short ln; | 333 | unsigned short ln; |
333 | if (fread(&ln,sizeof(ln),1,f) == 1) | 334 | if (fread(&ln,sizeof(ln),1,f) == 1) |
334 | { | 335 | { |
335 | tchar* nm = new tchar[ln+1]; | 336 | tchar* nm = new tchar[ln+1]; |
336 | fread(nm,sizeof(tchar),ln,f); | 337 | fread(nm,sizeof(tchar),ln,f); |
337 | nm[ln] = 0; | 338 | nm[ln] = 0; |
338 | fread(&ln,sizeof(ln),1,f); | 339 | fread(&ln,sizeof(ln),1,f); |
339 | tchar* anno = new tchar[ln+1]; | 340 | tchar* anno = new tchar[ln+1]; |
340 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); | 341 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); |
341 | anno[ln] = 0; | 342 | anno[ln] = 0; |
342 | unsigned int pos; | 343 | unsigned int pos; |
343 | fread(&pos,sizeof(pos),1,f); | 344 | fread(&pos,sizeof(pos),1,f); |
344 | b = new Bkmk(nm,anno,pos); | 345 | b = new Bkmk(nm,anno,pos); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | return b; | 348 | return b; |
348 | } | 349 | } |
349 | 350 | ||
350 | Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f) | 351 | Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f) |
351 | { | 352 | { |
352 | Bkmk* b = NULL; | 353 | Bkmk* b = NULL; |
353 | if (f != NULL) | 354 | if (f != NULL) |
354 | { | 355 | { |
355 | unsigned short ln; | 356 | unsigned short ln; |
356 | if (fread(&ln,sizeof(ln),1,f) == 1) | 357 | if (fread(&ln,sizeof(ln),1,f) == 1) |
357 | { | 358 | { |
358 | b = new Bkmk; | 359 | b = new Bkmk; |
359 | b->m_namelen = ln; | 360 | b->m_namelen = ln; |
360 | b->m_name = new unsigned char[b->m_namelen]; | 361 | b->m_name = new unsigned char[b->m_namelen]; |
361 | fread(b->m_name,1,b->m_namelen,f); | 362 | fread(b->m_name,1,b->m_namelen,f); |
362 | 363 | ||
363 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); | 364 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); |
364 | if (b->m_annolen > 0) | 365 | if (b->m_annolen > 0) |
365 | { | 366 | { |
366 | b->m_anno = new unsigned char[b->m_annolen]; | 367 | b->m_anno = new unsigned char[b->m_annolen]; |
367 | fread(b->m_anno,1,b->m_annolen,f); | 368 | fread(b->m_anno,1,b->m_annolen,f); |
368 | } | 369 | } |
369 | fread(&(b->m_position),sizeof(b->m_position),1,f); | 370 | fread(&(b->m_position),sizeof(b->m_position),1,f); |
370 | b->m_position2 = b->m_position+b->m_namelen-1; | 371 | b->m_position2 = b->m_position+b->m_namelen-1; |
371 | b->m_red = b->m_green = b->m_blue = 127; | 372 | b->m_red = b->m_green = b->m_blue = 127; |
372 | b->m_level = 0; | 373 | b->m_level = 0; |
373 | } | 374 | } |
374 | } | 375 | } |
375 | return b; | 376 | return b; |
376 | } | 377 | } |
377 | 378 | ||
378 | Bkmk* BkmkFile::read07(BkmkFile* _this, FILE* f) | 379 | Bkmk* BkmkFile::read07(BkmkFile* _this, FILE* f) |
379 | { | 380 | { |
380 | Bkmk* b = NULL; | 381 | Bkmk* b = NULL; |
381 | if (f != NULL) | 382 | if (f != NULL) |
382 | { | 383 | { |
383 | unsigned short ln; | 384 | unsigned short ln; |
384 | if (fread(&ln,sizeof(ln),1,f) == 1) | 385 | if (fread(&ln,sizeof(ln),1,f) == 1) |
385 | { | 386 | { |
386 | b = new Bkmk; | 387 | b = new Bkmk; |
387 | b->m_namelen = ln; | 388 | b->m_namelen = ln; |
388 | b->m_name = new unsigned char[b->m_namelen]; | 389 | b->m_name = new unsigned char[b->m_namelen]; |
389 | fread(b->m_name,1,b->m_namelen,f); | 390 | fread(b->m_name,1,b->m_namelen,f); |
390 | 391 | ||
391 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); | 392 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); |
392 | if (b->m_annolen > 0) | 393 | if (b->m_annolen > 0) |
393 | { | 394 | { |
394 | b->m_anno = new unsigned char[b->m_annolen]; | 395 | b->m_anno = new unsigned char[b->m_annolen]; |
395 | fread(b->m_anno,1,b->m_annolen,f); | 396 | fread(b->m_anno,1,b->m_annolen,f); |
396 | } | 397 | } |
397 | fread(&(b->m_position),sizeof(b->m_position),1,f); | 398 | fread(&(b->m_position),sizeof(b->m_position),1,f); |
398 | if (_this->m_extras) | 399 | if (_this->m_extras) |
399 | { | 400 | { |
400 | fread(&(b->m_position2),sizeof(b->m_position2),1,f); | 401 | fread(&(b->m_position2),sizeof(b->m_position2),1,f); |
401 | fread(&(b->m_red),sizeof(b->m_red),1,f); | 402 | fread(&(b->m_red),sizeof(b->m_red),1,f); |
402 | fread(&(b->m_green),sizeof(b->m_green),1,f); | 403 | fread(&(b->m_green),sizeof(b->m_green),1,f); |
403 | fread(&(b->m_blue),sizeof(b->m_blue),1,f); | 404 | fread(&(b->m_blue),sizeof(b->m_blue),1,f); |
404 | fread(&(b->m_level),sizeof(b->m_level),1,f); | 405 | fread(&(b->m_level),sizeof(b->m_level),1,f); |
405 | } | 406 | } |
406 | else | 407 | else |
407 | { | 408 | { |
408 | b->m_position2 = b->m_position; | 409 | b->m_position2 = b->m_position; |
409 | b->m_red = b->m_green = b->m_blue = 255; | 410 | b->m_red = b->m_green = b->m_blue = 255; |
410 | b->m_level = 0; | 411 | b->m_level = 0; |
411 | } | 412 | } |
412 | } | 413 | } |
413 | } | 414 | } |
414 | return b; | 415 | return b; |
415 | } | 416 | } |