~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/windows/identity/plugins/krb4/errorfuncs.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:28:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030102853-x7v876vw4af46v0m
Tags: 1.4.4-3ubuntu1
* Merge with Debian; only Ubuntu change:
  - src/include/k5-thread.h: Define__USE_GNU when #include'ing pthread.h to
    fix FTBFS (from 1.4.3-9ubuntu1).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2004 Massachusetts Institute of Technology
 
2
 * Copyright (c) 2005 Massachusetts Institute of Technology
3
3
 *
4
4
 * Permission is hereby granted, free of charge, to any person
5
5
 * obtaining a copy of this software and associated documentation
27
27
#include<krbcred.h>
28
28
#include<kherror.h>
29
29
 
 
30
#include<strsafe.h>
 
31
 
30
32
extern void (__cdecl *pinitialize_krb_error_func)();
31
33
extern void (__cdecl *pinitialize_kadm_error_table)();
32
34
 
62
64
 
63
65
HWND GetRootParent (HWND Child)
64
66
{
65
 
    HWND Last;
 
67
    HWND Last = NULL;
66
68
    while (Child)
67
69
    {
68
70
        Last = Child;
72
74
}
73
75
 
74
76
 
75
 
LPSTR err_describe(LPSTR buf, long code)
 
77
LPSTR err_describe(LPSTR buf, size_t len, long code)
76
78
{
77
79
    LPSTR cp, com_err_msg;
78
80
    int offset;
89
91
    case kadm_err_base:
90
92
        break;
91
93
    default:
92
 
        strcpy(buf, com_err_msg);
 
94
        StringCbCopyA(buf, len, com_err_msg);
93
95
        return buf;
94
96
    }
95
97
 
192
194
            /* no extra error msg */
193
195
            break;
194
196
        }
195
 
    if(com_err_msg != buf)
196
 
        strcpy(buf, com_err_msg);
 
197
    if(com_err_msg != buf) {
 
198
        StringCbCopyA(buf, len, com_err_msg);
 
199
    }
197
200
    cp = buf + strlen(buf);
198
201
    *cp++ = '\n';
199
202
    switch(table_num) {
207
210
        etype = Lerror_table_name(table_num);
208
211
        break;
209
212
    }
210
 
    wsprintfA((LPSTR) cp, (LPSTR) "(%s error %d"
 
213
    StringCbPrintfA((LPSTR) cp, len - (cp-buf), (LPSTR) "(%s error %d"
211
214
#ifdef DEBUG_COM_ERR
212
215
             " (absolute error %ld)"
213
216
#endif
221
224
    return (LPSTR)buf;
222
225
}
223
226
 
224
 
int lsh_com_err_proc (LPSTR whoami, long code,
225
 
                              LPSTR fmt, va_list args)
226
 
{
227
 
    int retval;
228
 
    HWND hOldFocus;
229
 
    char buf[1024], *cp; /* changed to 512 by jms 8/23/93 */
230
 
    WORD mbformat = MB_OK | MB_ICONEXCLAMATION;
231
 
  
232
 
    cp = buf;
233
 
    memset(buf, '\0', sizeof(buf));
234
 
    cp[0] = '\0';
235
 
  
236
 
    if (code)
237
 
    {
238
 
        err_describe(buf, code);
239
 
        while (*cp)
240
 
            cp++;
241
 
    }
242
 
  
243
 
    if (fmt)
244
 
    {
245
 
        if (fmt[0] == '%' && fmt[1] == 'b')
246
 
        {
247
 
            fmt += 2;
248
 
            mbformat = va_arg(args, WORD);
249
 
            /* if the first arg is a %b, we use it for the message
250
 
               box MB_??? flags. */
251
 
        }
252
 
        if (code)
253
 
        {
254
 
            *cp++ = '\n';
255
 
            *cp++ = '\n';
256
 
        }
257
 
        wvsprintfA((LPSTR)cp, fmt, args);
258
 
    }
259
 
    hOldFocus = GetFocus();
260
 
    retval = MessageBoxA(/*GetRootParent(hOldFocus)*/NULL, buf, whoami, 
261
 
                        mbformat | MB_ICONHAND | MB_TASKMODAL);
262
 
    SetFocus(hOldFocus);
263
 
    return retval;
264
 
}