source: git/src/editwrap.c @ ecbc6c18

RELEASE/1.1RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-data
Last change on this file since ecbc6c18 was ecbc6c18, checked in by Olly Betts <olly@…>, 14 years ago

src/: Update FSF address in licence notices.

git-svn-id: file:///home/survex-svn/survex/branches/survex-1_1@3417 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/* editwrap.c
2 * Run svxedit.tcl from the same directory as this program
3 * Copyright (C) 2002 Olly Betts
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24#include <stdlib.h>
25#include <string.h>
26#include <windows.h>
27
28int APIENTRY
29WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
30{
31   DWORD len = 256;
32   char *buf = NULL, *p;
33   hInst = hInst; /* suppress compiler warning */
34   hPrevInst = hPrevInst; /* suppress compiler warning */
35   while (1) {
36       DWORD got;
37       buf = realloc(buf, len);
38       if (!buf) exit(1);
39       got = GetModuleFileName(NULL, buf, len);
40       if (got + 12 < len) break;
41       len += len;
42   }
43   /* Strange Win32 nastiness - strip prefix "\\?\" if present */
44   if (strncmp(buf, "\\\\?\\", 4) == 0) buf += 4;
45   p = strrchr(buf, '\\');
46   if (p) ++p; else p = buf;
47   strcpy(p, "svxedit.tcl");
48   /* ShellExecute returns an HINSTANCE for some wacko reason - the docs say
49    * the only valid operation is to convert it to an int.  Marvellous. */
50   if ((int)ShellExecute(NULL, NULL, buf, lpCmdLine, NULL, nCmdShow) <= 32) {
51       ShellExecute(NULL, NULL, "notepad", lpCmdLine, NULL, nCmdShow);
52   }
53   return 0;
54}
Note: See TracBrowser for help on using the repository browser.