author | erik <erik> | 2007-01-24 19:46:19 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-24 19:46:19 (UTC) |
commit | a017bf21dd89159052f2f7a3fbc043a24956c08c (patch) (unidiff) | |
tree | 008be2b62ee5487dc55b8a7c7f043c94268f8362 /noncore | |
parent | a4a7bd22feb060a80e20c81cded43cc24f5cd423 (diff) | |
download | opie-a017bf21dd89159052f2f7a3fbc043a24956c08c.zip opie-a017bf21dd89159052f2f7a3fbc043a24956c08c.tar.gz opie-a017bf21dd89159052f2f7a3fbc043a24956c08c.tar.bz2 |
Every file in this commit has a memory leak of some kind or another. I think
all of them are minor and should not effect properly running code. But if I
were you I would give libstocks and the stockticker plugin in Today a wide
berth. That library is atrocious.
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/Excel.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 45 | ||||
-rw-r--r-- | noncore/comm/keypebble/vncauth.c | 6 | ||||
-rw-r--r-- | noncore/net/ftplib/ftplib.c | 4 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/csv.c | 106 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/currency.c | 1 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/lists.h | 1 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/stocks.c | 23 |
9 files changed, 140 insertions, 51 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 00141a3..45aa045 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp | |||
@@ -322,48 +322,49 @@ Bkmk* BkmkFile::read03(BkmkFile* /*_this*/, FILE* f) | |||
322 | delete [] anno; | 322 | delete [] anno; |
323 | } | 323 | } |
324 | } | 324 | } |
325 | return b; | 325 | return b; |
326 | } | 326 | } |
327 | 327 | ||
328 | Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) | 328 | Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) |
329 | { | 329 | { |
330 | Bkmk* b = NULL; | 330 | Bkmk* b = NULL; |
331 | if (f != NULL) | 331 | if (f != NULL) |
332 | { | 332 | { |
333 | unsigned short ln; | 333 | unsigned short ln; |
334 | if (fread(&ln,sizeof(ln),1,f) == 1) | 334 | if (fread(&ln,sizeof(ln),1,f) == 1) |
335 | { | 335 | { |
336 | tchar* nm = new tchar[ln+1]; | 336 | tchar* nm = new tchar[ln+1]; |
337 | fread(nm,sizeof(tchar),ln,f); | 337 | fread(nm,sizeof(tchar),ln,f); |
338 | nm[ln] = 0; | 338 | nm[ln] = 0; |
339 | fread(&ln,sizeof(ln),1,f); | 339 | fread(&ln,sizeof(ln),1,f); |
340 | tchar* anno = new tchar[ln+1]; | 340 | tchar* anno = new tchar[ln+1]; |
341 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); | 341 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); |
342 | anno[ln] = 0; | 342 | anno[ln] = 0; |
343 | unsigned int pos; | 343 | unsigned int pos; |
344 | fread(&pos,sizeof(pos),1,f); | 344 | fread(&pos,sizeof(pos),1,f); |
345 | b = new Bkmk(nm,anno,pos); | 345 | b = new Bkmk(nm,anno,pos); |
346 | delete [] anno; | ||
346 | } | 347 | } |
347 | } | 348 | } |
348 | return b; | 349 | return b; |
349 | } | 350 | } |
350 | 351 | ||
351 | Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f) | 352 | Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f) |
352 | { | 353 | { |
353 | Bkmk* b = NULL; | 354 | Bkmk* b = NULL; |
354 | if (f != NULL) | 355 | if (f != NULL) |
355 | { | 356 | { |
356 | unsigned short ln; | 357 | unsigned short ln; |
357 | if (fread(&ln,sizeof(ln),1,f) == 1) | 358 | if (fread(&ln,sizeof(ln),1,f) == 1) |
358 | { | 359 | { |
359 | b = new Bkmk; | 360 | b = new Bkmk; |
360 | b->m_namelen = ln; | 361 | b->m_namelen = ln; |
361 | b->m_name = new unsigned char[b->m_namelen]; | 362 | b->m_name = new unsigned char[b->m_namelen]; |
362 | fread(b->m_name,1,b->m_namelen,f); | 363 | fread(b->m_name,1,b->m_namelen,f); |
363 | 364 | ||
364 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); | 365 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); |
365 | if (b->m_annolen > 0) | 366 | if (b->m_annolen > 0) |
366 | { | 367 | { |
367 | b->m_anno = new unsigned char[b->m_annolen]; | 368 | b->m_anno = new unsigned char[b->m_annolen]; |
368 | fread(b->m_anno,1,b->m_annolen,f); | 369 | fread(b->m_anno,1,b->m_annolen,f); |
369 | } | 370 | } |
diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp index 51fe707..27080e9 100644 --- a/noncore/apps/opie-sheet/Excel.cpp +++ b/noncore/apps/opie-sheet/Excel.cpp | |||
@@ -356,49 +356,51 @@ ExcelBREC* ExcelBook::GetBREC(void) | |||
356 | rec= new ExcelBREC; | 356 | rec= new ExcelBREC; |
357 | if(FileEOF()) return NULL; | 357 | if(FileEOF()) return NULL; |
358 | rec->data=NULL; | 358 | rec->data=NULL; |
359 | rec->code=Get2Bytes(); | 359 | rec->code=Get2Bytes(); |
360 | rec->length=Get2Bytes(); | 360 | rec->length=Get2Bytes(); |
361 | rec->position=Position; | 361 | rec->position=Position; |
362 | SeekSkip(rec->length); | 362 | SeekSkip(rec->length); |
363 | return rec; | 363 | return rec; |
364 | }; | 364 | }; |
365 | 365 | ||
366 | ExcelBREC* ExcelBook::PeekBREC(void) | 366 | ExcelBREC* ExcelBook::PeekBREC(void) |
367 | { | 367 | { |
368 | int oldpos; | 368 | int oldpos; |
369 | ExcelBREC* NextRec; | 369 | ExcelBREC* NextRec; |
370 | oldpos=Position; | 370 | oldpos=Position; |
371 | NextRec=GetBREC(); | 371 | NextRec=GetBREC(); |
372 | SeekPosition(oldpos); | 372 | SeekPosition(oldpos); |
373 | return NextRec; | 373 | return NextRec; |
374 | }; | 374 | }; |
375 | 375 | ||
376 | char* ExcelBook::GetDataOfBREC(ExcelBREC* record) | 376 | char* ExcelBook::GetDataOfBREC(ExcelBREC* record) |
377 | { | 377 | { |
378 | if(record->data==NULL) | 378 | if(record->data==NULL) |
379 | { | 379 | { |
380 | ConvertCharToArray(record,Read(record->position,record->length),record->length); | 380 | char* readData = Read(record->position,record->length); |
381 | ConvertCharToArray(record,readData,record->length); | ||
382 | delete [] readData; | ||
381 | }; | 383 | }; |
382 | return record->data;//new? | 384 | return record->data;//new? |
383 | }; | 385 | }; |
384 | 386 | ||
385 | void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) | 387 | void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) |
386 | { | 388 | { |
387 | record->data=new char[length]; | 389 | record->data=new char[length]; |
388 | for(int w1=0;w1<=length-1;w1++) | 390 | for(int w1=0;w1<=length-1;w1++) |
389 | record->data[w1]=chars[w1]; | 391 | record->data[w1]=chars[w1]; |
390 | }; | 392 | }; |
391 | 393 | ||
392 | 394 | ||
393 | bool ExcelSheet::InitCells() | 395 | bool ExcelSheet::InitCells() |
394 | { | 396 | { |
395 | int r; | 397 | int r; |
396 | Cells.resize(rows * cols + cols+1); | 398 | Cells.resize(rows * cols + cols+1); |
397 | if(Cells.count()==0) return false; | 399 | if(Cells.count()==0) return false; |
398 | for(r=0;r < Cells.count();r++) | 400 | for(r=0;r < Cells.count();r++) |
399 | { | 401 | { |
400 | Cells[r]=NULL; | 402 | Cells[r]=NULL; |
401 | }; | 403 | }; |
402 | return true; | 404 | return true; |
403 | }; | 405 | }; |
404 | 406 | ||
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index f70f863..9c0c6ce 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -1751,105 +1751,111 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1751 | } | 1751 | } |
1752 | } | 1752 | } |
1753 | 1753 | ||
1754 | retval = loadFinalize(); | 1754 | retval = loadFinalize(); |
1755 | 1755 | ||
1756 | return true; | 1756 | return true; |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | int ZSafe::loadInit(const char* _filename, const char *password) | 1759 | int ZSafe::loadInit(const char* _filename, const char *password) |
1760 | { | 1760 | { |
1761 | unsigned int j = 0; | 1761 | unsigned int j = 0; |
1762 | unsigned int keylength=0; | 1762 | unsigned int keylength=0; |
1763 | int count=0, count2=0, count3=0; | 1763 | int count=0, count2=0, count3=0; |
1764 | unsigned char charbuf[8]; | 1764 | unsigned char charbuf[8]; |
1765 | unsigned short ciphertext[4]; | 1765 | unsigned short ciphertext[4]; |
1766 | char key[128]; | 1766 | char key[128]; |
1767 | Krc2* krc2 = new Krc2(); | 1767 | Krc2* krc2 = new Krc2(); |
1768 | 1768 | ||
1769 | fd = fopen (_filename, "rb"); | 1769 | fd = fopen (_filename, "rb"); |
1770 | 1770 | ||
1771 | QFileInfo f (_filename); | 1771 | QFileInfo f (_filename); |
1772 | load_buffer_length = f.size(); | 1772 | load_buffer_length = f.size(); |
1773 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; | 1773 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; |
1774 | 1774 | ||
1775 | if (fd == NULL) | 1775 | if (fd == NULL) { |
1776 | delete krc2; | ||
1776 | return PWERR_OPEN; | 1777 | return PWERR_OPEN; |
1778 | } | ||
1777 | 1779 | ||
1778 | buffer = (char *)malloc(load_buffer_length); | 1780 | buffer = (char *)malloc(load_buffer_length); |
1779 | for (j = 0; password[j] != '\0'; j++) { | 1781 | for (j = 0; password[j] != '\0'; j++) { |
1780 | key[j] = password[j]; | 1782 | key[j] = password[j]; |
1781 | } | 1783 | } |
1782 | keylength = j; | 1784 | keylength = j; |
1783 | krc2->rc2_expandkey (key, keylength, 128); | 1785 | krc2->rc2_expandkey (key, keylength, 128); |
1784 | 1786 | ||
1785 | #ifndef Q_WS_WIN | 1787 | #ifndef Q_WS_WIN |
1786 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); | 1788 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); |
1787 | #else | 1789 | #else |
1788 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 1790 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
1789 | #endif | 1791 | #endif |
1790 | 1792 | ||
1791 | if (size < 8) | 1793 | if (size < 8) { |
1794 | delete krc2; | ||
1792 | return PWERR_DATA; | 1795 | return PWERR_DATA; |
1796 | } | ||
1793 | 1797 | ||
1794 | for (count = 0; count < 4; count++) { | 1798 | for (count = 0; count < 4; count++) { |
1795 | count2 = count << 1; | 1799 | count2 = count << 1; |
1796 | iv[count] = charbuf[count2] << 8; | 1800 | iv[count] = charbuf[count2] << 8; |
1797 | iv[count] += charbuf[count2 + 1]; | 1801 | iv[count] += charbuf[count2 + 1]; |
1798 | } | 1802 | } |
1799 | 1803 | ||
1800 | size = 0; | 1804 | size = 0; |
1801 | bufferIndex = 0; | 1805 | bufferIndex = 0; |
1802 | #ifndef Q_WS_WIN | 1806 | #ifndef Q_WS_WIN |
1803 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { | 1807 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { |
1804 | while (count < 8) { | 1808 | while (count < 8) { |
1805 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); | 1809 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); |
1806 | #else | 1810 | #else |
1807 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { | 1811 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { |
1808 | while (count < 8) { | 1812 | while (count < 8) { |
1809 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 1813 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
1810 | #endif | 1814 | #endif |
1811 | if (count2 == 0) { | 1815 | if (count2 == 0) { |
1816 | delete krc2; | ||
1812 | return PWERR_DATA; | 1817 | return PWERR_DATA; |
1813 | } | 1818 | } |
1814 | count += count2; | 1819 | count += count2; |
1815 | } /* while (count < 8) */ | 1820 | } /* while (count < 8) */ |
1816 | 1821 | ||
1817 | size += 8; | 1822 | size += 8; |
1818 | for (count2 = 0; count2 < 8; count2 += 2) { | 1823 | for (count2 = 0; count2 < 8; count2 += 2) { |
1819 | count3 = count2 >> 1; | 1824 | count3 = count2 >> 1; |
1820 | ciphertext[count3] = charbuf[count2] << 8; | 1825 | ciphertext[count3] = charbuf[count2] << 8; |
1821 | ciphertext[count3] += charbuf[count2 + 1]; | 1826 | ciphertext[count3] += charbuf[count2 + 1]; |
1822 | 1827 | ||
1823 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; | 1828 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; |
1824 | iv[count3] = plaintext[count3]; | 1829 | iv[count3] = plaintext[count3]; |
1825 | } /* for (count2) */ | 1830 | } /* for (count2) */ |
1826 | 1831 | ||
1827 | krc2->rc2_decrypt (plaintext); | 1832 | krc2->rc2_decrypt (plaintext); |
1828 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); | 1833 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); |
1829 | bufferIndex += 8; | 1834 | bufferIndex += 8; |
1830 | buffer[bufferIndex + 1] = '\0'; | 1835 | buffer[bufferIndex + 1] = '\0'; |
1831 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ | 1836 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ |
1837 | delete krc2; | ||
1832 | size -= buffer[size - 1]; | 1838 | size -= buffer[size - 1]; |
1833 | lastcount = 0; | 1839 | lastcount = 0; |
1834 | 1840 | ||
1835 | /* This will point to the starting index */ | 1841 | /* This will point to the starting index */ |
1836 | bufferIndex = 0; | 1842 | bufferIndex = 0; |
1837 | return PWERR_GOOD; | 1843 | return PWERR_GOOD; |
1838 | } | 1844 | } |
1839 | 1845 | ||
1840 | int ZSafe::loadEntry(char *entry[FIELD_SIZE]) | 1846 | int ZSafe::loadEntry(char *entry[FIELD_SIZE]) |
1841 | { | 1847 | { |
1842 | /* Strip off PKCS 5 padding | 1848 | /* Strip off PKCS 5 padding |
1843 | * Should check to make sure it's good here | 1849 | * Should check to make sure it's good here |
1844 | */ | 1850 | */ |
1845 | int count, count1=0; | 1851 | int count, count1=0; |
1846 | 1852 | ||
1847 | for (count = lastcount; count < size; count++) { | 1853 | for (count = lastcount; count < size; count++) { |
1848 | if ((unsigned char) (buffer[count]) == 255) { | 1854 | if ((unsigned char) (buffer[count]) == 255) { |
1849 | if (buffer[bufferIndex] == '\0') { | 1855 | if (buffer[bufferIndex] == '\0') { |
1850 | bufferIndex++; | 1856 | bufferIndex++; |
1851 | } | 1857 | } |
1852 | entry[count1] = (char *) malloc (count - bufferIndex + 1); | 1858 | entry[count1] = (char *) malloc (count - bufferIndex + 1); |
1853 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); | 1859 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); |
1854 | entry[count1][count - bufferIndex] = '\0'; | 1860 | entry[count1][count - bufferIndex] = '\0'; |
1855 | count++; | 1861 | count++; |
@@ -2078,79 +2084,67 @@ void ZSafe::getDocPassword(QString title) | |||
2078 | 2084 | ||
2079 | dialog->PasswordField->setFocus(); | 2085 | dialog->PasswordField->setFocus(); |
2080 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); | 2086 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
2081 | 2087 | ||
2082 | QString password; | 2088 | QString password; |
2083 | if (result == QDialog::Accepted || newPwdDialogResult) | 2089 | if (result == QDialog::Accepted || newPwdDialogResult) |
2084 | { | 2090 | { |
2085 | m_password = dialog->PasswordField->text(); | 2091 | m_password = dialog->PasswordField->text(); |
2086 | } | 2092 | } |
2087 | else | 2093 | else |
2088 | { | 2094 | { |
2089 | exitZs (1); | 2095 | exitZs (1); |
2090 | } | 2096 | } |
2091 | } | 2097 | } |
2092 | 2098 | ||
2093 | int ZSafe::saveInit(const char *_filename, const char *password) | 2099 | int ZSafe::saveInit(const char *_filename, const char *password) |
2094 | { | 2100 | { |
2095 | char key[128]; | 2101 | char key[128]; |
2096 | unsigned int j = 0; | 2102 | unsigned int j = 0; |
2097 | unsigned int keylength; | 2103 | unsigned int keylength; |
2098 | // int val; | 2104 | // int val; |
2099 | int count2; | 2105 | int count2; |
2100 | Krc2* krc2 = new Krc2(); | 2106 | Krc2* krc2 = new Krc2(); |
2101 | 2107 | ||
2102 | /* first we should check the permissions of the filename */ | ||
2103 | /* | ||
2104 | if (QFile::exists(_filename)) { | ||
2105 | val = checkFile(_filename); | ||
2106 | if (val != PWERR_GOOD) | ||
2107 | return val; | ||
2108 | } else | ||
2109 | { | ||
2110 | val = creat (_filename, (S_IRUSR | S_IWUSR)); | ||
2111 | if (val == -1) | ||
2112 | return PWERR_OPEN; | ||
2113 | else | ||
2114 | close(val); | ||
2115 | } | ||
2116 | */ | ||
2117 | QFileInfo f (_filename); | 2108 | QFileInfo f (_filename); |
2118 | save_buffer_length = f.size(); | 2109 | save_buffer_length = f.size(); |
2119 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; | 2110 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; |
2120 | 2111 | ||
2121 | fd = fopen (_filename, "wb"); | 2112 | fd = fopen (_filename, "wb"); |
2122 | if (fd == NULL) | 2113 | if (fd == NULL) { |
2114 | delete krc2; | ||
2123 | return PWERR_OPEN; | 2115 | return PWERR_OPEN; |
2116 | } | ||
2124 | 2117 | ||
2125 | buffer = (char*)malloc(save_buffer_length); | 2118 | buffer = (char*)malloc(save_buffer_length); |
2126 | 2119 | ||
2127 | /* make the key ready */ | 2120 | /* make the key ready */ |
2128 | for (j = 0; password[j] != '\0'; j++) { | 2121 | for (j = 0; password[j] != '\0'; j++) { |
2129 | key[j] = password[j]; | 2122 | key[j] = password[j]; |
2130 | } | 2123 | } |
2131 | keylength = j; | 2124 | keylength = j; |
2132 | krc2->rc2_expandkey (key, keylength, 128); | 2125 | krc2->rc2_expandkey (key, keylength, 128); |
2126 | delete krc2; | ||
2133 | 2127 | ||
2134 | /* First, we make the IV */ | 2128 | /* First, we make the IV */ |
2135 | for (count2 = 0; count2 < 4; count2++) { | 2129 | for (count2 = 0; count2 < 4; count2++) { |
2136 | iv[count2] = rand (); | 2130 | iv[count2] = rand (); |
2137 | putc ((unsigned char) (iv[count2] >> 8), fd); | 2131 | putc ((unsigned char) (iv[count2] >> 8), fd); |
2138 | putc ((unsigned char) (iv[count2] & 0xff), fd); | 2132 | putc ((unsigned char) (iv[count2] & 0xff), fd); |
2139 | } | 2133 | } |
2140 | 2134 | ||
2141 | bufferIndex = 0; | 2135 | bufferIndex = 0; |
2142 | return PWERR_GOOD; | 2136 | return PWERR_GOOD; |
2143 | } | 2137 | } |
2144 | 2138 | ||
2145 | 2139 | ||
2146 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) | 2140 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) |
2147 | { | 2141 | { |
2148 | char *text1; | 2142 | char *text1; |
2149 | int count2, count3; | 2143 | int count2, count3; |
2150 | unsigned short ciphertext[4]; | 2144 | unsigned short ciphertext[4]; |
2151 | Krc2* krc2 = new Krc2(); | 2145 | Krc2* krc2 = new Krc2(); |
2152 | 2146 | ||
2153 | buffer = (char*)memset(buffer, '\0', save_buffer_length); | 2147 | buffer = (char*)memset(buffer, '\0', save_buffer_length); |
2154 | 2148 | ||
2155 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { | 2149 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { |
2156 | text1 = entry[count2]; | 2150 | text1 = entry[count2]; |
@@ -2167,88 +2161,95 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE]) | |||
2167 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. | 2161 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. |
2168 | * PKCS 5 padding (explained at the code section | 2162 | * PKCS 5 padding (explained at the code section |
2169 | */ | 2163 | */ |
2170 | while (count2 < (int)strlen (buffer)) { | 2164 | while (count2 < (int)strlen (buffer)) { |
2171 | #ifndef WORDS_BIGENDIAN | 2165 | #ifndef WORDS_BIGENDIAN |
2172 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; | 2166 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; |
2173 | plaintext[bufferIndex] += buffer[count2] & 0xff; | 2167 | plaintext[bufferIndex] += buffer[count2] & 0xff; |
2174 | #endif | 2168 | #endif |
2175 | #ifdef WORDS_BIGENDIAN | 2169 | #ifdef WORDS_BIGENDIAN |
2176 | plaintext[bufferIndex] = buffer[count2] << 8; | 2170 | plaintext[bufferIndex] = buffer[count2] << 8; |
2177 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; | 2171 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; |
2178 | #endif | 2172 | #endif |
2179 | bufferIndex++; | 2173 | bufferIndex++; |
2180 | if (bufferIndex == 4) { | 2174 | if (bufferIndex == 4) { |
2181 | krc2->rc2_encrypt (plaintext); | 2175 | krc2->rc2_encrypt (plaintext); |
2182 | 2176 | ||
2183 | for (count3 = 0; count3 < 4; count3++) { | 2177 | for (count3 = 0; count3 < 4; count3++) { |
2184 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; | 2178 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; |
2185 | 2179 | ||
2186 | /* Now store the ciphertext as the iv */ | 2180 | /* Now store the ciphertext as the iv */ |
2187 | iv[count3] = plaintext[count3]; | 2181 | iv[count3] = plaintext[count3]; |
2188 | 2182 | ||
2189 | /* reset the buffer index */ | 2183 | /* reset the buffer index */ |
2190 | bufferIndex = 0; | 2184 | bufferIndex = 0; |
2191 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; | 2185 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) { |
2192 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; | 2186 | delete krc2; |
2187 | return PWERR_DATA; | ||
2188 | } | ||
2189 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) { | ||
2190 | delete krc2; | ||
2191 | return PWERR_DATA; | ||
2192 | } | ||
2193 | } /*for (count3 = 0; count3 < 5; count3++)*/ | 2193 | } /*for (count3 = 0; count3 < 5; count3++)*/ |
2194 | } /*if (bufferIndex == 5)*/ | 2194 | } /*if (bufferIndex == 5)*/ |
2195 | /* increment a short, not a byte */ | 2195 | /* increment a short, not a byte */ |
2196 | count2 += 2; | 2196 | count2 += 2; |
2197 | } /*while (count2 < strlen (buffer))*/ | 2197 | } /*while (count2 < strlen (buffer))*/ |
2198 | int ret = PWERR_GOOD; | 2198 | delete krc2; |
2199 | return ret; | 2199 | return PWERR_GOOD; |
2200 | } | 2200 | } |
2201 | 2201 | ||
2202 | int ZSafe::saveFinalize(void) | 2202 | int ZSafe::saveFinalize(void) |
2203 | { | 2203 | { |
2204 | int count1, retval = PWERR_GOOD; | 2204 | int count1, retval = PWERR_GOOD; |
2205 | unsigned short ciphertext[4]; | 2205 | unsigned short ciphertext[4]; |
2206 | Krc2* krc2 = new Krc2(); | 2206 | Krc2* krc2 = new Krc2(); |
2207 | 2207 | ||
2208 | /* Tack on the PKCS 5 padding | 2208 | /* Tack on the PKCS 5 padding |
2209 | * How it works is we fill up the last n bytes with the value n | 2209 | * How it works is we fill up the last n bytes with the value n |
2210 | * | 2210 | * |
2211 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left | 2211 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left |
2212 | * over, leaving us 3 short, so we fill it in with 3's. | 2212 | * over, leaving us 3 short, so we fill it in with 3's. |
2213 | * | 2213 | * |
2214 | * If we come out even, we fill it with 8 8s | 2214 | * If we come out even, we fill it with 8 8s |
2215 | * | 2215 | * |
2216 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. | 2216 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. |
2217 | * so, half everything | 2217 | * so, half everything |
2218 | */ | 2218 | */ |
2219 | for (count1 = bufferIndex; count1 < 4; count1++) { | 2219 | for (count1 = bufferIndex; count1 < 4; count1++) { |
2220 | plaintext[count1] = (4 - bufferIndex); | 2220 | plaintext[count1] = (4 - bufferIndex); |
2221 | } | 2221 | } |
2222 | krc2->rc2_encrypt (plaintext); | 2222 | krc2->rc2_encrypt (plaintext); |
2223 | for (count1 = 0; count1 < 4; count1++) { | 2223 | for (count1 = 0; count1 < 4; count1++) { |
2224 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2224 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2225 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2225 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2226 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2226 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2227 | } | 2227 | } |
2228 | 2228 | ||
2229 | fclose (fd); | 2229 | fclose (fd); |
2230 | free(buffer); | 2230 | free(buffer); |
2231 | delete krc2; | ||
2231 | return retval; | 2232 | return retval; |
2232 | } | 2233 | } |
2233 | 2234 | ||
2234 | void ZSafe::quitMe () | 2235 | void ZSafe::quitMe () |
2235 | { | 2236 | { |
2236 | if (modified) | 2237 | if (modified) |
2237 | { | 2238 | { |
2238 | switch( QMessageBox::information( this, tr("ZSafe"), | 2239 | switch( QMessageBox::information( this, tr("ZSafe"), |
2239 | tr("Do you want to save\nbefore exiting?"), | 2240 | tr("Do you want to save\nbefore exiting?"), |
2240 | tr("&Save"), | 2241 | tr("&Save"), |
2241 | tr("S&ave with\nnew\npassword"), | 2242 | tr("S&ave with\nnew\npassword"), |
2242 | tr("&Don't Save"), | 2243 | tr("&Don't Save"), |
2243 | 0 // Enter == button 0 | 2244 | 0 // Enter == button 0 |
2244 | ) ) | 2245 | ) ) |
2245 | { // Escape == button 2 | 2246 | { // Escape == button 2 |
2246 | case 0: // Save clicked, Alt-S or Enter pressed. | 2247 | case 0: // Save clicked, Alt-S or Enter pressed. |
2247 | // save | 2248 | // save |
2248 | modified = false; | 2249 | modified = false; |
2249 | saveDocument(filename, FALSE); | 2250 | saveDocument(filename, FALSE); |
2250 | exitZs (1); | 2251 | exitZs (1); |
2251 | break; | 2252 | break; |
2252 | case 1: // | 2253 | case 1: // |
2253 | // Save with new password | 2254 | // Save with new password |
2254 | modified = false; | 2255 | modified = false; |
diff --git a/noncore/comm/keypebble/vncauth.c b/noncore/comm/keypebble/vncauth.c index 277d145..7de837a 100644 --- a/noncore/comm/keypebble/vncauth.c +++ b/noncore/comm/keypebble/vncauth.c | |||
@@ -73,54 +73,58 @@ vncEncryptAndStorePasswd(char *passwd, char *fname) | |||
73 | des(encryptedPasswd, encryptedPasswd); | 73 | des(encryptedPasswd, encryptedPasswd); |
74 | 74 | ||
75 | for (i = 0; i < 8; i++) { | 75 | for (i = 0; i < 8; i++) { |
76 | putc(encryptedPasswd[i], fp); | 76 | putc(encryptedPasswd[i], fp); |
77 | } | 77 | } |
78 | 78 | ||
79 | fclose(fp); | 79 | fclose(fp); |
80 | return 0; | 80 | return 0; |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | /* | 84 | /* |
85 | * Decrypt a password from a file. Returns a pointer to a newly allocated | 85 | * Decrypt a password from a file. Returns a pointer to a newly allocated |
86 | * string containing the password or a null pointer if the password could | 86 | * string containing the password or a null pointer if the password could |
87 | * not be retrieved for some reason. | 87 | * not be retrieved for some reason. |
88 | */ | 88 | */ |
89 | 89 | ||
90 | char * | 90 | char * |
91 | vncDecryptPasswdFromFile(char *fname) | 91 | vncDecryptPasswdFromFile(char *fname) |
92 | { | 92 | { |
93 | FILE *fp; | 93 | FILE *fp; |
94 | int i, ch; | 94 | int i, ch; |
95 | unsigned char *passwd = (unsigned char *)malloc(9); | 95 | unsigned char *passwd = (unsigned char *)malloc(9); |
96 | 96 | ||
97 | if ((fp = fopen(fname,"r")) == NULL) return NULL; | 97 | if ((fp = fopen(fname,"r")) == NULL) { |
98 | free(passwd); | ||
99 | return NULL; | ||
100 | } | ||
98 | 101 | ||
99 | for (i = 0; i < 8; i++) { | 102 | for (i = 0; i < 8; i++) { |
100 | ch = getc(fp); | 103 | ch = getc(fp); |
101 | if (ch == EOF) { | 104 | if (ch == EOF) { |
102 | fclose(fp); | 105 | fclose(fp); |
106 | free(passwd); | ||
103 | return NULL; | 107 | return NULL; |
104 | } | 108 | } |
105 | passwd[i] = ch; | 109 | passwd[i] = ch; |
106 | } | 110 | } |
107 | 111 | ||
108 | deskey(fixedkey, DE1); | 112 | deskey(fixedkey, DE1); |
109 | des(passwd, passwd); | 113 | des(passwd, passwd); |
110 | 114 | ||
111 | passwd[8] = 0; | 115 | passwd[8] = 0; |
112 | 116 | ||
113 | return (char *)passwd; | 117 | return (char *)passwd; |
114 | } | 118 | } |
115 | 119 | ||
116 | 120 | ||
117 | /* | 121 | /* |
118 | * Generate CHALLENGESIZE random bytes for use in challenge-response | 122 | * Generate CHALLENGESIZE random bytes for use in challenge-response |
119 | * authentication. | 123 | * authentication. |
120 | */ | 124 | */ |
121 | 125 | ||
122 | void | 126 | void |
123 | vncRandomBytes(unsigned char *bytes) | 127 | vncRandomBytes(unsigned char *bytes) |
124 | { | 128 | { |
125 | int i; | 129 | int i; |
126 | unsigned int seed = (unsigned int) time(0); | 130 | unsigned int seed = (unsigned int) time(0); |
diff --git a/noncore/net/ftplib/ftplib.c b/noncore/net/ftplib/ftplib.c index efcd6f0..addf9d2 100644 --- a/noncore/net/ftplib/ftplib.c +++ b/noncore/net/ftplib/ftplib.c | |||
@@ -1151,49 +1151,53 @@ static int FtpXfer(const char *localfile, const char *path, | |||
1151 | int l,c; | 1151 | int l,c; |
1152 | char *dbuf; | 1152 | char *dbuf; |
1153 | FILE *local = NULL; | 1153 | FILE *local = NULL; |
1154 | netbuf *nData; | 1154 | netbuf *nData; |
1155 | int rv=1; | 1155 | int rv=1; |
1156 | 1156 | ||
1157 | if (localfile != NULL) | 1157 | if (localfile != NULL) |
1158 | { | 1158 | { |
1159 | char ac[4] = "w"; | 1159 | char ac[4] = "w"; |
1160 | if (typ == FTPLIB_FILE_WRITE) | 1160 | if (typ == FTPLIB_FILE_WRITE) |
1161 | ac[0] = 'r'; | 1161 | ac[0] = 'r'; |
1162 | if (mode == FTPLIB_IMAGE) | 1162 | if (mode == FTPLIB_IMAGE) |
1163 | ac[1] = 'b'; | 1163 | ac[1] = 'b'; |
1164 | local = fopen(localfile, ac); | 1164 | local = fopen(localfile, ac); |
1165 | if (local == NULL) | 1165 | if (local == NULL) |
1166 | { | 1166 | { |
1167 | strncpy(nControl->response, strerror(errno), | 1167 | strncpy(nControl->response, strerror(errno), |
1168 | sizeof(nControl->response)); | 1168 | sizeof(nControl->response)); |
1169 | return 0; | 1169 | return 0; |
1170 | } | 1170 | } |
1171 | } | 1171 | } |
1172 | if (local == NULL) | 1172 | if (local == NULL) |
1173 | local = (typ == FTPLIB_FILE_WRITE) ? stdin : stdout; | 1173 | local = (typ == FTPLIB_FILE_WRITE) ? stdin : stdout; |
1174 | if (!FtpAccess(path, typ, mode, nControl, &nData)) | 1174 | if (!FtpAccess(path, typ, mode, nControl, &nData)) |
1175 | { | ||
1176 | if (localfile != NULL) | ||
1177 | fclose(local); | ||
1175 | return 0; | 1178 | return 0; |
1179 | } | ||
1176 | dbuf = malloc(FTPLIB_BUFSIZ); | 1180 | dbuf = malloc(FTPLIB_BUFSIZ); |
1177 | if (typ == FTPLIB_FILE_WRITE) | 1181 | if (typ == FTPLIB_FILE_WRITE) |
1178 | { | 1182 | { |
1179 | while ((l = fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0) | 1183 | while ((l = fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0) |
1180 | if ((c = FtpWrite(dbuf, l, nData)) < l) | 1184 | if ((c = FtpWrite(dbuf, l, nData)) < l) |
1181 | { | 1185 | { |
1182 | printf("short write: passed %d, wrote %d\n", l, c); | 1186 | printf("short write: passed %d, wrote %d\n", l, c); |
1183 | rv = 0; | 1187 | rv = 0; |
1184 | break; | 1188 | break; |
1185 | } | 1189 | } |
1186 | } | 1190 | } |
1187 | else | 1191 | else |
1188 | { | 1192 | { |
1189 | while ((l = FtpRead(dbuf, FTPLIB_BUFSIZ, nData)) > 0) | 1193 | while ((l = FtpRead(dbuf, FTPLIB_BUFSIZ, nData)) > 0) |
1190 | if (fwrite(dbuf, 1, l, local) <= 0) | 1194 | if (fwrite(dbuf, 1, l, local) <= 0) |
1191 | { | 1195 | { |
1192 | perror("localfile write"); | 1196 | perror("localfile write"); |
1193 | rv = 0; | 1197 | rv = 0; |
1194 | break; | 1198 | break; |
1195 | } | 1199 | } |
1196 | } | 1200 | } |
1197 | free(dbuf); | 1201 | free(dbuf); |
1198 | fflush(local); | 1202 | fflush(local); |
1199 | if (localfile != NULL) | 1203 | if (localfile != NULL) |
diff --git a/noncore/todayplugins/stockticker/libstocks/csv.c b/noncore/todayplugins/stockticker/libstocks/csv.c index 86d8607..110df7c 100644 --- a/noncore/todayplugins/stockticker/libstocks/csv.c +++ b/noncore/todayplugins/stockticker/libstocks/csv.c | |||
@@ -120,155 +120,199 @@ stock *parse_csv_file(char *csv) | |||
120 | { | 120 | { |
121 | *end_line = 0; | 121 | *end_line = 0; |
122 | 122 | ||
123 | /* Check if symbol valid */ | 123 | /* Check if symbol valid */ |
124 | /* if 1 "N/A" then ok because Indices have N/A for volume */ | 124 | /* if 1 "N/A" then ok because Indices have N/A for volume */ |
125 | /* if 4 "N/A" then ok because Mutual funds have */ | 125 | /* if 4 "N/A" then ok because Mutual funds have */ |
126 | /* if 5 "N/A" then ok because currencies have */ | 126 | /* if 5 "N/A" then ok because currencies have */ |
127 | /* So if >5 then stock not valid */ | 127 | /* So if >5 then stock not valid */ |
128 | 128 | ||
129 | test = line; | 129 | test = line; |
130 | valid = 0; | 130 | valid = 0; |
131 | while ( (test = strstr(test, "N/A")) ) | 131 | while ( (test = strstr(test, "N/A")) ) |
132 | { | 132 | { |
133 | valid ++; | 133 | valid ++; |
134 | test = test +3; | 134 | test = test +3; |
135 | } | 135 | } |
136 | 136 | ||
137 | if (valid < 6) | 137 | if (valid < 6) |
138 | { | 138 | { |
139 | /* This Symbol is valid */ | 139 | /* This Symbol is valid */ |
140 | 140 | ||
141 | StockPtr = malloc_stock(); | 141 | StockPtr = malloc_stock(); |
142 | 142 | ||
143 | ptr = csv_strtok(line, ","); | 143 | ptr = csv_strtok(line, ","); |
144 | if (!ptr) return 0; | 144 | if (!ptr) |
145 | { | ||
146 | free_stock(StockPtr); | ||
147 | return 0; | ||
148 | } | ||
145 | 149 | ||
146 | symbol = (char *)malloc(strlen(ptr)+1); | 150 | symbol = (char *)malloc(strlen(ptr)+1); |
147 | if (symbol==NULL) | 151 | if (symbol==NULL) |
148 | { | 152 | { |
149 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 153 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
150 | ,__FILE__, __LINE__); | 154 | ,__FILE__, __LINE__); |
151 | exit(1); | 155 | exit(1); |
152 | } | 156 | } |
153 | strcpy((char *)(symbol), ptr); | 157 | strcpy((char *)(symbol), ptr); |
154 | StockPtr->Symbol = symbol; | 158 | StockPtr->Symbol = symbol; |
155 | 159 | ||
156 | ptr = csv_strtok(NULL, ","); | 160 | ptr = csv_strtok(NULL, ","); |
157 | if (!ptr) return 0; | 161 | if (!ptr) |
162 | { | ||
163 | free_stock(StockPtr); | ||
164 | return 0; | ||
165 | } | ||
158 | 166 | ||
159 | name = (char *)malloc(strlen(ptr)+1); | 167 | name = (char *)malloc(strlen(ptr)+1); |
160 | if (name==NULL) | 168 | if (name==NULL) |
161 | { | 169 | { |
162 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 170 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
163 | ,__FILE__, __LINE__); | 171 | ,__FILE__, __LINE__); |
164 | exit(1); | 172 | exit(1); |
165 | } | 173 | } |
166 | strcpy((char *)(name), ptr); | 174 | strcpy((char *)(name), ptr); |
167 | StockPtr->Name = name; | 175 | StockPtr->Name = name; |
168 | 176 | ||
169 | ptr = csv_strtok(NULL, ","); | 177 | ptr = csv_strtok(NULL, ","); |
170 | if (!ptr) return 0; | 178 | if (!ptr) |
179 | { | ||
180 | free_stock(StockPtr); | ||
181 | return 0; | ||
182 | } | ||
171 | sscanf(ptr,"%f",&(StockPtr->CurrentPrice)); | 183 | sscanf(ptr,"%f",&(StockPtr->CurrentPrice)); |
172 | 184 | ||
173 | ptr = csv_strtok(NULL, ","); | 185 | ptr = csv_strtok(NULL, ","); |
174 | if (!ptr) return 0; | 186 | if (!ptr) |
187 | { | ||
188 | free_stock(StockPtr); | ||
189 | return 0; | ||
190 | } | ||
175 | 191 | ||
176 | date = (char *)malloc(strlen(ptr)+1); | 192 | date = (char *)malloc(strlen(ptr)+1); |
177 | if (date==NULL) | 193 | if (date==NULL) |
178 | { | 194 | { |
179 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 195 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
180 | ,__FILE__, __LINE__); | 196 | ,__FILE__, __LINE__); |
181 | exit(1); | 197 | exit(1); |
182 | } | 198 | } |
183 | strcpy((char *)(date), ptr); | 199 | strcpy((char *)(date), ptr); |
184 | StockPtr->Date = date; | 200 | StockPtr->Date = date; |
185 | 201 | ||
186 | ptr = csv_strtok(NULL, ","); | 202 | ptr = csv_strtok(NULL, ","); |
187 | if (!ptr) return 0; | 203 | if (!ptr) |
204 | { | ||
205 | free_stock(StockPtr); | ||
206 | return 0; | ||
207 | } | ||
188 | 208 | ||
189 | time = (char *)malloc(strlen(ptr)+1); | 209 | time = (char *)malloc(strlen(ptr)+1); |
190 | if (time==NULL) | 210 | if (time==NULL) |
191 | { | 211 | { |
192 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 212 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
193 | ,__FILE__, __LINE__); | 213 | ,__FILE__, __LINE__); |
194 | exit(1); | 214 | exit(1); |
195 | } | 215 | } |
196 | strcpy((char *)(time), ptr); | 216 | strcpy((char *)(time), ptr); |
197 | StockPtr->Time = time; | 217 | StockPtr->Time = time; |
198 | 218 | ||
199 | ptr = csv_strtok(NULL, ","); | 219 | ptr = csv_strtok(NULL, ","); |
200 | if (!ptr) return 0; | 220 | if (!ptr) |
221 | { | ||
222 | free_stock(StockPtr); | ||
223 | return 0; | ||
224 | } | ||
201 | sscanf(ptr,"%f",&(StockPtr->Variation)); | 225 | sscanf(ptr,"%f",&(StockPtr->Variation)); |
202 | 226 | ||
203 | StockPtr->Pourcentage = 100 * StockPtr->Variation / | 227 | StockPtr->Pourcentage = 100 * StockPtr->Variation / |
204 | (StockPtr->CurrentPrice - StockPtr->Variation); | 228 | (StockPtr->CurrentPrice - StockPtr->Variation); |
205 | 229 | ||
206 | StockPtr->LastPrice = StockPtr->CurrentPrice - StockPtr->Variation; | 230 | StockPtr->LastPrice = StockPtr->CurrentPrice - StockPtr->Variation; |
207 | 231 | ||
208 | ptr = csv_strtok(NULL, ","); | 232 | ptr = csv_strtok(NULL, ","); |
209 | if (!ptr) return 0; | 233 | if (!ptr) |
234 | { | ||
235 | free_stock(StockPtr); | ||
236 | return 0; | ||
237 | } | ||
210 | sscanf(ptr,"%f",&(StockPtr->OpenPrice)); | 238 | sscanf(ptr,"%f",&(StockPtr->OpenPrice)); |
211 | 239 | ||
212 | ptr = csv_strtok(NULL, ","); | 240 | ptr = csv_strtok(NULL, ","); |
213 | if (!ptr) return 0; | 241 | if (!ptr) |
242 | { | ||
243 | free_stock(StockPtr); | ||
244 | return 0; | ||
245 | } | ||
214 | sscanf(ptr,"%f",&(StockPtr->MaxPrice)); | 246 | sscanf(ptr,"%f",&(StockPtr->MaxPrice)); |
215 | 247 | ||
216 | ptr = csv_strtok(NULL, ","); | 248 | ptr = csv_strtok(NULL, ","); |
217 | if (!ptr) return 0; | 249 | if (!ptr) |
250 | { | ||
251 | free_stock(StockPtr); | ||
252 | return 0; | ||
253 | } | ||
218 | sscanf(ptr,"%f",&(StockPtr->MinPrice)); | 254 | sscanf(ptr,"%f",&(StockPtr->MinPrice)); |
219 | 255 | ||
220 | ptr = csv_strtok(NULL, ","); | 256 | ptr = csv_strtok(NULL, ","); |
221 | if (!ptr) return 0; | 257 | if (!ptr) |
258 | { | ||
259 | free_stock(StockPtr); | ||
260 | return 0; | ||
261 | } | ||
222 | StockPtr->Volume = atoi(ptr); | 262 | StockPtr->Volume = atoi(ptr); |
223 | 263 | ||
224 | if( !FirstStockPtr ) | 264 | if( !FirstStockPtr ) |
225 | { | 265 | { |
226 | FirstStockPtr = StockPtr; | 266 | FirstStockPtr = StockPtr; |
227 | StockPtr->PreviousStock = 0; | 267 | StockPtr->PreviousStock = 0; |
228 | } | 268 | } |
229 | 269 | ||
230 | StockPtr->NextStock = 0; | 270 | StockPtr->NextStock = 0; |
231 | 271 | ||
232 | if (LastStockPtr) | 272 | if (LastStockPtr) |
233 | { | 273 | { |
234 | LastStockPtr->NextStock = StockPtr; | 274 | LastStockPtr->NextStock = StockPtr; |
235 | StockPtr->PreviousStock = LastStockPtr; | 275 | StockPtr->PreviousStock = LastStockPtr; |
236 | } | 276 | } |
237 | 277 | ||
238 | LastStockPtr = StockPtr; | 278 | LastStockPtr = StockPtr; |
239 | 279 | ||
240 | } | 280 | } |
241 | else | 281 | else |
242 | { | 282 | { |
243 | /* this symbol is not valid */ | 283 | /* this symbol is not valid */ |
244 | /* Set the stock struct just with Symbol, all other are NULL */ | 284 | /* Set the stock struct just with Symbol, all other are NULL */ |
245 | /* This can be used to see if the symbol has been reached are not */ | 285 | /* This can be used to see if the symbol has been reached are not */ |
246 | 286 | ||
247 | StockPtr = malloc_stock(); | 287 | StockPtr = malloc_stock(); |
248 | 288 | ||
249 | ptr = csv_strtok(line, ","); | 289 | ptr = csv_strtok(line, ","); |
250 | if (!ptr) return 0; | 290 | if (!ptr) |
291 | { | ||
292 | free_stock(StockPtr); | ||
293 | return 0; | ||
294 | } | ||
251 | 295 | ||
252 | symbol = (char *)malloc(strlen(ptr)+1); | 296 | symbol = (char *)malloc(strlen(ptr)+1); |
253 | if (symbol==NULL) | 297 | if (symbol==NULL) |
254 | { | 298 | { |
255 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 299 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
256 | ,__FILE__, __LINE__); | 300 | ,__FILE__, __LINE__); |
257 | exit(1); | 301 | exit(1); |
258 | } | 302 | } |
259 | strcpy((char *)(symbol), ptr); | 303 | strcpy((char *)(symbol), ptr); |
260 | StockPtr->Symbol = symbol; | 304 | StockPtr->Symbol = symbol; |
261 | 305 | ||
262 | if( !FirstStockPtr ) | 306 | if( !FirstStockPtr ) |
263 | { | 307 | { |
264 | FirstStockPtr = StockPtr; | 308 | FirstStockPtr = StockPtr; |
265 | StockPtr->PreviousStock = 0; | 309 | StockPtr->PreviousStock = 0; |
266 | } | 310 | } |
267 | 311 | ||
268 | StockPtr->NextStock = 0; | 312 | StockPtr->NextStock = 0; |
269 | 313 | ||
270 | if (LastStockPtr) | 314 | if (LastStockPtr) |
271 | { | 315 | { |
272 | LastStockPtr->NextStock = StockPtr; | 316 | LastStockPtr->NextStock = StockPtr; |
273 | StockPtr->PreviousStock = LastStockPtr; | 317 | StockPtr->PreviousStock = LastStockPtr; |
274 | } | 318 | } |
@@ -307,90 +351,120 @@ stock *parse_csv_history_file(char *csv_file) | |||
307 | stock *StockPtr=NULL; | 351 | stock *StockPtr=NULL; |
308 | stock *LastStockPtr=NULL; | 352 | stock *LastStockPtr=NULL; |
309 | 353 | ||
310 | /* Used to return the pointer to the list */ | 354 | /* Used to return the pointer to the list */ |
311 | stock *FirstStockPtr=NULL; | 355 | stock *FirstStockPtr=NULL; |
312 | 356 | ||
313 | line = csv_file; | 357 | line = csv_file; |
314 | end_line = csv_file; | 358 | end_line = csv_file; |
315 | 359 | ||
316 | /* do not use the first line */ | 360 | /* do not use the first line */ |
317 | if (!(end_line = strstr(line, "\n"))) | 361 | if (!(end_line = strstr(line, "\n"))) |
318 | return 0; | 362 | return 0; |
319 | *end_line = 0; | 363 | *end_line = 0; |
320 | end_line++; | 364 | end_line++; |
321 | line = end_line; | 365 | line = end_line; |
322 | 366 | ||
323 | while ((end_line = strstr(line, "\n"))) | 367 | while ((end_line = strstr(line, "\n"))) |
324 | { | 368 | { |
325 | *end_line = 0; | 369 | *end_line = 0; |
326 | 370 | ||
327 | StockPtr = malloc_stock(); | 371 | StockPtr = malloc_stock(); |
328 | 372 | ||
329 | /* Date */ | 373 | /* Date */ |
330 | ptr = strtok(line, ","); | 374 | ptr = strtok(line, ","); |
331 | if (!ptr) return 0; | 375 | if (!ptr) |
376 | { | ||
377 | free_stock(StockPtr); | ||
378 | free_stock(FirstStockPtr); | ||
379 | free_stock(LastStockPtr); | ||
380 | return 0; | ||
381 | } | ||
332 | 382 | ||
333 | sscanf(ptr,"%d-%3s-%d",&day,smonth,&year); | 383 | sscanf(ptr,"%d-%3s-%d",&day,smonth,&year); |
334 | 384 | ||
335 | i=0; | 385 | i=0; |
336 | 386 | ||
337 | #ifdef __UNIX__ | 387 | #ifdef __UNIX__ |
338 | while((test=strcasecmp(months[i], smonth))) i++; | 388 | while((test=strcasecmp(months[i], smonth))) i++; |
339 | #elif __WINDOWS__ | 389 | #elif __WINDOWS__ |
340 | while(test=_mbsnbicmp(months[i], smonth, strlen(months[i]))) i++; | 390 | while(test=_mbsnbicmp(months[i], smonth, strlen(months[i]))) i++; |
341 | #endif | 391 | #endif |
342 | 392 | ||
343 | month = i+1; | 393 | month = i+1; |
344 | 394 | ||
345 | date = (char *)malloc(DATE_LENGTH); | 395 | date = (char *)malloc(DATE_LENGTH); |
346 | if (date==NULL) | 396 | if (date==NULL) |
347 | { | 397 | { |
348 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 398 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
349 | ,__FILE__, __LINE__); | 399 | ,__FILE__, __LINE__); |
350 | exit(1); | 400 | exit(1); |
351 | } | 401 | } |
352 | sprintf(date,"%.2d%.2d%.2d", year, month, day); | 402 | sprintf(date,"%.2d%.2d%.2d", year, month, day); |
353 | StockPtr->Date = date; | 403 | StockPtr->Date = date; |
354 | 404 | ||
355 | /* Open */ | 405 | /* Open */ |
356 | ptr = strtok(NULL, ","); | 406 | ptr = strtok(NULL, ","); |
357 | if (!ptr) return 0; | 407 | if (!ptr) |
408 | { | ||
409 | free_stock(StockPtr); | ||
410 | free_stock(FirstStockPtr); | ||
411 | free_stock(LastStockPtr); | ||
412 | return 0; | ||
413 | } | ||
358 | sscanf(ptr,"%f",&(StockPtr->OpenPrice)); | 414 | sscanf(ptr,"%f",&(StockPtr->OpenPrice)); |
359 | 415 | ||
360 | /* High */ | 416 | /* High */ |
361 | ptr = strtok(NULL, ","); | 417 | ptr = strtok(NULL, ","); |
362 | if (!ptr) return 0; | 418 | if (!ptr) |
419 | { | ||
420 | free_stock(StockPtr); | ||
421 | free_stock(FirstStockPtr); | ||
422 | free_stock(LastStockPtr); | ||
423 | return 0; | ||
424 | } | ||
363 | sscanf(ptr,"%f",&(StockPtr->MaxPrice)); | 425 | sscanf(ptr,"%f",&(StockPtr->MaxPrice)); |
364 | 426 | ||
365 | /* Low */ | 427 | /* Low */ |
366 | ptr = strtok(NULL, ","); | 428 | ptr = strtok(NULL, ","); |
367 | if (!ptr) return 0; | 429 | if (!ptr) |
430 | { | ||
431 | free_stock(StockPtr); | ||
432 | free_stock(FirstStockPtr); | ||
433 | free_stock(LastStockPtr); | ||
434 | return 0; | ||
435 | } | ||
368 | sscanf(ptr,"%f",&(StockPtr->MinPrice)); | 436 | sscanf(ptr,"%f",&(StockPtr->MinPrice)); |
369 | 437 | ||
370 | /* Close */ | 438 | /* Close */ |
371 | ptr = strtok(NULL, ","); | 439 | ptr = strtok(NULL, ","); |
372 | if (!ptr) return 0; | 440 | if (!ptr) |
441 | { | ||
442 | free_stock(StockPtr); | ||
443 | free_stock(FirstStockPtr); | ||
444 | free_stock(LastStockPtr); | ||
445 | return 0; | ||
446 | } | ||
373 | sscanf(ptr,"%f",&(StockPtr->LastPrice)); | 447 | sscanf(ptr,"%f",&(StockPtr->LastPrice)); |
374 | 448 | ||
375 | /* Volume */ | 449 | /* Volume */ |
376 | 450 | ||
377 | ptr = strtok(NULL, ","); | 451 | ptr = strtok(NULL, ","); |
378 | if (!ptr) | 452 | if (!ptr) |
379 | /* It seems to be an indice */ | 453 | /* It seems to be an indice */ |
380 | /* No volume for indices */ | 454 | /* No volume for indices */ |
381 | StockPtr->Volume = 0; | 455 | StockPtr->Volume = 0; |
382 | else | 456 | else |
383 | StockPtr->Volume = atoi(ptr); | 457 | StockPtr->Volume = atoi(ptr); |
384 | 458 | ||
385 | if( !FirstStockPtr ) | 459 | if( !FirstStockPtr ) |
386 | { | 460 | { |
387 | FirstStockPtr = StockPtr; | 461 | FirstStockPtr = StockPtr; |
388 | StockPtr->PreviousStock = 0; | 462 | StockPtr->PreviousStock = 0; |
389 | } | 463 | } |
390 | 464 | ||
391 | StockPtr->NextStock = 0; | 465 | StockPtr->NextStock = 0; |
392 | 466 | ||
393 | if (LastStockPtr) | 467 | if (LastStockPtr) |
394 | { | 468 | { |
395 | LastStockPtr->NextStock = StockPtr; | 469 | LastStockPtr->NextStock = StockPtr; |
396 | StockPtr->PreviousStock = LastStockPtr; | 470 | StockPtr->PreviousStock = LastStockPtr; |
diff --git a/noncore/todayplugins/stockticker/libstocks/currency.c b/noncore/todayplugins/stockticker/libstocks/currency.c index 9a08a9d..e0090e2 100644 --- a/noncore/todayplugins/stockticker/libstocks/currency.c +++ b/noncore/todayplugins/stockticker/libstocks/currency.c | |||
@@ -31,36 +31,37 @@ | |||
31 | /*****************************************************************************/ | 31 | /*****************************************************************************/ |
32 | /* returns the currency exchange rate of "from" currency into */ | 32 | /* returns the currency exchange rate of "from" currency into */ |
33 | /* "into" currency. */ | 33 | /* "into" currency. */ |
34 | /*****************************************************************************/ | 34 | /*****************************************************************************/ |
35 | libstocks_return_code get_currency_exchange(char *from, | 35 | libstocks_return_code get_currency_exchange(char *from, |
36 | char *into, | 36 | char *into, |
37 | float *exchange) | 37 | float *exchange) |
38 | { | 38 | { |
39 | char *symbol; | 39 | char *symbol; |
40 | stock *data; | 40 | stock *data; |
41 | libstocks_return_code error; | 41 | libstocks_return_code error; |
42 | 42 | ||
43 | if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL) | 43 | if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL) |
44 | { | 44 | { |
45 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 45 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
46 | ,__FILE__, __LINE__); | 46 | ,__FILE__, __LINE__); |
47 | exit(1); | 47 | exit(1); |
48 | } | 48 | } |
49 | 49 | ||
50 | strcpy(symbol, from); | 50 | strcpy(symbol, from); |
51 | strcat(symbol, into); | 51 | strcat(symbol, into); |
52 | strcat(symbol, "=X"); | 52 | strcat(symbol, "=X"); |
53 | 53 | ||
54 | error = get_stocks(symbol, &data); | 54 | error = get_stocks(symbol, &data); |
55 | free(symbol); | ||
55 | if (error) | 56 | if (error) |
56 | { | 57 | { |
57 | *exchange = 0; | 58 | *exchange = 0; |
58 | return(error); | 59 | return(error); |
59 | } | 60 | } |
60 | 61 | ||
61 | free_stocks(data); | 62 | free_stocks(data); |
62 | 63 | ||
63 | *exchange = data->CurrentPrice; | 64 | *exchange = data->CurrentPrice; |
64 | return(error); | 65 | return(error); |
65 | 66 | ||
66 | } | 67 | } |
diff --git a/noncore/todayplugins/stockticker/libstocks/lists.h b/noncore/todayplugins/stockticker/libstocks/lists.h index 0132317..a0eb434 100644 --- a/noncore/todayplugins/stockticker/libstocks/lists.h +++ b/noncore/todayplugins/stockticker/libstocks/lists.h | |||
@@ -9,27 +9,28 @@ | |||
9 | * | 9 | * |
10 | * This library is distributed in the hope that it will be useful, | 10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. | 13 | * Library General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU Library General Public | 15 | * You should have received a copy of the GNU Library General Public |
16 | * License along with this library; if not, write to the | 16 | * License along with this library; if not, write to the |
17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __LISTS_H__ | 21 | #ifndef __LISTS_H__ |
22 | #define __LISTS_H__ | 22 | #define __LISTS_H__ |
23 | 23 | ||
24 | #ifndef __LISTS_C__ | 24 | #ifndef __LISTS_C__ |
25 | #define PUBEXT_LISTS extern | 25 | #define PUBEXT_LISTS extern |
26 | #else | 26 | #else |
27 | #define PUBEXT_LISTS | 27 | #define PUBEXT_LISTS |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include "stocks.h" | 30 | #include "stocks.h" |
31 | 31 | ||
32 | PUBEXT_LISTS stock *malloc_stock(void); | 32 | PUBEXT_LISTS stock *malloc_stock(void); |
33 | PUBEXT_LISTS void free_stock(stock*); | ||
33 | 34 | ||
34 | 35 | ||
35 | #endif /* __LISTS_H */ | 36 | #endif /* __LISTS_H */ |
diff --git a/noncore/todayplugins/stockticker/libstocks/stocks.c b/noncore/todayplugins/stockticker/libstocks/stocks.c index eb04ba9..3a26a47 100644 --- a/noncore/todayplugins/stockticker/libstocks/stocks.c +++ b/noncore/todayplugins/stockticker/libstocks/stocks.c | |||
@@ -216,132 +216,133 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) | |||
216 | printf("*get_stocks\n"); | 216 | printf("*get_stocks\n"); |
217 | #endif | 217 | #endif |
218 | 218 | ||
219 | /* to preserve stocks */ | 219 | /* to preserve stocks */ |
220 | tok_ptr = malloc(strlen(stocks)+1); | 220 | tok_ptr = malloc(strlen(stocks)+1); |
221 | if(tok_ptr==NULL) | 221 | if(tok_ptr==NULL) |
222 | { | 222 | { |
223 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 223 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
224 | ,__FILE__, __LINE__); | 224 | ,__FILE__, __LINE__); |
225 | exit(1); | 225 | exit(1); |
226 | } | 226 | } |
227 | strcpy(tok_ptr, stocks); | 227 | strcpy(tok_ptr, stocks); |
228 | 228 | ||
229 | while( (symbol = strtok(tok_ptr, "+"))!=0) | 229 | while( (symbol = strtok(tok_ptr, "+"))!=0) |
230 | { | 230 | { |
231 | /* clear tok_ptr for next strtok */ | 231 | /* clear tok_ptr for next strtok */ |
232 | tok_ptr = NULL; | 232 | tok_ptr = NULL; |
233 | 233 | ||
234 | /* look for "." in the symbol */ | 234 | /* look for "." in the symbol */ |
235 | source = find_yahoo_source(symbol); | 235 | source = find_yahoo_source(symbol); |
236 | 236 | ||
237 | switch (source) | 237 | switch (source) |
238 | { | 238 | { |
239 | case YAHOO_US: | 239 | case YAHOO_US: |
240 | |||
241 | if (us_quotes) | 240 | if (us_quotes) |
242 | { | 241 | { |
243 | lgr_us_quotes = strlen(us_quotes); | 242 | lgr_us_quotes = strlen(us_quotes); |
244 | lgr_symbol = strlen(symbol); | 243 | lgr_symbol = strlen(symbol); |
245 | 244 | ||
246 | us_quotes_temp = malloc(lgr_us_quotes + lgr_symbol +2); | 245 | us_quotes_temp = malloc(lgr_us_quotes + lgr_symbol +2); |
247 | if(us_quotes_temp==NULL) | 246 | if(us_quotes_temp==NULL) |
248 | { | 247 | { |
249 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 248 | fprintf(stderr,"Memory allocating error (%s line %d)\n", |
250 | ,__FILE__, __LINE__); | 249 | __FILE__, __LINE__); |
251 | exit(1); | 250 | exit(1); |
252 | } | 251 | } |
253 | strcpy(us_quotes_temp, us_quotes); | 252 | strcpy(us_quotes_temp, us_quotes); |
254 | strcat(us_quotes_temp,"+"); | 253 | strcat(us_quotes_temp,"+"); |
255 | strcat(us_quotes_temp,symbol); | 254 | strcat(us_quotes_temp,symbol); |
256 | 255 | ||
257 | free(us_quotes); | 256 | free(us_quotes); |
258 | us_quotes = us_quotes_temp; | 257 | us_quotes = us_quotes_temp; |
259 | } | 258 | } |
260 | else | 259 | else |
261 | { | 260 | { |
262 | us_quotes = malloc(strlen(symbol)+1); | 261 | us_quotes = malloc(strlen(symbol)+1); |
263 | 262 | ||
264 | if(us_quotes==NULL) | 263 | if(us_quotes==NULL) |
265 | { | 264 | { |
266 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 265 | fprintf(stderr,"Memory allocating error (%s line %d)\n", |
267 | ,__FILE__, __LINE__); | 266 | __FILE__, __LINE__); |
268 | exit(1); | 267 | exit(1); |
269 | } | 268 | } |
270 | strcpy(us_quotes, symbol); | 269 | strcpy(us_quotes, symbol); |
271 | } | 270 | } |
272 | 271 | ||
273 | break; | 272 | break; |
274 | 273 | ||
275 | case YAHOO_EUROPE: | 274 | case YAHOO_EUROPE: |
276 | |||
277 | if (eu_quotes) | 275 | if (eu_quotes) |
278 | { | 276 | { |
279 | lgr_eu_quotes = strlen(eu_quotes); | 277 | lgr_eu_quotes = strlen(eu_quotes); |
280 | lgr_symbol = strlen(symbol); | 278 | lgr_symbol = strlen(symbol); |
281 | 279 | ||
282 | eu_quotes_temp = malloc(lgr_eu_quotes + lgr_symbol +2); | 280 | eu_quotes_temp = malloc(lgr_eu_quotes + lgr_symbol +2); |
283 | if(eu_quotes_temp==NULL) | 281 | if(eu_quotes_temp==NULL) |
284 | { | 282 | { |
285 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 283 | fprintf(stderr,"Memory allocating error (%s line %d)\n", |
286 | ,__FILE__, __LINE__); | 284 | __FILE__, __LINE__); |
287 | exit(1); | 285 | exit(1); |
288 | } | 286 | } |
289 | strcpy(eu_quotes_temp, eu_quotes); | 287 | strcpy(eu_quotes_temp, eu_quotes); |
290 | strcat(eu_quotes_temp, "+"); | 288 | strcat(eu_quotes_temp, "+"); |
291 | strcat(eu_quotes_temp, symbol); | 289 | strcat(eu_quotes_temp, symbol); |
292 | 290 | ||
293 | free(eu_quotes); | 291 | free(eu_quotes); |
294 | eu_quotes = eu_quotes_temp; | 292 | eu_quotes = eu_quotes_temp; |
295 | } | 293 | } |
296 | else | 294 | else |
297 | { | 295 | { |
298 | eu_quotes = malloc(strlen(symbol)+1); | 296 | eu_quotes = malloc(strlen(symbol)+1); |
299 | if(eu_quotes==NULL) | 297 | if(eu_quotes==NULL) |
300 | { | 298 | { |
301 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 299 | fprintf(stderr,"Memory allocating error (%s line %d)\n", |
302 | ,__FILE__, __LINE__); | 300 | __FILE__, __LINE__); |
303 | exit(1); | 301 | exit(1); |
304 | } | 302 | } |
305 | strcpy(eu_quotes, symbol); | 303 | strcpy(eu_quotes, symbol); |
306 | } | 304 | } |
307 | break; | 305 | break; |
308 | } | 306 | } |
309 | } | 307 | } |
310 | 308 | ||
311 | free(tok_ptr); | 309 | free(tok_ptr); |
312 | 310 | ||
313 | if (us_quotes) | 311 | if (us_quotes) |
314 | { | 312 | { |
315 | /* Gets us quotes */ | 313 | /* Gets us quotes */ |
316 | error = download_stocks(us_quotes, &stocks_tmp, YAHOO_US); | 314 | error = download_stocks(us_quotes, &stocks_tmp, YAHOO_US); |
315 | free(us_quotes); | ||
317 | if (error) return error; | 316 | if (error) return error; |
318 | } | 317 | } |
319 | 318 | ||
320 | if (eu_quotes) | 319 | if (eu_quotes) |
321 | { | 320 | { |
322 | /* Gets european quotes */ | 321 | /* Gets european quotes */ |
323 | error = download_stocks(eu_quotes, &stocks_getted, YAHOO_EUROPE); | 322 | error = download_stocks(eu_quotes, &stocks_getted, YAHOO_EUROPE); |
323 | free(eu_quotes); | ||
324 | if (error) return error; | 324 | if (error) return error; |
325 | 325 | ||
326 | /* concats lists if needed */ | 326 | /* concats lists if needed */ |
327 | if (stocks_tmp) | 327 | if (stocks_tmp) |
328 | { | 328 | { |
329 | stocks_tmp2 = stocks_tmp; | 329 | stocks_tmp2 = stocks_tmp; |
330 | 330 | ||
331 | while(stocks_tmp2 != NULL) | 331 | while(stocks_tmp2 != NULL) |
332 | { | 332 | { |
333 | last_stock = stocks_tmp2; | 333 | last_stock = stocks_tmp2; |
334 | stocks_tmp2 = next_stock(stocks_tmp2); | 334 | stocks_tmp2 = next_stock(stocks_tmp2); |
335 | } | 335 | } |
336 | 336 | ||
337 | last_stock->NextStock = stocks_getted; | 337 | last_stock->NextStock = stocks_getted; |
338 | stocks_getted->PreviousStock = last_stock; | 338 | stocks_getted->PreviousStock = last_stock; |
339 | 339 | ||
340 | } | 340 | } |
341 | else (stocks_tmp = stocks_getted); | 341 | else |
342 | (stocks_tmp = stocks_getted); | ||
342 | } | 343 | } |
343 | 344 | ||
344 | *stock_datas = stocks_tmp; | 345 | *stock_datas = stocks_tmp; |
345 | 346 | ||
346 | return(0); | 347 | return(0); |
347 | } | 348 | } |