Go to the source code of this file.
|
#define | STREQ(a, b) (strcmp(a,b) == 0) |
|
#define | STRNEQ(a, b, s) (strncmp(a,b,(size_t)(s)) == 0) |
|
#define | ISTRCMP strcmp |
|
#define | ISTRNCMP strncmp |
|
#define | ISTREQ(a, b) (ISTRCMP(a,b) == 0) |
|
#define | ISTRNEQ(a, b, s) (ISTRNCMP(a,b,(size_t)(s)) == 0) |
|
#define | YESNO(i) ((i == 0) ? "no" : "yes") |
|
#define | ONOFF(i) ((i == 0) ? "off" : "on") |
|
#define | TRUEFALSE(i) ((i == 0) ? "false" : "true") |
|
#define | strcoll strcmp |
|
#define | strncoll strncmp |
|
#define | F_OK 0 |
|
#define | kOurDirectoryName ".ncftp" |
|
#define | kPasswordMagic "*encoded*" |
|
#define | kPasswordMagicLen 9 |
|
|
void | ToBase64 (void *, const void *, size_t, int) |
|
void | FromBase64 (void *, const void *, size_t, int) |
|
void | OutOfMemory (void) |
|
void * | Realloc (void *, size_t) |
|
char * | GetCWD (char *, size_t) |
|
void | MyInetAddr (char *, size_t, char **, int) |
|
struct hostent * | GetHostEntry (const char *, struct in_addr *) |
|
void | CompressPath (char *const dst, const char *const src, const size_t dsize) |
|
void | PathCat (char *const dst, const size_t dsize, const char *const cwd, const char *const src) |
|
char * | FileToURL (char *url, size_t urlsize, const char *const fn, const char *const rcwd, const char *const startdir, const char *const user, const char *const pass, const char *const hname, const unsigned int port) |
|
void | AbbrevStr (char *, const char *, size_t, int) |
|
char * | Path (char *const dst, const size_t siz, const char *const parent, const char *const fname) |
|
char * | OurDirectoryPath (char *const dst, const size_t siz, const char *const fname) |
|
void | InitOurDirectory (void) |
|
void | InitUserInfo (void) |
|
int | MayUseFirewall (const char *const, int, const char *const) |
|
int | StrToBool (const char *const) |
|
void | AbsoluteToRelative (char *const, const size_t, const char *const, const char *const, const size_t) |
|
int | GetHostByName (char *const volatile, size_t, const char *const, int) |
|
time_t | UnDate (char *dstr) |
|
int | DecodeDirectoryURL (const FTPCIPtr, char *, LineListPtr, char *, size_t) |
|
char * | OurInstallationPath (char *const dst, const size_t siz, const char *const fname) |
|
◆ F_OK
◆ ISTRCMP
◆ ISTREQ
◆ ISTRNCMP
◆ ISTRNEQ
◆ kOurDirectoryName
#define kOurDirectoryName ".ncftp" |
◆ kPasswordMagic
#define kPasswordMagic "*encoded*" |
◆ kPasswordMagicLen
◆ ONOFF
#define ONOFF |
( |
|
i | ) |
((i == 0) ? "off" : "on") |
◆ strcoll
◆ STREQ
◆ strncoll
◆ STRNEQ
◆ TRUEFALSE
#define TRUEFALSE |
( |
|
i | ) |
((i == 0) ? "false" : "true") |
◆ YESNO
#define YESNO |
( |
|
i | ) |
((i == 0) ? "no" : "yes") |
◆ bsearch_proc_t
Definition at line 9 of file util.h.
◆ qsort_proc_t
Definition at line 8 of file util.h.
◆ sigproc_t
◆ vsigproc_t
◆ AbbrevStr()
Definition at line 451 of file util.c.
452{
454
458
461 } else {
462
465 }
466 } else {
468 }
469}
char * Strncat(char *const, const char *const, const size_t)
char * Strncpy(char *const, const char *const, const size_t)
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Referenced by MakePrompt(), PrSizeAndRateMeter(), PrStatBar(), and Usage().
◆ AbsoluteToRelative()
Definition at line 785 of file util.c.
786{
793 } else {
794
796 }
797 }
798}
int strcmp(const char *String1, const char *String2)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Referenced by CurrentURL(), and FillBookmarkInfo().
◆ CompressPath()
Definition at line 247 of file util.c.
248{
253
254 if (
src[0] ==
'\0') {
256 return;
257 }
258
262 for (;;) {
265 if (((
s ==
src) || (
s[-1] ==
'/')) && ((
s[1] ==
'/') || (
s[1] ==
'\0'))) {
266
270 }
else if (
d < lim) {
272 } else {
274 }
275 }
else if (
c ==
'/') {
276
279 else
281 for (;;) {
284
286 }
else if (
c ==
'.') {
289
291 }
else if (
c ==
'\0') {
292
294 } else {
295 break;
296 }
297 } else {
298 break;
299 }
300 }
301 }
else if (
c ==
'\0') {
302
303 if ((
d[-1] ==
'/') && (
d > (
dst + 1)))
306 break;
307 }
else if (
d < lim) {
309 } else {
311 }
312 }
314
315
316
317
318
319
322 for (;;) {
323
325 return;
328 break;
329 }
331 }
332 if ((
b[0] ==
'.') && (
b[1] ==
'.')) {
334
335
336
337 continue;
338 }
339 }
340 if ((
a[0] ==
'.') && (
a[1] ==
'.')) {
342
343 if ((
b ==
dst) && (*
dst ==
'/'))
345 else
348 }
else if (
a[2] ==
'\0') {
349
350 if ((
b <=
dst + 1) && (*
dst ==
'/'))
352 else
355 } else {
356
357
358
359
360 }
361 }
362 }
363}
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
#define memmove(s1, s2, n)
Referenced by PathCat().
◆ DecodeDirectoryURL()
Definition at line 1086 of file util.c.
1093{
1094 int rc;
1095 char urlstr2[256];
1097
1098
1099
1100
1101
1102
1103
1104
1105
1108
1112 }
1114 return (rc);
1115}
char * strchr(const char *String, int ch)
#define STRNCPY(dst, src, n)
int FTPDecodeURL(const FTPCIPtr cip, char *const url, LineListPtr cdlist, char *const fn, const size_t fnsize, int *const xtype, int *const wantnlst)
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static GLenum _GLUfuncptr fn
Referenced by OpenCmd(), and SetStartupURL().
◆ FileToURL()
Definition at line 387 of file util.c.
388{
389 size_t ulen, dsize;
391 int isUser;
392
393
394
395
396
398 isUser = 0;
400 isUser = 1;
405 }
407 }
412 }
413
416 dsize = urlsize - ulen;
418 if ((startdir !=
NULL) && (startdir[0] !=
'\0') && (startdir[1] !=
'\0')) {
420
422 } else if (isUser != 0) {
423
424
425
426
427
428 dst[dsize - 1] =
'\0';
429 dst[dsize - 2] =
'\0';
430 dst[dsize - 3] =
'\0';
431 dst[dsize - 4] =
'\0';
437 }
438 }
439
441}
void user(int argc, const char *argv[])
void PathCat(char *const dst, const size_t dsize, const char *const cwd, const char *const src)
#define sprintf(buf, format,...)
Referenced by PrPhilBar(), PrSizeAndRateMeter(), and PrStatBar().
◆ FromBase64()
Definition at line 128 of file util.c.
129{
131 const unsigned char *
src, *srclim;
132 unsigned int c0, c1, c2, c3;
133 unsigned int ch;
134
138
139 while (
src < srclim) {
143 } else {
144 c1 = 0;
145 }
148 } else {
149 c2 = 0;
150 }
153 } else {
154 c3 = 0;
155 }
156
159
162
165
167 }
170}
void MSVCRT() terminate()
static const unsigned char B64DecodeTable[256]
Referenced by ParseHostLine().
◆ GetCWD()
◆ GetHostByName()
Definition at line 826 of file util.c.
827{
828#if defined(WIN32) || defined(_WINDOWS)
831
832 if (
inet_addr(hn) != (
unsigned long) 0xFFFFFFFF) {
833
835 return (0);
836 }
837
842 return (0);
843 }
844
845#else
846 int sj;
849#ifndef HAVE_INET_NTOP
851#endif
852
853#ifdef HAVE_INET_ATON
855
857 return (0);
858 }
859#else
861
863 return (0);
864 }
865#endif
866
867#ifdef HAVE_SIGSETJMP
868 osigpipe = osigint = osigalrm = (
sigproc_t) 0;
870#else
871 osigpipe = osigint = osigalrm = (
sigproc_t) 0;
873#endif
874
875 if (sj != 0) {
876
881#ifdef ncftp
882 Trace(0,
"Canceled GetHostByName because of signal %d.\n", gResolveSig);
883#endif
884 } else {
889 (
void) alarm((
unsigned int)
t);
897#ifdef HAVE_INET_NTOP
900#else
903#endif
904 return (0);
905 }
906 }
907#endif
908
910 return (-1);
911}
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
#define inet_aton(cp, addr)
#define memcpy(s1, s2, n)
jmp_buf gGetHostByNameJmp
static void CancelGetHostByName(int sigNum)
volatile sigproc_t vsigproc_t
int sigsetjmp(sigjmp_buf buf, int savesigs)
const char *WSAAPI inet_ntop(int af, const void *src, char *dst, size_t cnt)
Referenced by DoOpen().
◆ GetHostEntry()
Definition at line 215 of file util.c.
216{
219
220
221
222
223
227 } else {
228
232 }
233 if (ip_address !=
NULL)
235 return (hp);
236}
PHOSTENT WSAAPI gethostbyaddr(IN const char FAR *addr, IN int len, IN int type)
◆ InitOurDirectory()
Definition at line 506 of file util.c.
507{
508#if defined(WIN32) || defined(_WINDOWS)
512 int rc;
513
516
519 "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\ncftp.exe",
523 {
525 dwType = 0;
527 hkey,
530 &dwType,
533 {
534
535
536
540 else
542 }
544 }
545
549 } else {
550
551
552
556 else
558 }
559 }
560
567 if ((
cp !=
NULL) && (
cp[1] ==
'\0'))
574 if ((
cp !=
NULL) && (
cp[1] ==
'\0'))
576 } else {
578 if (
gUser[0] ==
'\0') {
580 } else {
583 }
584 }
586 }
587
588#else
591
592#ifdef BINDIR
594#else
596#endif
597
602
603
604
605
606
607
608
610 return;
611 } else {
616 );
617 }
618
622 }
623 }
624#endif
625}
PRTL_UNICODE_STRING_BUFFER Path
#define RegCloseKey(hKey)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
char gOurInstallationPath[260]
char gOurDirectoryPath[260]
#define kOurDirectoryName
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
#define StrRFindLocalPathDelim(a)
int MkDirs(const char *const, int mode1)
#define GetModuleFileName
#define HKEY_LOCAL_MACHINE
Referenced by InitUserInfo().
◆ InitUserInfo()
Definition at line 630 of file util.c.
631{
632#if defined(WIN32) || defined(_WINDOWS)
635
640
644 if ((
cp !=
NULL) && (
cp[1] ==
'\0'))
646
648#else
649 struct passwd *pwptr;
650 char *envp;
651
653 pwptr = getpwuid(
gUid);
654
659 (
void)
fprintf(
stderr,
"You have a user id number of %d, but no username associated with it.\n", (
int)
gUid);
661 } else {
663 }
664
668 else
670
674 else
676 } else {
677
679
680
682
683
685 }
686#endif
687
689}
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void InitOurDirectory(void)
*nSize LPSTR _Inout_ LPDWORD nSize
Referenced by PreInit().
◆ MayUseFirewall()
Definition at line 695 of file util.c.
696{
697#ifdef HAVE_STRSTR
699 char *tok;
700 char *parse;
701#endif
702
704 return (0);
705
706 if (firewallExceptionList[0] == '\0') {
708
709
710
711 return (0);
712 } else {
713 return (1);
714 }
715 }
716
718
719
720
721
722
723
726 if (
strcmp(tok,
"localdomain") == 0)
727 return (0);
728 }
729
730 }
731
732#ifdef HAVE_STRSTR
735
736
737
739 return (0);
740 }
741#endif
742 return (1);
743}
char * strstr(char *String1, char *String2)
char * strtok(char *String, const char *Delimiters)
GLenum GLuint GLenum GLsizei const GLchar * buf
#define kFirewallNotInUse
Referenced by OpenCmd(), and SetStartupURL().
◆ MyInetAddr()
Definition at line 185 of file util.c.
186{
188#ifndef HAVE_INET_NTOP
190#endif
191
193 if (
src != (
char **) 0) {
195#ifdef HAVE_INET_NTOP
197#else
199 if ((
cp != (
char *) 0) && (
cp != (
char *) -1) && (
cp[0] !=
'\0'))
201#endif
202 }
203}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
◆ OurDirectoryPath()
Definition at line 486 of file util.c.
Referenced by CheckForNewV3User(), CloseTrace(), EndLog(), InitLog(), LoadFirewallPrefs(), LoadHistory(), LoadPrefs(), MkSpoolDir(), OpenBookmarkFile(), OpenTmpBookmarkFile(), OpenTrace(), RunBookmarkEditor(), SaveHistory(), SavePrefs(), SwapBookmarkFiles(), and TruncBatchLog().
◆ OurInstallationPath()
◆ OutOfMemory()
Definition at line 64 of file fc.c.
65{
68}
void ConResPuts(FILE *fp, UINT nID)
#define IDS_OUT_OF_MEMORY
◆ Path()
Definition at line 475 of file util.c.
476{
480}
#define LOCAL_PATH_DELIM_STR
◆ PathCat()
Definition at line 368 of file util.c.
369{
371 char tmp[512];
372
375 return;
376 }
377 cp =
Strnpcpy(tmp, (
char *) cwd,
sizeof(tmp) - 1);
382}
char * Strnpcpy(char *const, const char *const, size_t)
char * Strnpcat(char *const, const char *const, size_t)
void CompressPath(char *const dst, const char *const src, const size_t dsize)
Referenced by Chdirs(), FileToURL(), Ls(), nFTPChdirAndGetCWD(), and RemoteCompletionFunction().
◆ Realloc()
◆ StrToBool()
◆ ToBase64()
Definition at line 83 of file util.c.
84{
86 const unsigned char *
src, *srclim;
87 unsigned int c0, c1, c2;
88 unsigned int ch;
89
93
94 while (
src < srclim) {
98 } else {
99 c1 = 0;
100 }
103 } else {
104 c2 = 0;
105 }
106
107 ch = c0 >> 2;
109
110 ch = ((c0 << 4) & 060) | ((c1 >> 4) & 017);
112
113 ch = ((c1 << 2) & 074) | ((c2 >> 6) & 03);
115
116 ch = (c2 & 077);
118
120 }
123}
static const unsigned char B64EncodeTable[64]
Referenced by SpoolX(), and WriteBmLine().
◆ UnDate()
Definition at line 917 of file util.c.
918{
919#ifndef HAVE_MKTIME
921#else
925
928
929
930
931
932
933
935
936
937 if (
sscanf(dstr,
"%04d%02d%02d%02d%02d%02d",
938 &ut.tm_year,
939 &ut.tm_mon,
940 &ut.tm_mday,
941 &ut.tm_hour,
942 &ut.tm_min,
943 &ut.tm_sec) == 6)
944 {
945 --ut.tm_mon;
946 ut.tm_year -= 1900;
948 }
950#endif
951}
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_CRTIMP time_t __cdecl mktime(struct tm *_Tm)
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Referenced by GetStartSpoolDate().