comparison src/misc1.c @ 14133:352c2832d17f v8.1.0084

patch 8.1.0084: user name completion does not work on MS-Windows commit https://github.com/vim/vim/commit/828c3d70833a0689cc07581f2a67d06430675da5 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 19 18:58:07 2018 +0200 patch 8.1.0084: user name completion does not work on MS-Windows Problem: User name completion does not work on MS-Windows. Solution: Use NetUserEnum() to get user names. (Yasuhiro Matsumoto)
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Jun 2018 19:00:07 +0200
parents a039c93f5ff7
children 2ad722003b36
comparison
equal deleted inserted replaced
14132:0aeb4cc130cf 14133:352c2832d17f
11 * misc1.c: functions that didn't seem to fit elsewhere 11 * misc1.c: functions that didn't seem to fit elsewhere
12 */ 12 */
13 13
14 #include "vim.h" 14 #include "vim.h"
15 #include "version.h" 15 #include "version.h"
16
17 #if defined(FEAT_CMDL_COMPL) && defined(WIN3264)
18 # include <lm.h>
19 #endif
16 20
17 static char_u *vim_version_dir(char_u *vimdir); 21 static char_u *vim_version_dir(char_u *vimdir);
18 static char_u *remove_tail(char_u *p, char_u *pend, char_u *name); 22 static char_u *remove_tail(char_u *p, char_u *pend, char_u *name);
19 #if defined(FEAT_CMDL_COMPL) 23 #if defined(FEAT_CMDL_COMPL)
20 static void init_users(void); 24 static void init_users(void);
4600 if (user == NULL) 4604 if (user == NULL)
4601 break; 4605 break;
4602 ((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user; 4606 ((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user;
4603 } 4607 }
4604 endpwent(); 4608 endpwent();
4609 }
4610 # elif defined(WIN3264)
4611 {
4612 char_u* user;
4613 DWORD nusers = 0, ntotal = 0, i;
4614 PUSER_INFO_0 uinfo;
4615
4616 if (NetUserEnum(NULL, 0, 0, (LPBYTE *) &uinfo, MAX_PREFERRED_LENGTH,
4617 &nusers, &ntotal, NULL) == NERR_Success)
4618 {
4619 for (i = 0; i < nusers; i++)
4620 {
4621 if (ga_grow(&ga_users, 1) == FAIL)
4622 break;
4623 user = utf16_to_enc(uinfo[i].usri0_name, NULL);
4624 if (user == NULL)
4625 break;
4626 ((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user;
4627 }
4628
4629 NetApiBufferFree(uinfo);
4630 }
4605 } 4631 }
4606 # endif 4632 # endif
4607 } 4633 }
4608 4634
4609 /* 4635 /*