14#if defined(_WIN32) && !defined(__CYGWIN__)
25#include <glade/glade.h>
44#include <mach-o/dyld.h>
48#include <sys/sysctl.h>
69 static size_t baselen;
86static char *
useString =
"Usage: smyrna [-v?] <file>\n\
87 -f<WxH:bits@rate> - full-screen mode\n\
88 -e - draw edges as splines if available\n\
106 while ((c = getopt(argc, argv,
":eKf:txvV?")) != -1) {
115 viewinfo->
optArg = optarg;
119 fprintf(stderr,
"%s version %s (%s)\n",
Info[0],
Info[1],
Info[2]);
123 if (optopt ==
'\0' || optopt ==
'?')
126 fprintf(stderr,
"smyrna: option -%c unrecognized\n", optopt);
140 GdkGLConfig *glconfig;
142 GtkComboBox *graphComboBox;
145 gtk_init(&argc, &argv);
150 GtkWidget *gladewidget = glade_xml_get_widget(
xml,
"frmMain");
151 gtk_widget_show(gladewidget);
152 g_signal_connect(gladewidget,
"destroy", G_CALLBACK(
mQuitSlot),
NULL);
153 glade_xml_signal_autoconnect(
xml);
157 gladewidget = glade_xml_get_widget(
xml,
"hbox11");
159 gtk_widget_hide(glade_xml_get_widget(
xml,
"vbox13"));
160 gtk_window_set_deletable(
161 (GtkWindow *)glade_xml_get_widget(
xml,
"dlgSettings"), 0);
162 gtk_window_set_deletable((GtkWindow *)glade_xml_get_widget(
xml,
"frmTVNodes"),
168 glutInit(&argc, argv);
171 gladewidget = glade_xml_get_widget(
xml,
"hbox13");
172 graphComboBox = (GtkComboBox *)gtk_combo_box_new_text();
173 gtk_box_pack_end((GtkBox *)gladewidget, (GtkWidget *)graphComboBox, 1, 1, 10);
174 gtk_widget_show((GtkWidget *)graphComboBox);
181#if !defined(__APPLE__) && !defined(_WIN32)
185 char *resolved =
NULL;
191 resolved =
gv_realloc(resolved, size, size == 0 ? 1024 : (size * 2));
192 size = size == 0 ? 1024 : (size * 2);
196 ssize_t written = readlink(
path, resolved, size);
200 if ((
size_t)written < size) {
202 resolved[written] =
'\0';
221 uint32_t buf_size = 0;
222 int rc = _NSGetExecutablePath(
NULL, &buf_size);
224 assert(buf_size > 0);
229 if (_NSGetExecutablePath(
path, &buf_size) < 0) {
230 fprintf(stderr,
"failed to get path for executable.\n");
247 size_t path_size = 0;
251 size_t size = path_size == 0 ? 1024 : (path_size * 2);
255 rc = GetModuleFileName(
NULL,
path, path_size);
257 fprintf(stderr,
"failed to get path for executable.\n");
261 }
while (rc == path_size);
285 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
286 static const size_t MIB_LENGTH =
sizeof(mib) /
sizeof(mib[0]);
291 if (sysctl(mib, MIB_LENGTH,
NULL, &buf_size,
NULL, 0) < 0) {
294 assert(buf_size > 0);
300 if (sysctl(mib, MIB_LENGTH, buf, &buf_size,
NULL, 0) == 0) {
309 fprintf(stderr,
"failed to get path for executable.\n");
317 const char PATH_SEPARATOR =
'\\';
319 const char PATH_SEPARATOR =
'/';
328 char *slash = strrchr(smyrna_exe, PATH_SEPARATOR);
330 fprintf(stderr,
"no path separator in path to self, %s\n", smyrna_exe);
336 slash = strrchr(smyrna_exe, PATH_SEPARATOR);
338 fprintf(stderr,
"no path separator in directory containing self, %s\n",
345 size_t share_len = strlen(smyrna_exe) + strlen(
"/share/graphviz/smyrna") + 1;
347 snprintf(share, share_len,
"%s%cshare%cgraphviz%csmyrna", smyrna_exe,
348 PATH_SEPARATOR, PATH_SEPARATOR, PATH_SEPARATOR);
354int main(
int argc,
char *argv[]) {
360 char *package_locale_dir;
363 char *package_prefix =
364 g_win32_get_package_installation_directory(
NULL,
NULL);
366 g_build_filename(package_prefix,
"share",
"locale",
NULL);
367 g_free(package_prefix);
370 package_locale_dir = g_build_filename(
smyrnaDir,
"locale",
NULL);
374 bind_textdomain_codeset(GETTEXT_PACKAGE,
"UTF-8");
387 g_free(package_locale_dir);
Memory allocation wrappers that exit on failure.
static void * gv_realloc(void *ptr, size_t old_size, size_t new_size)
static void * gv_calloc(size_t nmemb, size_t size)
static void * gv_alloc(size_t size)
static NORETURN void graphviz_exit(int status)
GdkGLConfig * configure_gl(void)
void create_window(GdkGLConfig *glconfig, GtkWidget *vbox)
static double len(glCompPoint p)
int cb_glutinit(int w, int h, int *argcp, char *argv[], char *optArg)
static const char * usage
static char * smyrnaGlade
char * smyrnaPath(char *suffix)
static char * readln(const char *path)
readlink-alike but dynamically allocates
static char * find_me(void)
find an absolute path to the current executable
static char * parseArgs(int argc, char *argv[], ViewInfo *viewinfo)
static void windowedMode(int argc, char *argv[])
static char * find_share(void)
find an absolute path to where Smyrna auxiliary files are stored
GtkComboBox * graphComboBox
#define textdomain(String)
#define bindtextdomain(Domain, Directory)
void init_viewport(ViewInfo *vi)