diff options
author | Norbert Preining <norbert@preining.info> | 2020-09-20 03:03:26 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-09-20 03:03:26 +0000 |
commit | 1f457376b478257b88d4a857f5ec1b6155442dd7 (patch) | |
tree | 2a06a60551dea362cf8cb0cb0ba66c78608717c4 /support/dktools/dkwt-to.c | |
parent | ac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff) |
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/dkwt-to.c')
-rw-r--r-- | support/dktools/dkwt-to.c | 198 |
1 files changed, 113 insertions, 85 deletions
diff --git a/support/dktools/dkwt-to.c b/support/dktools/dkwt-to.c index 1bec540ace..5cb2cb11cf 100644 --- a/support/dktools/dkwt-to.c +++ b/support/dktools/dkwt-to.c @@ -1,36 +1,14 @@ /* - WARNING: This file was generated by dkct. - Changes you make here will be lost if dkct is run again! - You should modify the original source and run dkct on it. - Original source: dkwt-to.ctr +Copyright (C) 2011-2020, Dirk Krause +SPDX-License-Identifier: BSD-3-Clause */ /* -Copyright (C) 2011-2017, Dirk Krause - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above opyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. -* Neither the name of the author nor the names of contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + WARNING: This file was generated by the dkct program (see + http://dktools.sourceforge.net/ for details). + Changes you make here will be lost if dkct is run again! + You should modify the original source and run dkct on it. + Original source: dkwt-to.ctr */ /** @file dkwt-to.c The dkwt-to module. @@ -281,24 +259,28 @@ dkwt_tool_open_account_list(dk3_app_t *app, int f_long) DWORD dwPreferredLength = MAX_PREFERRED_LENGTH; DWORD dwFilter = 0; /* FILTER_NORMAL_ACCOUNT */ DWORD i = 0; - LPTSTR pStringSid; +#if DK3_CHAR_SIZE > 1 + LPWSTR pStringSid; +#else + LPASTR pStringSid; +#endif -#line 241 "dkwt-to.ctr" +#line 245 "dkwt-to.ctr" back = dk3_new_app(dkwt_account_list_t,1,app); if(back) { -#line 243 "dkwt-to.ctr" +#line 247 "dkwt-to.ctr" back->s_acc = NULL; back->i_acc = NULL; back->s_acc = dk3sto_open_app(app); if(back->s_acc) { -#line 246 "dkwt-to.ctr" +#line 250 "dkwt-to.ctr" dk3sto_set_comp(back->s_acc, dkwt_tool_compare_accounts, 0); back->i_acc = dk3sto_it_open(back->s_acc); if(back->i_acc) { -#line 249 "dkwt-to.ctr" +#line 253 "dkwt-to.ctr" ok = 1; do { pBuf = NULL; @@ -312,50 +294,51 @@ dkwt_tool_open_account_list(dk3_app_t *app, int f_long) &dwEntriesRead, &dwTotalEntries, &dwResumeHandle - ); + ); + -#line 263 "dkwt-to.ctr" +#line 268 "dkwt-to.ctr" if((NERR_Success == nStatus) || (ERROR_MORE_DATA == nStatus)) { -#line 265 "dkwt-to.ctr" +#line 270 "dkwt-to.ctr" if(pBuf != NULL) { -#line 266 "dkwt-to.ctr" +#line 271 "dkwt-to.ctr" pTmpBuf = pBuf; for(i = 0; i < dwEntriesRead; i++) { -#line 269 "dkwt-to.ctr" +#line 274 "dkwt-to.ctr" if(pTmpBuf->usri0_name) { -#line 270 "dkwt-to.ctr" +#line 275 "dkwt-to.ctr" ap = dkwt_tool_open_account(pTmpBuf->usri0_name, app); if(ap) { -#line 272 "dkwt-to.ctr" +#line 277 "dkwt-to.ctr" if(!dk3sto_add(back->s_acc, (void *)ap)) { ok = 0; dkwt_tool_close_account(ap); } } else { -#line 277 "dkwt-to.ctr" +#line 282 "dkwt-to.ctr" ok = 0; } } else { -#line 280 "dkwt-to.ctr" +#line 285 "dkwt-to.ctr" } pTmpBuf++; } } else { -#line 284 "dkwt-to.ctr" +#line 289 "dkwt-to.ctr" } } else { -#line 286 "dkwt-to.ctr" +#line 291 "dkwt-to.ctr" } if(pBuf != NULL) { NetApiBufferFree(pBuf); @@ -370,12 +353,14 @@ dkwt_tool_open_account_list(dk3_app_t *app, int f_long) dk3sto_it_reset(back->i_acc); while((ap = (dkwt_account_t *)dk3sto_it_next(back->i_acc)) != NULL) { pb4 = NULL; - nStatus = NetUserGetInfo(NULL, ap->logname, (DWORD)4, (LPBYTE *)(&pb4)); + nStatus = NetUserGetInfo( + NULL, ap->logname, (DWORD)4, (LPBYTE *)(&pb4) + ); if(NERR_Success == nStatus) { if(pb4) { -#line 304 "dkwt-to.ctr" +#line 311 "dkwt-to.ctr" ap->f_long = 1; ap->priv = pb4->usri4_priv; ap->flags = pb4->usri4_flags; @@ -384,7 +369,7 @@ dkwt_tool_open_account_list(dk3_app_t *app, int f_long) ap->codepage = pb4->usri4_code_page; if(pb4->usri4_full_name) { -#line 311 "dkwt-to.ctr" +#line 318 "dkwt-to.ctr" ap->fullname = dk3str_dup_app(pb4->usri4_full_name, app); if(!(ap->fullname)) { ok = 0; @@ -392,7 +377,7 @@ dkwt_tool_open_account_list(dk3_app_t *app, int f_long) } if(pb4->usri4_comment) { -#line 317 "dkwt-to.ctr" +#line 324 "dkwt-to.ctr" ap->comment = dk3str_dup_app(pb4->usri4_comment, app); if(!(ap->comment)) { ok = 0; @@ -418,9 +403,13 @@ dkwt_tool_open_account_list(dk3_app_t *app, int f_long) } if(pb4->usri4_user_sid) { -#line 341 "dkwt-to.ctr" +#line 348 "dkwt-to.ctr" pStringSid = NULL; - if(ConvertSidToStringSid(pb4->usri4_user_sid, &pStringSid)) +#if DK3_CHAR_SIZE > 1 + if(ConvertSidToStringSidW(pb4->usri4_user_sid, &pStringSid)) +#else + if(ConvertSidToStringSidA(pb4->usri4_user_sid, &pStringSid)) +#endif { if(pStringSid) { ap->textsid = dk3str_dup_app(pStringSid, app); @@ -434,11 +423,11 @@ dkwt_tool_open_account_list(dk3_app_t *app, int f_long) } } else { -#line 355 "dkwt-to.ctr" +#line 366 "dkwt-to.ctr" } } else { -#line 357 "dkwt-to.ctr" +#line 368 "dkwt-to.ctr" } if(pb4) { NetApiBufferFree(pb4); @@ -448,21 +437,21 @@ dkwt_tool_open_account_list(dk3_app_t *app, int f_long) } } else { -#line 365 "dkwt-to.ctr" +#line 376 "dkwt-to.ctr" } } else { -#line 367 "dkwt-to.ctr" +#line 378 "dkwt-to.ctr" } if(!ok) { dkwt_tool_close_account_list(back); back = NULL; } } else { -#line 372 "dkwt-to.ctr" +#line 383 "dkwt-to.ctr" } -#line 373 "dkwt-to.ctr" +#line 384 "dkwt-to.ctr" return back; } @@ -494,6 +483,8 @@ dkwt_tool_get_account_from_list(dkwt_account_list_t *lp) +#if VERSION_BEFORE_2019_10_20 + /** Compare two group entries. @param l Left entry. @param r Right entry. @@ -536,6 +527,8 @@ dkwt_group_compare(void *l, void *r, int cr) return back; } +#endif + @@ -557,6 +550,8 @@ dkwt_tool_close_group(dkwt_group_t *gp) +#if VERSION_BEFORE_2019_10_20 + /** Open new group structure, allocate memory. @param gn Group name. @param app Application structure for diagnostics. @@ -580,6 +575,9 @@ dkwt_tool_open_group(dkChar const *gn, dk3_app_t *app) return back; } +#endif + + void dkwt_tool_reset_group_list(dkwt_group_list_t *glp) @@ -701,10 +699,14 @@ dkwt_tool_read_group_list(dkwt_group_list_t *gl, dk3_app_t *app, int f_long) LOCALGROUP_INFO_0 *lgrptr; LOCALGROUP_INFO_1 *lgr1ptr; dkwt_group_t *newgroup; - LPTSTR stringsid; +#if DK3_CHAR_SIZE > 1 + LPWSTR stringsid; +#else + LPASTR stringsid; +#endif -#line 613 "dkwt-to.ctr" +#line 637 "dkwt-to.ctr" /* Group information for network groups */ @@ -723,12 +725,12 @@ dkwt_tool_read_group_list(dkwt_group_list_t *gl, dk3_app_t *app, int f_long) if((ERROR_MORE_DATA == nStatus) || (NERR_Success == nStatus)) { if(pBuf) { -#line 630 "dkwt-to.ctr" +#line 654 "dkwt-to.ctr" grptr = (GROUP_INFO_0 *)pBuf; for(i = 0; i < dwEntries; i++) { if(grptr->grpi0_name) { -#line 633 "dkwt-to.ctr" +#line 657 "dkwt-to.ctr" newgroup = dkwt_tool_group_open(grptr->grpi0_name, app); if(newgroup) { if(!dk3sto_add(gl->s_grp, newgroup)) { @@ -794,10 +796,10 @@ dkwt_tool_read_group_list(dkwt_group_list_t *gl, dk3_app_t *app, int f_long) while((newgroup = (dkwt_group_t *)dk3sto_it_next(gl->i_grp)) != NULL) { pBuf = NULL; -#line 697 "dkwt-to.ctr" +#line 721 "dkwt-to.ctr" if(newgroup->gtype == DKWT_GROUP_LOCAL) { -#line 698 "dkwt-to.ctr" +#line 722 "dkwt-to.ctr" dwLevel = 1; pBuf = NULL; nStatus = NetLocalGroupGetInfo( @@ -808,11 +810,11 @@ dkwt_tool_read_group_list(dkwt_group_list_t *gl, dk3_app_t *app, int f_long) ); if(NERR_Success == nStatus) { -#line 707 "dkwt-to.ctr" +#line 731 "dkwt-to.ctr" if(pBuf) { lgr1ptr = (LOCALGROUP_INFO_1 *)pBuf; if(lgr1ptr->lgrpi1_comment) { - newgroup->comment = dk3str_dup_app(lgr1ptr->lgrpi1_comment, app); + newgroup->comment = dk3str_dup_app(lgr1ptr->lgrpi1_comment,app); if(!(newgroup->comment)) { back = 0; } @@ -826,7 +828,7 @@ dkwt_tool_read_group_list(dkwt_group_list_t *gl, dk3_app_t *app, int f_long) } } else { -#line 723 "dkwt-to.ctr" +#line 747 "dkwt-to.ctr" dwLevel = 3; pBuf = NULL; nStatus = NetGroupGetInfo( @@ -837,7 +839,7 @@ dkwt_tool_read_group_list(dkwt_group_list_t *gl, dk3_app_t *app, int f_long) ); if(NERR_Success == nStatus) { -#line 732 "dkwt-to.ctr" +#line 756 "dkwt-to.ctr" if(pBuf) { gr3ptr = (GROUP_INFO_3 *)pBuf; if(gr3ptr->grpi3_comment) { @@ -846,7 +848,12 @@ dkwt_tool_read_group_list(dkwt_group_list_t *gl, dk3_app_t *app, int f_long) } if(gr3ptr->grpi3_group_sid) { stringsid = NULL; - if(ConvertSidToStringSid(gr3ptr->grpi3_group_sid, &stringsid)) { +#if DK3_CHAR_SIZE > 1 + if(ConvertSidToStringSidW(gr3ptr->grpi3_group_sid, &stringsid)) +#else + if(ConvertSidToStringSidA(gr3ptr->grpi3_group_sid, &stringsid)) +#endif + { if(stringsid) { newgroup->textsid = dk3str_dup_app(stringsid, app); if(!(newgroup->textsid)) { back = 0; } @@ -867,7 +874,7 @@ dkwt_tool_read_group_list(dkwt_group_list_t *gl, dk3_app_t *app, int f_long) } } -#line 760 "dkwt-to.ctr" +#line 789 "dkwt-to.ctr" return back; } @@ -880,7 +887,7 @@ dkwt_tool_open_group_list(dk3_app_t *app, int f_long) int ok = 0; -#line 771 "dkwt-to.ctr" +#line 800 "dkwt-to.ctr" back = dk3_new_app(dkwt_group_list_t,1,app); if(back) { back->i_grp = NULL; @@ -897,7 +904,7 @@ dkwt_tool_open_group_list(dk3_app_t *app, int f_long) } } -#line 786 "dkwt-to.ctr" +#line 815 "dkwt-to.ctr" return back; } @@ -1053,44 +1060,65 @@ dkwt_tool_read_printer_list( DWORD cbNeeded; DWORD cbReturned; DWORD i; - PRINTER_INFO_2 *pi2; +#if DK3_CHAR_SIZE > 1 + PRINTER_INFO_2W *pi2; +#else + PRINTER_INFO_2A *pi2; +#endif dkwt_printer_t *pr; cbNeeded = (DWORD)0UL; cbReturned = (DWORD)0UL; -#line 946 "dkwt-to.ctr" - EnumPrinters( +#line 979 "dkwt-to.ctr" +#if DK3_CHAR_SIZE > 1 + EnumPrintersW( + PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &cbNeeded, &cbReturned + ); +#else + EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &cbNeeded, &cbReturned ); +#endif if(cbNeeded > 0) { peb = dk3_new_app(char,(size_t)cbNeeded,app); if(peb) { szpeb = cbNeeded; cbNeeded = (DWORD)0UL; cbReturned = (DWORD)0UL; - if(EnumPrinters( +#if DK3_CHAR_SIZE > 1 + if(EnumPrintersW( + PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)peb, szpeb, &cbNeeded, &cbReturned + ) + ) +#else + if(EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)peb, szpeb, &cbNeeded, &cbReturned ) ) +#endif { if(cbReturned > (DWORD)0UL) { - pi2 = (PRINTER_INFO_2 *)peb; +#if DK3_CHAR_SIZE > 1 + pi2 = (PRINTER_INFO_2W *)peb; +#else + pi2 = (PRINTER_INFO_2A *)peb; +#endif back = 1; for(i = 0; i < cbReturned; i++) { if(pi2->pPrinterName) { -#line 965 "dkwt-to.ctr" +#line 1015 "dkwt-to.ctr" pr = dkwt_tool_printer_new(pi2->pPrinterName, app); if(pr) { -#line 967 "dkwt-to.ctr" +#line 1017 "dkwt-to.ctr" if(dk3sto_add(pl->s_prn, (void *)pr)) { -#line 968 "dkwt-to.ctr" +#line 1018 "dkwt-to.ctr" if(f_long) { -#line 969 "dkwt-to.ctr" +#line 1019 "dkwt-to.ctr" dkwt_tool_save_text( &(pr->comment), pi2->pComment, @@ -1164,7 +1192,7 @@ dkwt_tool_read_printer_list( pr->nJobs = pi2->cJobs; } else { -#line 1041 "dkwt-to.ctr" +#line 1091 "dkwt-to.ctr" } } else { dkwt_tool_printer_delete(pr); @@ -1185,7 +1213,7 @@ dkwt_tool_read_printer_list( dk3app_log_i1(app, DK3_LL_ERROR, 244); } -#line 1060 "dkwt-to.ctr" +#line 1110 "dkwt-to.ctr" return back; } @@ -1311,7 +1339,7 @@ dkwt_tool_reg_delete_tree( ) { long res = ERROR_NOT_SUPPORTED; -#if _MSC_VER >= 1700 && (!(DK4_WINDOWS_LEGACY)) +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0601) #if DK3_CHAR_SIZE > 1 res = RegDeleteTreeW(hk, tn); #else @@ -1336,7 +1364,7 @@ dkwt_tool_reg_enum_key( long res; -#line 1209 "dkwt-to.ctr" +#line 1259 "dkwt-to.ctr" #if DK3_CHAR_SIZE > 1 res = RegEnumKeyExW( hk, dwIndex, pResult, pDwSzResult, @@ -1350,7 +1378,7 @@ dkwt_tool_reg_enum_key( #endif -#line 1221 "dkwt-to.ctr" +#line 1271 "dkwt-to.ctr" return res; } |