~ubuntu-branches/ubuntu/wily/apvlv/wily

« back to all changes in this revision

Viewing changes to src/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-01 22:18:49 UTC
  • mfrom: (10.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110601221849-niibd5p5i7avemy4
Tags: 0.1.1-1.1
* Non-maintainer upload.
* Add support for poppler >= 0.15. Patch by Pino Toscano. (Closes: #627609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "ApvlvInfo.hpp"
33
33
#include "ApvlvUtil.hpp"
34
34
 
35
 
#include <iostream>
36
 
 
37
35
#include <locale.h>
38
36
#ifndef WIN32
39
37
#include <getopt.h>
40
38
#endif
41
39
#include <gtk/gtk.h>
 
40
#include <iostream>
42
41
 
43
42
using namespace apvlv;
44
43
 
52
51
usage_exit ()
53
52
{
54
53
  fprintf (stdout, "%s Usage:\n"
55
 
           "%s\n"
56
 
           "Please send bug report to %s\n",
57
 
           PACKAGE_NAME,
58
 
           "\t-h                display this and exit\n"
59
 
           "\t-v                display version info and exit\n"
60
 
           "\t-c [file]         set user configuration file\n",
61
 
           PACKAGE_BUGREPORT);
 
54
           "%s\n"
 
55
           "Please send bug report to %s\n",
 
56
           PACKAGE_NAME,
 
57
           "\t-h                display this and exit\n"
 
58
           "\t-v                display version info and exit\n"
 
59
           "\t-c [file]         set user configuration file\n",
 
60
           PACKAGE_BUGREPORT);
62
61
}
63
62
 
64
63
static void
65
64
version_exit ()
66
65
{
67
66
  fprintf (stdout, "%s %s-%s\n"
68
 
           "Please send bug report to %s\n"
69
 
           "\n", PACKAGE_NAME, PACKAGE_VERSION, RELEASE, PACKAGE_BUGREPORT);
 
67
           "Please send bug report to %s\n"
 
68
           "\n", PACKAGE_NAME, PACKAGE_VERSION, RELEASE, PACKAGE_BUGREPORT);
70
69
}
71
70
#endif
72
71
 
85
84
  return 1;
86
85
#else
87
86
  int c, index;
88
 
  static struct option long_options[] = {
89
 
    {"config", required_argument, NULL, 'c'},
90
 
    {"help", no_argument, NULL, 'h'},
91
 
    {"version", no_argument, NULL, 'v'},
92
 
    {0, 0, 0, 0}
93
 
  };
 
87
  static struct option long_options[] =
 
88
    {
 
89
      {"config", required_argument, NULL, 'c'},
 
90
      {"help", no_argument, NULL, 'h'},
 
91
      {"version", no_argument, NULL, 'v'},
 
92
      {0, 0, 0, 0}
 
93
    };
94
94
 
95
95
  index = 0;
96
96
  ini = NULL;
97
97
  while ((c = getopt_long (argc, argv, "c:hv", long_options, &index)) != -1)
98
98
    {
99
99
      switch (c)
100
 
        {
101
 
        case 'c':
102
 
          ini = absolutepath (optarg);
103
 
          break;
104
 
 
105
 
        case 'h':
106
 
          usage_exit ();
107
 
          return -1;
108
 
 
109
 
        case 'v':
110
 
          version_exit ();
111
 
          return -1;
112
 
 
113
 
        default:
114
 
          errp ("no command line options");
115
 
          return -1;
116
 
        }
 
100
        {
 
101
        case 'c':
 
102
          ini = absolutepath (optarg);
 
103
          break;
 
104
 
 
105
        case 'h':
 
106
          usage_exit ();
 
107
          return -1;
 
108
 
 
109
        case 'v':
 
110
          version_exit ();
 
111
          return -1;
 
112
 
 
113
        default:
 
114
          errp ("no command line options");
 
115
          return -1;
 
116
        }
117
117
    }
118
118
 
119
119
  if (ini == NULL)
121
121
      ini = absolutepath (inifile.c_str ());
122
122
    }
123
123
 
124
 
  /* 
 
124
  /*
125
125
   * load the global sys conf file
126
126
   * */
127
127
  gchar *sysini = g_strdup_printf ("%s/%s", SYSCONFDIR, "apvlvrc");
131
131
      g_free (sysini);
132
132
    }
133
133
 
134
 
  /* 
 
134
  /*
135
135
   * load the user conf file
136
136
   * */
137
137
  if (ini != NULL)
175
175
  int opt = parse_options (argc, argv);
176
176
  if (opt < 0)
177
177
    {
 
178
      errp ("Parse options failed.\n");
178
179
      return 1;
179
180
    }
180
181
 
194
195
  gchar *rpath = g_locale_to_utf8 (path, -1, NULL, NULL, NULL);
195
196
  if (rpath == NULL)
196
197
    {
 
198
      errp ("Convert path: '%s' to utf8 failed.\n", path);
197
199
      return 1;
198
200
    }
199
201
 
201
203
  g_free (rpath);
202
204
  if (path == NULL)
203
205
    {
 
206
      errp ("Convert '%s' to absolute path failed.\n", rpath);
204
207
      return 1;
205
208
    }
206
209
 
207
210
  if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE)
208
211
    {
 
212
      errp ("File '%s' is not readble.\n", path);
209
213
      g_free (path);
210
214
      return 1;
211
215
    }
225
229
    {
226
230
      path = absolutepath (argv[opt++]);
227
231
      if (path == NULL)
228
 
        {
229
 
          continue;
230
 
        }
 
232
        {
 
233
          continue;
 
234
        }
231
235
 
232
236
      if (gView->loadfile (path) == false)
233
 
        {
234
 
          errp ("Can't open document: %s", path);
235
 
        }
 
237
        {
 
238
          errp ("Can't open document: %s", path);
 
239
        }
236
240
 
237
241
      g_free (path);
238
242
    }