*** include/includes.h Wed Nov 10 21:36:00 1999 --- /new/include/includes.h Tue Nov 16 19:32:45 1999 *************** *** 21,26 **** --- 21,36 ---- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + #ifdef AMIGA + /* This type definition clashes with one + * used in the Samba code, which is why + * we hide it. + */ + #define BOOL __BOOL + #include + #undef BOOL + #endif /* AMIGA */ + #ifndef NO_CONFIG_H /* for some tests */ #include "config.h" #endif *************** *** 847,852 **** --- 857,873 ---- /* yuck, I'd like a better way of doing this */ #define DIRP_SIZE (256 + 32) + + #ifdef AMIGA + /* Remap a couple of library routines. */ + #include "amiga.h" + + /* These clash with local definitions in "smbd/ipc.c", + * which is why we undefine them. + */ + #undef ACCESS_READ + #undef ACCESS_WRITE + #endif /* AMIGA */ /* * glibc on linux doesn't seem to have MSG_WAITALL *** lib/smbrun.c Tue Jul 20 20:25:09 1999 --- /new/lib/smbrun.c Tue Nov 16 19:32:45 1999 *************** *** 92,97 **** --- 92,100 ---- set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY, False); #ifndef HAVE_EXECL + #ifdef AMIGA + return(amiga_smbrun(cmd,outfile,shared)); + #else int ret; pstring syscmd; char *path = lp_smbrun(); *************** *** 113,118 **** --- 116,122 ---- ret = system(syscmd); DEBUG(5,("gave %d\n",ret)); return(ret); + #endif /* AMIGA */ #else /* in this newer method we will exec /bin/sh with the correct arguments, after first setting stdout to point at the file */ *** lib/snprintf.c Wed Oct 13 00:26:49 1999 --- /new/lib/snprintf.c Tue Nov 16 19:32:48 1999 *************** *** 49,54 **** --- 49,59 ---- * fixed handling of %.0f * added test for HAVE_LONG_DOUBLE * + * Olaf Barthel 15-Oct-99 + * Implemented the missing 'f' and 'g' floating point output + * formats; also fixed handling of floating point numbers + * like "0.01" which would always come out as "0.1". + * **************************************************************/ #include "config.h" *************** *** 59,64 **** --- 64,73 ---- #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) + #ifdef AMIGA + #include + #endif /* AMIGA */ + /* Define this as a fall through, HAVE_STDARG_H is probably already set */ #define HAVE_VARARGS_H *************** *** 107,113 **** static void fmtint (char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags); static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ! LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); /* --- 116,122 ---- static void fmtint (char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags); static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ! LDOUBLE fvalue, int min, int max, int flags, char ch); static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); /* *************** *** 326,332 **** else fvalue = va_arg (args, double); /* um, floating point? */ ! fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); break; case 'E': flags |= DP_F_UP; --- 335,341 ---- else fvalue = va_arg (args, double); /* um, floating point? */ ! fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch); break; case 'E': flags |= DP_F_UP; *************** *** 335,340 **** --- 344,351 ---- fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch); break; case 'G': flags |= DP_F_UP; *************** *** 343,348 **** --- 354,361 ---- fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch); break; case 'c': dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); *************** *** 577,584 **** } static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ! LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; LDOUBLE ufvalue; #ifndef HAVE_FCVT --- 590,604 ---- } static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ! LDOUBLE fvalue, int min, int max, int flags, char ch) { + enum /* olsen: output formats to be used below. */ + { + FORMAT_f, + FORMAT_g, + FORMAT_e + }; + int signvalue = 0; LDOUBLE ufvalue; #ifndef HAVE_FCVT *************** *** 593,599 **** --- 613,621 ---- # ifdef HAVE_FCVTL extern char *fcvtl(long double value, int ndigit, int *decpt, int *sign); # else + #ifndef AMIGA extern char *fcvt(double value, int ndigit, int *decpt, int *sign); + #endif /* AMIGA */ # endif #endif int iplace = 0; *************** *** 603,609 **** int caps = 0; long intpart; long fracpart; ! /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 --- 625,635 ---- int caps = 0; long intpart; long fracpart; ! int exponent; ! int exponentLen; ! int outputFmt; ! int decimalPointLen; ! /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 *************** *** 622,627 **** --- 648,696 ---- if (flags & DP_F_SPACE) signvalue = ' '; + /* olsen: determine the output format. */ + if(ch == 'g' || ch == 'G') + outputFmt = FORMAT_g; + else if (ch == 'e' || ch == 'E') + outputFmt = FORMAT_e; + else + outputFmt = FORMAT_f; + + /* olsen: calculate the exponent */ + exponent = 0; + if(ufvalue > 0.0 && outputFmt != FORMAT_f) + { + LDOUBLE value = ufvalue; + + /* Make sure that the integer part + * comes out as a single digit. + */ + if(value < 1.0) + { + do + { + value *= 10.0; + exponent--; + } + while(value < 1.0); + } + else if(value > 10.0) + { + do + { + value /= 10.0; + exponent++; + } + while(value > 10.0); + } + + /* Don't change the base unless we are to output + * the number in scientific format. + */ + if((outputFmt == FORMAT_e) || (outputFmt == FORMAT_g && exponent < -4)) + ufvalue = value; + } + #if 0 if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ #endif *************** *** 659,674 **** intpart = (intpart / 10); } while(intpart && (iplace < 20)); if (iplace == 20) iplace--; ! iconvert[iplace] = 0; /* Convert fractional part */ do { fconvert[fplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; fracpart = (fracpart / 10); ! } while(fracpart && (fplace < 20)); if (fplace == 20) fplace--; ! fconvert[fplace] = 0; #else /* use fcvt() */ if (max > 310) max = 310; --- 728,752 ---- intpart = (intpart / 10); } while(intpart && (iplace < 20)); if (iplace == 20) iplace--; ! iconvert[iplace] = '\0'; /* Convert fractional part */ do { fconvert[fplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; fracpart = (fracpart / 10); ! } while(fracpart != 0 && (fplace < 20)); ! ! /* olsen: we need to make up for numbers like 0.01 ! * which would come out as "0.1" unless ! * we add a few padding zeroes. ! */ ! while(fplace < 20 && fplace < max) ! fconvert[fplace++] = '0'; ! if (fplace == 20) fplace--; ! fconvert[fplace] = '\0'; ! #else /* use fcvt() */ if (max > 310) max = 310; *************** *** 716,723 **** } #endif /* fcvt */ /* -1 for decimal point, another -1 if we are printing a sign */ ! padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; --- 794,863 ---- } #endif /* fcvt */ + /* olsen: eliminate trailing zeroes. */ + decimalPointLen = (max > 0) ? 1 : 0; + exponentLen = 0; + if(outputFmt == FORMAT_g) + { + int i,numTrailingZeroes; + + /* Count the number of trailing zeroes. */ + numTrailingZeroes = 0; + for(i = 0 ; i < fplace ; i++) + { + if(fconvert[i] == '0') + numTrailingZeroes++; + else + break; + } + + /* If there are any, remove them. */ + if(numTrailingZeroes > 0) + { + /* Remove the zeroes, if necessary. + * Otherwise, just forget that we + * had any digits in the fractional + * part. + */ + if(numTrailingZeroes != fplace) + { + for(i = 0 ; i < fplace-numTrailingZeroes ; i++) + fconvert[i] = fconvert[numTrailingZeroes+i]; + } + + fplace -= numTrailingZeroes; + fconvert[fplace] = '\0'; + + /* Don't print the decimal point if + * there is nothing to follow it. + */ + if(fplace == 0) + decimalPointLen = 0; + } + + /* Switch to scientific output format + * if the exponent is too small. + */ + if(exponent < -4) + { + /* Two digits for the "e+" and + * at least two digits for the number + * to follow the sign. + */ + exponentLen = (int)log10((LDOUBLE)exponent) + 2; + if(exponentLen < 4) + exponentLen = 4; + } + } + else if(outputFmt == FORMAT_e) + { + exponentLen = (int)log10((LDOUBLE)exponent) + 2; + if(exponentLen < 4) + exponentLen = 4; + } + /* -1 for decimal point, another -1 if we are printing a sign */ ! padlen = min - iplace - max - decimalPointLen - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; *************** *** 726,731 **** --- 866,875 ---- if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justifty */ + /* olsen: eliminate trailing zeroes. */ + if(outputFmt == FORMAT_g) + zpadlen = 0; + if ((flags & DP_F_ZERO) && (padlen > 0)) { if (signvalue) *************** *** 760,766 **** * Decimal point. This should probably use locale to find the correct * char to print out. */ ! if (max > 0) { dopr_outch (buffer, currlen, maxlen, '.'); while (fplace > 0) --- 904,910 ---- * Decimal point. This should probably use locale to find the correct * char to print out. */ ! if (max > 0 && decimalPointLen > 0) { dopr_outch (buffer, currlen, maxlen, '.'); while (fplace > 0) *************** *** 773,778 **** --- 917,951 ---- --zpadlen; } + /* olsen: output the exponent */ + if(exponentLen > 0) + { + char expChars[10]; + int numExpChars; + int i; + + dopr_outch (buffer, currlen, maxlen, caps?'E':'e'); + if(exponent < 0) + { + dopr_outch (buffer, currlen, maxlen, '-'); + exponent = (-exponent); + } + else + { + dopr_outch (buffer, currlen, maxlen, '+'); + } + + numExpChars = 0; + for(i = 0 ; i < exponentLen-2 && i < sizeof(expChars)-1 ; i++) + { + expChars[numExpChars++] = '0' + (exponent % 10); + exponent /= 10; + } + + while(numExpChars > 0) + dopr_outch (buffer, currlen, maxlen, expChars[--numExpChars]); + } + while (padlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); *************** *** 848,857 **** "%3.2f", "%.0f", "%.1f", NULL }; double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, ! 0.9996, 1.996, 4.136, 6442452944.1234, 0}; char *int_fmt[] = { "%-1.5d", "%1.5d", --- 1021,1059 ---- "%3.2f", "%.0f", "%.1f", + + "%-1.5g", + "%1.5g", + "%123.9g", + "%10.5g", + "% 10.5g", + "%+22.9g", + "%+4.9g", + "%01.3g", + "%4g", + "%3.1g", + "%3.2g", + "%.0g", + "%.1g", + + "%-1.5e", + "%1.5e", + "%123.9e", + "%10.5e", + "% 10.5e", + "%+22.9e", + "%+4.9e", + "%01.3e", + "%4e", + "%3.1e", + "%3.2e", + "%.0e", + "%.1e", + NULL }; double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, ! 0.9996, 1.996, 4.136, 644245294.1234, 0}; char *int_fmt[] = { "%-1.5d", "%1.5d", *************** *** 900,904 **** } printf ("%d tests failed out of %d.\n", fail, num); } ! #endif /* SNPRINTF_TEST */ ! --- 1102,1105 ---- } printf ("%d tests failed out of %d.\n", fail, num); } ! #endif /* TEST_SNPRINTF */ *** lib/util.c Wed Nov 10 21:36:02 1999 --- /new/lib/util.c Tue Nov 16 19:32:49 1999 *************** *** 1582,1587 **** --- 1582,1594 ---- ****************************************************************************/ void become_daemon(void) { + #ifdef AMIGA + { + DEBUG(2,("Warning: become_daemon() not done.\n")); + return; + } + #endif /* AMIGA */ + if (fork()) { _exit(0); } *** lib/interface.c Wed Oct 13 00:26:48 1999 --- /new/lib/interface.c Sat Nov 20 16:01:23 1999 *************** *** 234,243 **** n = get_interfaces(ifaces, MAX_INTERFACES); ! if (n != total_probed || ! memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n)) { ! return True; } return False; } --- 234,255 ---- n = get_interfaces(ifaces, MAX_INTERFACES); ! /* olsen: probed_ifaces can be NULL! */ ! #ifdef AMIGA ! { ! if (n != total_probed || ! (probed_ifaces != NULL && memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n))) { ! return True; ! } } + #else + { + if (n != total_probed || + memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n)) { + return True; + } + } + #endif return False; } *** lib/interfaces.c Fri Sep 24 18:42:05 1999 --- /new/lib/interfaces.c Fri Dec 03 09:14:02 1999 *************** *** 331,336 **** --- 331,345 ---- return total; } + #elif defined(AMIGA) + + static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) + { + extern int amiga_get_interfaces(struct iface_struct * ifaces,int max_interfaces); + + return(amiga_get_interfaces(ifaces,max_interfaces)); + } + #else /* a dummy version */ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) { *** libsmb/clientgen.c Wed Nov 10 21:36:03 1999 --- /new/libsmb/clientgen.c Tue Nov 16 19:32:53 1999 *************** *** 872,878 **** pstrcpy(p,workgroup); strupper(p); p = skip_string(p,1); ! pstrcpy(p,"Unix");p = skip_string(p,1); pstrcpy(p,"Samba");p = skip_string(p,1); set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False); } --- 872,886 ---- pstrcpy(p,workgroup); strupper(p); p = skip_string(p,1); ! #ifdef AMIGA ! { ! pstrcpy(p,"AmigaOS");p = skip_string(p,1); ! } ! #else ! { ! pstrcpy(p,"Unix");p = skip_string(p,1); ! } ! #endif /* AMIGA */ pstrcpy(p,"Samba");p = skip_string(p,1); set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False); } *** smbd/reply.c Wed Nov 10 21:36:11 1999 --- /new/smbd/reply.c Tue Nov 16 19:32:54 1999 *************** *** 955,961 **** char *p; set_message(outbuf,3,3,True); p = smb_buf(outbuf); ! pstrcpy(p,"Unix"); p = skip_string(p,1); pstrcpy(p,"Samba "); pstrcat(p,VERSION); p = skip_string(p,1); pstrcpy(p,global_myworkgroup); p = skip_string(p,1); set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False); --- 955,969 ---- char *p; set_message(outbuf,3,3,True); p = smb_buf(outbuf); ! #ifdef AMIGA ! { ! pstrcpy(p,"AmigaOS"); p = skip_string(p,1); ! } ! #else ! { ! pstrcpy(p,"Unix"); p = skip_string(p,1); ! } ! #endif /* AMIGA */ pstrcpy(p,"Samba "); pstrcat(p,VERSION); p = skip_string(p,1); pstrcpy(p,global_myworkgroup); p = skip_string(p,1); set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False); *** web/swat.c Wed Nov 10 21:36:19 1999 --- /new/web/swat.c Tue Nov 16 19:32:55 1999 *************** *** 965,972 **** if (!dbf) dbf = stderr; /* we don't want stderr screwing us up */ ! close(2); ! open("/dev/null", O_WRONLY); while ((opt = getopt(argc, argv,"s:a")) != EOF) { switch (opt) { --- 965,976 ---- if (!dbf) dbf = stderr; /* we don't want stderr screwing us up */ ! #ifndef AMIGA ! { ! close(2); ! open("/dev/null", O_WRONLY); ! } ! #endif /* AMIGA */ while ((opt = getopt(argc, argv,"s:a")) != EOF) { switch (opt) {