Changeset 126 for branches/samba-3.0/source/ndpsmb/ndpsmb.c
- Timestamp:
- Apr 7, 2008, 9:33:39 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/ndpsmb/ndpsmb.c
r123 r126 12 12 #define NULL ((void *)0) 13 13 14 #ifndef DEBUG_PRINTF 15 #define debug_printf( ...) 16 #endif 17 14 18 void log(const char *fmt, ...) 15 19 { … … 39 43 } 40 44 45 // ------------------------------------------------------------- 46 47 /* time conversion functions: SMB protocol sends timestamps in GMT time, 48 * os2 api uses localtime, 49 * emx/klibc uses timezone and daylight saving to convert GMT timestamps, 50 * so only the timezone must be counted in conversion. 51 */ 52 void fsphUnixTimeToDosDate( time_t time, FDATE* fdate, FTIME *ftime) 53 { 54 struct tm* gmt = localtime( &time); 55 if (gmt->tm_isdst>0) { 56 debug_printf( "daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone); 57 time -= 3600; 58 gmt = localtime( &time); 59 } 60 fdate->day = gmt->tm_mday; 61 fdate->month = gmt->tm_mon+1; 62 fdate->year = gmt->tm_year + 1900 - 1980; 63 ftime->twosecs = gmt->tm_sec/2; 64 ftime->minutes = gmt->tm_min; 65 ftime->hours = gmt->tm_hour; 66 } 67 68 void fsphDosDateToUnixTime( FDATE fdate, FTIME ftime, unsigned long* time) 69 { 70 struct tm gmtime = { 0 }; 71 struct tm* gmt; 72 73 debug_printf( "fsphDosDateToUnixTime time %02d:%02d\n", ftime.hours, ftime.minutes); 74 gmtime.tm_mday = fdate.day; 75 gmtime.tm_mon = fdate.month-1; 76 gmtime.tm_year = fdate.year + 1980 - 1900; 77 gmtime.tm_sec = ftime.twosecs*2; 78 gmtime.tm_min = ftime.minutes; 79 gmtime.tm_hour = ftime.hours; 80 gmtime.tm_isdst = -1; // force libc to check dst saving 81 82 *time = mktime( &gmtime); 83 debug_printf( "fsphDosDateToUnixTime time1 %d %s", *time, ctime( time)); 84 gmt = localtime( (time_t*) time); 85 if (gmt->tm_isdst>0) { 86 debug_printf( "fsphDosDateToUnixTime daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone); 87 *time += 3600; 88 } 89 debug_printf( "fsphDosDateToUnixTime time2 %d %s", *time, ctime( time)); 90 } 91 92 // ------------------------------------------------------------- 93 41 94 int StrLen(char * s) 42 95 { … … 339 392 stat->attrFile = (finfo->attr & 0x37); 340 393 341 ph->fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);342 ph->fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);343 ph->fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);394 fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite); 395 fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation); 396 fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess); 344 397 } 345 398 … … 369 422 stat.attrFile = (finfo->attr & 0x37); 370 423 371 ph->fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite); 372 ph->fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation); 373 ph->fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess); 424 fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite); 425 fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation); 426 fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess); 427 debug_printf( "fname %s\n", finfo->fname); 428 debug_printf( "mtime %d %s", finfo->mtime, ctime( &finfo->mtime)); 429 debug_printf( "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2); 374 430 375 431 ph->fsphAddFile32L(plist, &stat, name, StrLen(name), finfo, sizeof(*finfo), 0); … … 1179 1235 NDPATHELEMENT *pel = ph->fsphNameElem(0); 1180 1236 1181 log("NdpFindStart in\n");1237 debug_printf("NdpFindStart in\n"); 1182 1238 do 1183 1239 { … … 1282 1338 do 1283 1339 { 1284 log("NdpQueryInfo in <%s>, retry = %d\n", szPath, retry);1340 debug_printf("NdpQueryInfo in <%s>, retry = %d\n", szPath, retry); 1285 1341 1286 1342 do { … … 1414 1470 char path[CCHMAXPATH+1] = {0}; 1415 1471 1416 log("NdpSetPathInfo in\n");1472 debug_printf("NdpSetPathInfo in\n"); 1417 1473 do { 1418 1474 rc = checkconnection(pConn); … … 1431 1487 1432 1488 StrNCpy(finfo->fname, path, sizeof(finfo->fname) - 1); 1433 ph->fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, (unsigned long *)&(finfo->mtime));1489 fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(finfo->mtime)); 1434 1490 if (ifL) 1435 1491 { … … 2140 2196 smbwrp_fileinfo * finfo = (smbwrp_fileinfo *)(pConn->mem + sizeof(pConn->file)); 2141 2197 2142 log("NdpFileQueryInfo in\n");2198 debug_printf("NdpFileQueryInfo in\n"); 2143 2199 do { 2144 2200 if (pConn->file.fd < 0 || !*pConn->file.fname) … … 2381 2437 smbwrp_fileinfo * finfo = (smbwrp_fileinfo *)pConn->mem; 2382 2438 2383 log("NdpFileSetInfo in\n");2439 debug_printf("NdpFileSetInfo in\n"); 2384 2440 do { 2385 2441 if (pConn->file.fd < 0 || !*pConn->file.fname) … … 2404 2460 // deferred setinfo - on closing the file 2405 2461 pConn->file.openattr = attrFile; 2406 ph->fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, (unsigned long *)&(pConn->file.mtime)); 2462 fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(pConn->file.mtime)); 2463 debug_printf("NdpFileSetInfo mtime %d\n", pConn->file.mtime); 2407 2464 } while (0); 2408 2465 log("NdpFileSetInfo <%s> %08x %d %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, attrFile, rc, pConn->rc);
Note:
See TracChangeset
for help on using the changeset viewer.