|
|
|
@ -1,22 +1,24 @@ |
|
|
|
/* |
|
|
|
* --- T2-COPYRIGHT-NOTE-BEGIN --- |
|
|
|
* --- SDE-COPYRIGHT-NOTE-BEGIN --- |
|
|
|
* This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|
|
|
* |
|
|
|
* T2 SDE: misc/tools-source/fl_wrparse.c |
|
|
|
* |
|
|
|
* Filename: src/tools-source/fl_wrparse.c |
|
|
|
* Copyright (C) 2013 The OpenSDE Project |
|
|
|
* Copyright (C) 2004 - 2006 The T2 SDE Project |
|
|
|
* Copyright (C) 1998 - 2003 Clifford Wolf |
|
|
|
* |
|
|
|
* |
|
|
|
* More information can be found in the files COPYING and README. |
|
|
|
* |
|
|
|
* |
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
* the Free Software Foundation; version 2 of the License. A copy of the |
|
|
|
* GNU General Public License can be found in the file COPYING. |
|
|
|
* --- T2-COPYRIGHT-NOTE-END --- |
|
|
|
* --- SDE-COPYRIGHT-NOTE-END --- |
|
|
|
*/ |
|
|
|
|
|
|
|
#define _GNU_SOURCE |
|
|
|
|
|
|
|
#include <errno.h> |
|
|
|
#include <string.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <sys/stat.h> |
|
|
|
@ -25,7 +27,7 @@ |
|
|
|
|
|
|
|
char * get_realname(char * origname) { |
|
|
|
static char buf[FILENAME_MAX]; |
|
|
|
char *file, odir[FILENAME_MAX]; |
|
|
|
char *file, odir[FILENAME_MAX] = ""; |
|
|
|
|
|
|
|
if (! strcmp(origname, "/")) return "/"; |
|
|
|
|
|
|
|
@ -37,9 +39,15 @@ char * get_realname(char * origname) { |
|
|
|
*file=0; file++; |
|
|
|
file = origname + (file-buf); |
|
|
|
} |
|
|
|
|
|
|
|
getcwd(odir, FILENAME_MAX); chdir(buf); |
|
|
|
getcwd(buf, FILENAME_MAX); chdir(odir); |
|
|
|
|
|
|
|
if (getcwd(odir, FILENAME_MAX) == NULL || |
|
|
|
chdir(buf) < 0 || |
|
|
|
getcwd(buf, FILENAME_MAX) == NULL || |
|
|
|
chdir(odir) < 0) { |
|
|
|
fprintf(stderr,"fl_wrapper:getcwd/chdir: (%s:%s): %s\n", odir, buf, |
|
|
|
strerror(errno)); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
if (strcmp(buf, "/")) strcat(buf,"/"); |
|
|
|
strcat(buf, file); |
|
|
|
@ -97,7 +105,10 @@ int main(int argc, char ** argv) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ( rootdir != NULL ) chdir(rootdir); |
|
|
|
if (rootdir && chdir(rootdir) < 0) { |
|
|
|
fprintf(stderr, "fl_wrapper: rootdir=%s: %s\n", rootdir, strerror(errno)); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
while ( fgets(buf, FILENAME_MAX, stdin) != NULL ) { |
|
|
|
|
|
|
|
|