Ticket #132: add_SafeDosQueryAppType.diff

File add_SafeDosQueryAppType.diff, 2.4 KB (added by guest, 17 years ago)

Patch (1st try) to implement SafeDosQueryAppType

  • libc/include/os2safe.h

     
    3636#define DosWaitNPipe            SafeDosWaitNPipe
    3737#define DosSetFilePtr           SafeDosSetFilePtr
    3838#define DosSetFilePtrL          SafeDosSetFilePtrL
    3939#define DosDupHandle            SafeDosDupHandle
    4040#define DosOpenL                SafeDosOpenL
    4141#define DosQueryFHState         SafeDosQueryFHState
    4242#define DosSetDateTime          SafeDosSetDateTime
    4343#define DosStartSession         SafeDosStartSession
     44#define DosQueryAppType         SafeDosQueryAppType
    4445
    4546#endif
  • new file libc/src/libos2/safe/SafeDosQueryAppType.c

    - +  
     1/* $Id$ */
     2/** @file
     3 *
     4 * SafeDosQueryAppType()
     5 *
     6 * Copyright (c) 2007 Peter Weilbacher <mozilla@weilbacher.org>
     7 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>
     8 *                    (code adapted from SafeDosQueryFHState.c and SafeDosOpenL.c)
     9 *
     10 * This program is free software; you can redistribute it and/or modify
     11 * it under the terms of the GNU General Public License as published by
     12 * the Free Software Foundation; either version 2 of the License, or
     13 * (at your option) any later version.
     14 *
     15 * This program is distributed in the hope that it will be useful,
     16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18 * GNU General Public License for more details.
     19 *
     20 * You should have received a copy of the GNU General Public License
     21 * along with This program; if not, write to the Free Software
     22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     23 *
     24 */
     25
     26#define INCL_BASE
     27#include <os2.h>
     28#include "safe.h"
     29
     30APIRET APIENTRY SafeDosQueryAppType(PSZ pszFile, PULONG pulFlags);
     31APIRET APIENTRY SafeDosQueryAppType(PSZ pszFile, PULONG pulFlags)
     32{
     33    ULONG   rc, ul;
     34    PULONG  pul = NULL;
     35    // even though pszFile is PSZ and not PSCZ, use of the PCSZ macros
     36    // should be safe
     37    SAFE_PCSZ(pszFile);
     38
     39    if (pulFlags)
     40    {
     41        ul = *pulFlags;
     42        pul = &ul;
     43    }
     44
     45    rc = DosQueryAppType(SAFE_PCSZ_USE(pszFile), pul);
     46
     47    if (pulFlags)
     48        *pulFlags = ul;
     49
     50    SAFE_PCSZ_DONE(pszFile);
     51    SAFE_DOS_FAILURE();
     52
     53    return rc;
     54}
     55