]> git.lyx.org Git - features.git/blob - development/cygwin/lyxeditor.c
Add support for the newly released Cygwin 1.7.
[features.git] / development / cygwin / lyxeditor.c
1 /**
2  * \file lyxeditor.c
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Enrico Forestieri
7  *
8  * Full author contact details are available in file CREDITS.
9  *
10  * This is a wrapper program for the lyxeditor.sh script or lyxclient program,
11  * meant to be used with yap or sumatrapdf for inverse search.
12  */
13
14 #include "config.h"
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <limits.h>
18 #include <cygwin/version.h>
19 #include <sys/cygwin.h>
20 #include <windows.h>
21
22 void convert_to_full_posix_path(char const * from, char *to)
23 {
24 #if CYGWIN_VERSION_DLL_MAJOR >= 1007
25     cygwin_conv_path(CCP_WIN_A_TO_POSIX, from, to, PATH_MAX);
26 #else
27     cygwin_conv_to_full_posix_path(from, to);
28 #endif
29 }
30
31 int main(int ac, char **av)
32 {
33         char buf[2 * PATH_MAX];
34         char posixpath[PATH_MAX + 1];
35
36         if (ac < 3 || ac > 4) {
37                 MessageBox(0, "Usage: lyxeditor [-g] <file.tex> <lineno>",
38                                 "ERROR: Wrong number of arguments", 0);
39                 return 1;
40         }
41
42         if (ac == 3) {
43                 convert_to_full_posix_path(av[1], posixpath);
44                 sprintf(buf, "lyxeditor.sh" PROGRAM_SUFFIX " '%s' %s",
45                                 posixpath, av[2]);
46         } else {
47                 convert_to_full_posix_path(av[2], posixpath);
48                 sprintf(buf, "lyxclient" PROGRAM_SUFFIX " %s '%s' %s",
49                                 av[1], posixpath, av[3]);
50         }
51         system(buf);
52         return 0;
53 }