Ticket #1463: filezilla_fzsftp_unicode.patch

File filezilla_fzsftp_unicode.patch, 16.3 KB (added by tommywu, 20 years ago)

let FzSFtp.exe work in unicode build

  • FzSFtp/NOISE.C

    diff -Nur source.p1/FzSFtp/NOISE.C source.p2/FzSFtp/NOISE.C
    old new  
    1818void noise_get_heavy(void (*func) (void *, int))
    1919{
    2020    HANDLE srch;
    21     WIN32_FIND_DATA finddata;
     21    WIN32_FIND_DATAA finddata;
    2222    char winpath[MAX_PATH + 3];
    2323
    24     GetWindowsDirectory(winpath, sizeof(winpath));
     24    GetWindowsDirectoryA(winpath, sizeof(winpath));
    2525    strcat(winpath, "\\*");
    26     srch = FindFirstFile(winpath, &finddata);
     26    srch = FindFirstFileA(winpath, &finddata);
    2727    if (srch != INVALID_HANDLE_VALUE) {
    2828    do {
    2929        func(&finddata, sizeof(finddata));
    30     } while (FindNextFile(srch, &finddata));
     30    } while (FindNextFileA(srch, &finddata));
    3131    FindClose(srch);
    3232    }
    3333
  • FzSFtp/PAGEANTC.C

    diff -Nur source.p1/FzSFtp/PAGEANTC.C source.p2/FzSFtp/PAGEANTC.C
    old new  
    1919int agent_exists(void)
    2020{
    2121    HWND hwnd;
    22     hwnd = FindWindow("Pageant", "Pageant");
     22    hwnd = FindWindowA("Pageant", "Pageant");
    2323    if (!hwnd)
    2424    return FALSE;
    2525    else
     
    8585    *out = NULL;
    8686    *outlen = 0;
    8787
    88     hwnd = FindWindow("Pageant", "Pageant");
     88    hwnd = FindWindowA("Pageant", "Pageant");
    8989    if (!hwnd)
    9090    return 1;              /* *out == NULL, so failure */
    9191    mapname = dupprintf("PageantRequest%08x", (unsigned)GetCurrentThreadId());
    92     filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
     92    filemap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
    9393                0, AGENT_MAX_MSGLEN, mapname);
    9494    if (!filemap)
    9595    return 1;              /* *out == NULL, so failure */
  • FzSFtp/PSFTP.C

    diff -Nur source.p1/FzSFtp/PSFTP.C source.p2/FzSFtp/PSFTP.C
    old new  
    391391    }
    392392
    393393    if (restart)
    394     fp = CreateFile(outfname, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
     394    fp = CreateFileA(outfname, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
    395395    else
    396     fp = CreateFile(outfname, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
     396    fp = CreateFileA(outfname, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
    397397
    398398    if (fp==INVALID_HANDLE_VALUE)
    399399    {
     
    508508    return 0;
    509509    }
    510510
    511     fp = CreateFile(localfile, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
     511    fp = CreateFileA(localfile, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
    512512    if (fp == INVALID_HANDLE_VALUE)
    513513    {
    514514    FzSFtpIpc_Error1("Unable to open %s", localfile);
     
    14151415
    14161416    if (!FzSFtpIpc_Init(lpCmdLine))
    14171417    {
    1418         MessageBox(0, "Error: You can't start FzSFtp directly. It can only by started from FileZilla when connecting to an SFTP server.", "FzSFtp Error", MB_OK);
     1418        MessageBoxA(0, "Error: You can't start FzSFtp directly. It can only by started from FileZilla when connecting to an SFTP server.", "FzSFtp Error", MB_OK);
    14191419        return 1;
    14201420    }
    14211421
  • FzSFtp/WINNET.C

    diff -Nur source.p1/FzSFtp/WINNET.C source.p2/FzSFtp/WINNET.C
    old new  
    679679    }
    680680
    681681    if (len>20480)
    682         MessageBox(0, "Error! Please get in contact with Tim.Kosse@gmx.de if this happens frequently.\r\nError: WINNET.C->try_send->len>20480", "Critical error!!!", MB_ICONSTOP);
     682        MessageBoxA(0, "Error! Please get in contact with Tim.Kosse@gmx.de if this happens frequently.\r\nError: WINNET.C->try_send->len>20480", "Critical error!!!", MB_ICONSTOP);
    683683    while (TRUE)
    684684    {
    685685        FzSFtpIpc_SendRequest(SFTP_DATAID_CTS_WRITE, len, data);
     
    959959      case FD_WRITE:
    960960    {
    961961        int bufsize_before, bufsize_after;
    962         MessageBox(0, "FD_WRITE", "FD_WRITE", MB_OK);
     962        MessageBoxA(0, "FD_WRITE", "FD_WRITE", MB_OK);
    963963        s->writable = 1;
    964964        bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
    965965        try_send(s);
  • FzSFtp/WINSTORE.C

    diff -Nur source.p1/FzSFtp/WINSTORE.C source.p2/FzSFtp/WINSTORE.C
    old new  
    7474    p = snewn(3 * strlen(sessionname) + 1, char);
    7575    mungestr(sessionname, p);
    7676
    77     ret = RegCreateKey(HKEY_CURRENT_USER, puttystr, &subkey1);
     77    // tommy
     78    ret = RegCreateKeyA(HKEY_CURRENT_USER, puttystr, &subkey1);
    7879    if (ret != ERROR_SUCCESS) {
    7980    sfree(p);
    8081        *errmsg = dupprintf("Unable to create registry key\n"
    8182                            "HKEY_CURRENT_USER%s", puttystr);
    8283    return NULL;
    8384    }
    84     ret = RegCreateKey(subkey1, p, &sesskey);
     85    ret = RegCreateKeyA(subkey1, p, &sesskey);
    8586    sfree(p);
    8687    RegCloseKey(subkey1);
    8788    if (ret != ERROR_SUCCESS) {
     
    9596void write_setting_s(void *handle, const char *key, const char *value)
    9697{
    9798    if (handle)
    98     RegSetValueEx((HKEY) handle, key, 0, REG_SZ, value,
     99    RegSetValueExA((HKEY) handle, key, 0, REG_SZ, value,
    99100              1 + strlen(value));
    100101}
    101102
    102103void write_setting_i(void *handle, const char *key, int value)
    103104{
    104105    if (handle)
    105     RegSetValueEx((HKEY) handle, key, 0, REG_DWORD,
     106    RegSetValueExA((HKEY) handle, key, 0, REG_DWORD,
    106107              (CONST BYTE *) & value, sizeof(value));
    107108}
    108109
     
    122123    p = snewn(3 * strlen(sessionname) + 1, char);
    123124    mungestr(sessionname, p);
    124125
    125     if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS) {
     126    if (RegOpenKeyA(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS) {
    126127    sesskey = NULL;
    127128    } else {
    128     if (RegOpenKey(subkey1, p, &sesskey) != ERROR_SUCCESS) {
     129    if (RegOpenKeyA(subkey1, p, &sesskey) != ERROR_SUCCESS) {
    129130        sesskey = NULL;
    130131    }
    131132    RegCloseKey(subkey1);
     
    142143    size = buflen;
    143144
    144145    if (!handle ||
    145     RegQueryValueEx((HKEY) handle, key, 0,
     146    RegQueryValueExA((HKEY) handle, key, 0,
    146147            &type, buffer, &size) != ERROR_SUCCESS ||
    147148    type != REG_SZ) return NULL;
    148149    else
     
    155156    size = sizeof(val);
    156157
    157158    if (!handle ||
    158     RegQueryValueEx((HKEY) handle, key, 0, &type,
     159    RegQueryValueExA((HKEY) handle, key, 0, &type,
    159160            (BYTE *) & val, &size) != ERROR_SUCCESS ||
    160161    size != sizeof(val) || type != REG_DWORD)
    161162    return defvalue;
     
    222223    HKEY subkey1;
    223224    char *p;
    224225
    225     if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS)
     226    if (RegOpenKeyA(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS)
    226227    return;
    227228
    228229    p = snewn(3 * strlen(sessionname) + 1, char);
    229230    mungestr(sessionname, p);
    230     RegDeleteKey(subkey1, p);
     231    RegDeleteKeyA(subkey1, p);
    231232    sfree(p);
    232233
    233234    RegCloseKey(subkey1);
     
    243244    struct enumsettings *ret;
    244245    HKEY key;
    245246
    246     if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &key) != ERROR_SUCCESS)
     247    if (RegOpenKeyA(HKEY_CURRENT_USER, puttystr, &key) != ERROR_SUCCESS)
    247248    return NULL;
    248249
    249250    ret = snew(struct enumsettings);
     
    260261    struct enumsettings *e = (struct enumsettings *) handle;
    261262    char *otherbuf;
    262263    otherbuf = snewn(3 * buflen, char);
    263     if (RegEnumKey(e->key, e->i++, otherbuf, 3 * buflen) == ERROR_SUCCESS) {
     264    if (RegEnumKeyA(e->key, e->i++, otherbuf, 3 * buflen) == ERROR_SUCCESS) {
    264265    unmungestr(otherbuf, buffer, buflen);
    265266    sfree(otherbuf);
    266267    return buffer;
     
    309310
    310311    hostkey_regname(regname, hostname, port, keytype);
    311312
    312     if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_POS "\\SshHostKeys",
     313    if (RegOpenKeyA(HKEY_CURRENT_USER, PUTTY_REG_POS "\\SshHostKeys",
    313314           &rkey) != ERROR_SUCCESS)
    314315    return 1;              /* key does not exist in registry */
    315316
    316317    readlen = len;
    317     ret = RegQueryValueEx(rkey, regname, NULL, &type, otherstr, &readlen);
     318    ret = RegQueryValueExA(rkey, regname, NULL, &type, otherstr, &readlen);
    318319
    319320    if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA &&
    320321    !strcmp(keytype, "rsa")) {
     
    326327    char *justhost = regname + 1 + strcspn(regname, ":");
    327328    char *oldstyle = snewn(len + 10, char); /* safety margin */
    328329    readlen = len;
    329     ret = RegQueryValueEx(rkey, justhost, NULL, &type,
     330    ret = RegQueryValueExA(rkey, justhost, NULL, &type,
    330331                  oldstyle, &readlen);
    331332
    332333    if (ret == ERROR_SUCCESS && type == REG_SZ) {
     
    373374         * wrong, and hyper-cautiously do nothing.
    374375         */
    375376        if (!strcmp(otherstr, key))
    376         RegSetValueEx(rkey, regname, 0, REG_SZ, otherstr,
     377        RegSetValueExA(rkey, regname, 0, REG_SZ, otherstr,
    377378                  strlen(otherstr) + 1);
    378379    }
    379380    }
     
    404405
    405406    hostkey_regname(regname, hostname, port, keytype);
    406407
    407     if (RegCreateKey(HKEY_CURRENT_USER, PUTTY_REG_POS "\\SshHostKeys",
     408    if (RegCreateKeyA(HKEY_CURRENT_USER, PUTTY_REG_POS "\\SshHostKeys",
    408409             &rkey) != ERROR_SUCCESS)
    409410    return;                /* key does not exist in registry */
    410     RegSetValueEx(rkey, regname, 0, REG_SZ, key, strlen(key) + 1);
     411    RegSetValueExA(rkey, regname, 0, REG_SZ, key, strlen(key) + 1);
    411412    RegCloseKey(rkey);
    412413}
    413414
     
    421422
    422423    size = sizeof(seedpath);
    423424
    424     if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_POS, &rkey) ==
     425    if (RegOpenKeyA(HKEY_CURRENT_USER, PUTTY_REG_POS, &rkey) ==
    425426    ERROR_SUCCESS) {
    426     int ret = RegQueryValueEx(rkey, "RandSeedFile",
     427    int ret = RegQueryValueExA(rkey, "RandSeedFile",
    427428                  0, &type, seedpath, &size);
    428429    if (ret != ERROR_SUCCESS || type != REG_SZ)
    429430        seedpath[0] = '\0';
     
    435436    int len, ret;
    436437
    437438    len =
    438         GetEnvironmentVariable("HOMEDRIVE", seedpath,
     439        GetEnvironmentVariableA("HOMEDRIVE", seedpath,
    439440                   sizeof(seedpath));
    440441    ret =
    441         GetEnvironmentVariable("HOMEPATH", seedpath + len,
     442        GetEnvironmentVariableA("HOMEPATH", seedpath + len,
    442443                   sizeof(seedpath) - len);
    443444    if (ret == 0) {            /* probably win95; store in \WINDOWS */
    444         GetWindowsDirectory(seedpath, sizeof(seedpath));
     445        GetWindowsDirectoryA(seedpath, sizeof(seedpath));
    445446        len = strlen(seedpath);
    446447    } else
    447448        len += ret;
     
    456457    if (!seedpath[0])
    457458    get_seedpath();
    458459
    459     seedf = CreateFile(seedpath, GENERIC_READ,
     460    seedf = CreateFileA(seedpath, GENERIC_READ,
    460461               FILE_SHARE_READ | FILE_SHARE_WRITE,
    461462               NULL, OPEN_EXISTING, 0, NULL);
    462463
     
    481482    if (!seedpath[0])
    482483    get_seedpath();
    483484
    484     seedf = CreateFile(seedpath, GENERIC_WRITE, 0,
     485    seedf = CreateFileA(seedpath, GENERIC_WRITE, 0,
    485486               NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    486487
    487488    if (seedf != INVALID_HANDLE_VALUE) {
     
    502503    HKEY subkey;
    503504
    504505    i = 0;
    505     while (RegEnumKey(key, i, name, sizeof(name)) == ERROR_SUCCESS) {
    506     if (RegOpenKey(key, name, &subkey) == ERROR_SUCCESS) {
     506    while (RegEnumKeyA(key, i, name, sizeof(name)) == ERROR_SUCCESS) {
     507    if (RegOpenKeyA(key, name, &subkey) == ERROR_SUCCESS) {
    507508        registry_recursive_remove(subkey);
    508509        RegCloseKey(subkey);
    509510    }
    510     RegDeleteKey(key, name);
     511    RegDeleteKeyA(key, name);
    511512    }
    512513}
    513514
     
    531532    /*
    532533     * Open the main PuTTY registry key and remove everything in it.
    533534     */
    534     if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_POS, &key) ==
     535    if (RegOpenKeyA(HKEY_CURRENT_USER, PUTTY_REG_POS, &key) ==
    535536    ERROR_SUCCESS) {
    536537    registry_recursive_remove(key);
    537538    RegCloseKey(key);
     
    541542     * we've done that, see if the parent key has any other
    542543     * children.
    543544     */
    544     if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_PARENT,
     545    if (RegOpenKeyA(HKEY_CURRENT_USER, PUTTY_REG_PARENT,
    545546           &key) == ERROR_SUCCESS) {
    546     RegDeleteKey(key, PUTTY_REG_PARENT_CHILD);
    547     ret = RegEnumKey(key, 0, name, sizeof(name));
     547    RegDeleteKeyA(key, PUTTY_REG_PARENT_CHILD);
     548    ret = RegEnumKeyA(key, 0, name, sizeof(name));
    548549    RegCloseKey(key);
    549550    /*
    550551     * If the parent key had no other children, we must delete
     
    552553     * key.
    553554     */
    554555    if (ret != ERROR_SUCCESS) {
    555         if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_GPARENT,
     556        if (RegOpenKeyA(HKEY_CURRENT_USER, PUTTY_REG_GPARENT,
    556557               &key) == ERROR_SUCCESS) {
    557         RegDeleteKey(key, PUTTY_REG_GPARENT_CHILD);
     558        RegDeleteKeyA(key, PUTTY_REG_GPARENT_CHILD);
    558559        RegCloseKey(key);
    559560        }
    560561    }
  • FzSFtp/winmisc.c

    diff -Nur source.p1/FzSFtp/winmisc.c source.p2/FzSFtp/winmisc.c
    old new  
    55#include <stdio.h>
    66#include <stdlib.h>
    77#include "putty.h"
    8 
     8#include <tchar.h>
    99OSVERSIONINFO osVersion;
    1010
    1111void platform_get_x11_auth(char *display, int *proto,
     
    4949    return NULL;
    5050
    5151    user = snewn(namelen, char);
    52     GetUserName(user, &namelen);
     52    GetUserNameA(user, &namelen);
    5353
    5454    return user;
    5555}
     
    7575    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    7676    wc.hbrBackground = (HBRUSH) (COLOR_BACKGROUND +1);
    7777    wc.lpszMenuName = NULL;
    78     wc.lpszClassName = "PuTTYConfigBox";
     78    wc.lpszClassName = _T("PuTTYConfigBox");
    7979    RegisterClass(&wc);
    8080
    8181    hwnd = CreateDialog(hinst, tmpl, hwndparent, lpDialogFunc);
  • FzSFtp/winsftp.c

    diff -Nur source.p1/FzSFtp/winsftp.c source.p2/FzSFtp/winsftp.c
    old new  
    135135{
    136136    char *ret = NULL;
    137137
    138     if (!SetCurrentDirectory(dir)) {
     138    if (!SetCurrentDirectoryA(dir)) {
    139139    LPVOID message;
    140140    int i;
    141141    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
     
    159159char *psftp_getcwd(void)
    160160{
    161161    char *ret = snewn(256, char);
    162     int len = GetCurrentDirectory(256, ret);
     162    int len = GetCurrentDirectoryA(256, ret);
    163163    if (len > 256)
    164164    ret = sresize(ret, len, char);
    165     GetCurrentDirectory(len, ret);
     165    GetCurrentDirectoryA(len, ret);
    166166    return ret;
    167167}
    168168
     
    181181    HANDLE h;
    182182    RFile *ret;
    183183
    184     h = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL,
     184    h = CreateFileA(name, GENERIC_READ, FILE_SHARE_READ, NULL,
    185185           OPEN_EXISTING, 0, 0);
    186186    if (h == INVALID_HANDLE_VALUE)
    187187    return NULL;
     
    229229    HANDLE h;
    230230    WFile *ret;
    231231
    232     h = CreateFile(name, GENERIC_WRITE, 0, NULL,
     232    h = CreateFileA(name, GENERIC_WRITE, 0, NULL,
    233233           CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
    234234    if (h == INVALID_HANDLE_VALUE)
    235235    return NULL;
     
    267267int file_type(char *name)
    268268{
    269269    DWORD attr;
    270     attr = GetFileAttributes(name);
     270    attr = GetFileAttributesA(name);
    271271    /* We know of no `weird' files under Windows. */
    272272    if (attr == (DWORD)-1)
    273273    return FILE_TYPE_NONEXISTENT;
     
    285285DirHandle *open_directory(char *name)
    286286{
    287287    HANDLE h;
    288     WIN32_FIND_DATA fdat;
     288    WIN32_FIND_DATAA fdat;
    289289    char *findfile;
    290290    DirHandle *ret;
    291291
    292292    /* To enumerate files in dir `foo', we search for `foo/*'. */
    293293    findfile = dupcat(name, "/*", NULL);
    294     h = FindFirstFile(findfile, &fdat);
     294    h = FindFirstFileA(findfile, &fdat);
    295295    if (h == INVALID_HANDLE_VALUE)
    296296    return NULL;
    297297    sfree(findfile);
     
    305305char *read_filename(DirHandle *dir)
    306306{
    307307    while (!dir->name) {
    308     WIN32_FIND_DATA fdat;
    309     int ok = FindNextFile(dir->h, &fdat);
     308    WIN32_FIND_DATAA fdat;
     309    int ok = FindNextFileA(dir->h, &fdat);
    310310
    311311    if (!ok)
    312312        return NULL;
     
    338338int test_wildcard(char *name, int cmdline)
    339339{
    340340    HANDLE fh;
    341     WIN32_FIND_DATA fdat;
     341    WIN32_FIND_DATAA fdat;
    342342
    343343    /* First see if the exact name exists. */
    344     if (GetFileAttributes(name) != (DWORD)-1)
     344    if (GetFileAttributesA(name) != (DWORD)-1)
    345345    return WCTYPE_FILENAME;
    346346
    347347    /* Otherwise see if a wildcard match finds anything. */
    348     fh = FindFirstFile(name, &fdat);
     348    fh = FindFirstFileA(name, &fdat);
    349349    if (fh == INVALID_HANDLE_VALUE)
    350350    return WCTYPE_NONEXISTENT;
    351351
     
    386386WildcardMatcher *begin_wildcard_matching(char *name)
    387387{
    388388    HANDLE h;
    389     WIN32_FIND_DATA fdat;
     389    WIN32_FIND_DATAA fdat;
    390390    WildcardMatcher *ret;
    391391    char *last;
    392392
    393     h = FindFirstFile(name, &fdat);
     393    h = FindFirstFileA(name, &fdat);
    394394    if (h == INVALID_HANDLE_VALUE)
    395395    return NULL;
    396396
     
    445445
    446446int create_directory(char *name)
    447447{
    448     return CreateDirectory(name, NULL) != 0;
     448    return CreateDirectoryA(name, NULL) != 0;
    449449}
    450450
    451451char *dir_file_cat(char *dir, char *file)