Changeset 505 for trunk/client/src/ndpsmb.c
- Timestamp:
- Dec 23, 2010, 2:49:52 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/src/ndpsmb.c
r499 r505 92 92 debug_printf( "fsphDosDateToUnixTime time2 %d %s", *time, ctime( (time_t*)time)); 93 93 } 94 95 // -------------------------------------------------------------96 94 97 int StrLen(char * s)98 {99 char * p;100 if (!s)101 {102 return 0;103 }104 for (p = s; *p; p++);105 return (p - s);106 }107 108 char * StrNCat(char *dst, const char *src, int count)109 {110 int i;111 if (!dst || !src || count <= 0)112 {113 return dst;114 }115 for (i = 0; dst[i]; i++);116 for (;i < count && *src; i++, src++)117 {118 dst[i] = *src;119 }120 dst[i] = 0;121 return dst;122 }123 124 char * StrNCpy(char *dst, const char *src, int count)125 {126 if (!dst || !src || count <= 0)127 {128 return dst;129 }130 *dst = 0;131 return StrNCat(dst, src, count);132 }133 134 char * StrCpy(char *dst, const char *src)135 {136 char * p;137 if (!dst || !src)138 {139 return dst;140 }141 p = dst;142 while (*p++ = *src++);143 return dst;144 }145 146 char * StrCat(char *dst, const char *src)147 {148 int i;149 if (!dst || !src)150 {151 return dst;152 }153 for (i = 0; dst[i]; i++);154 for (; *src; i++, src++)155 {156 dst[i] = *src;157 }158 dst[i] = 0;159 return dst;160 }161 162 void * MemCpy(void * dst, const void * src, int len)163 {164 int i;165 if (!src || !dst || len <= 0)166 {167 return dst;168 }169 for (i = 0; i < len; i++)170 {171 ((char *)dst)[i] = ((char *)src)[i];172 }173 return dst;174 }175 176 void *MemSet(void *dst, char c, int len)177 {178 int i;179 if (!dst || len <= 0)180 {181 return dst;182 }183 for (i = 0; i < len; i++)184 {185 ((char *)dst)[i] = c;186 }187 return dst;188 }189 190 95 // ------------------------------------------------------------- 191 96 … … 269 174 name = pConn->pRes->srv.share_name; 270 175 } 271 StrNCpy(stat->achName, name, CCHMAXPATHCOMP - 1);176 strncpy(stat->achName, name, CCHMAXPATHCOMP - 1); 272 177 stat->cbFile = finfo->size; 273 178 stat->cbFileAlloc = stat->cbFile; 274 179 stat->oNextEntryOffset = 0ul; 275 stat->cchName = StrLen(stat->achName);180 stat->cchName = strlen(stat->achName); 276 181 stat->attrFile = (finfo->attr & 0x37); 277 182 … … 313 218 debug_printf( "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2); 314 219 315 ph->fsphAddFile32L(plist, &stat, name, StrLen(name), finfo, sizeof(*finfo), 0);220 ph->fsphAddFile32L(plist, &stat, name, strlen(name), finfo, sizeof(*finfo), 0); 316 221 return 1; 317 222 } … … 402 307 if (!rc && t && *q) 403 308 { 404 StrNCpy(pRes->srv.workgroup, q, sizeof(pRes->srv.workgroup) - 1);309 strncpy(pRes->srv.workgroup, q, sizeof(pRes->srv.workgroup) - 1); 405 310 pRes->rootlevel = 1; 406 311 } … … 410 315 if (!rc && t && *q) 411 316 { 412 StrNCpy(pRes->srv.server_name, q, sizeof(pRes->srv.server_name) - 1);317 strncpy(pRes->srv.server_name, q, sizeof(pRes->srv.server_name) - 1); 413 318 pRes->rootlevel = 2; 414 319 } … … 418 323 if (!rc && t && *q) 419 324 { 420 StrNCpy(pRes->srv.share_name, q, sizeof(pRes->srv.share_name) - 1);325 strncpy(pRes->srv.share_name, q, sizeof(pRes->srv.share_name) - 1); 421 326 pRes->rootlevel = 3; 422 327 } … … 426 331 if (!rc && t && *q) 427 332 { 428 StrNCpy(pRes->srv.username, q, sizeof(pRes->srv.username) - 1);333 strncpy(pRes->srv.username, q, sizeof(pRes->srv.username) - 1); 429 334 } 430 335 … … 433 338 if (!rc && t && *q) 434 339 { 435 StrNCpy(pRes->srv.password, q, sizeof(pRes->srv.password) - 1);340 strncpy(pRes->srv.password, q, sizeof(pRes->srv.password) - 1); 436 341 defaultPassword = 0; 437 342 } … … 450 355 if (*p) 451 356 { 452 StrNCpy(pRes->srv.password, p, sizeof(pRes->srv.password) - 1);357 strncpy(pRes->srv.password, p, sizeof(pRes->srv.password) - 1); 453 358 454 359 /* clear the plain password */ … … 471 376 if (!rc && t && *q) 472 377 { 473 StrNCpy(pRes->srv.master, q, sizeof(pRes->srv.master) - 1);378 strncpy(pRes->srv.master, q, sizeof(pRes->srv.master) - 1); 474 379 } 475 380 … … 537 442 if (iftestpath(path)) 538 443 { 539 StrCpy(result, "\\A.+,;=[].B");444 strcpy(result, "\\A.+,;=[].B"); 540 445 return NO_ERROR; 541 446 } … … 560 465 if (!p) 561 466 { 562 p = path + StrLen(path);563 } 564 if ( StrLen(tmp->workgroup) != p - path467 p = path + strlen(path); 468 } 469 if (strlen(tmp->workgroup) != p - path 565 470 || (p == path || ph->fsphStrNICmp(path, tmp->workgroup, p - path))) 566 471 { 567 StrNCpy(tmp->workgroup, path, p - path);472 strncpy(tmp->workgroup, path, p - path); 568 473 tmp->workgroup[p - path] = 0; 569 474 newlevel = 1; … … 577 482 if (!p) 578 483 { 579 p = path + StrLen(path);580 } 581 if ( StrLen(tmp->server_name) != p - path484 p = path + strlen(path); 485 } 486 if (strlen(tmp->server_name) != p - path 582 487 || (p == path || ph->fsphStrNICmp(path, tmp->server_name, p - path))) 583 488 { 584 StrNCpy(tmp->server_name, path, p - path);489 strncpy(tmp->server_name, path, p - path); 585 490 tmp->server_name[p - path] = 0; 586 491 newlevel = 1; … … 594 499 if (!p) 595 500 { 596 p = path + StrLen(path);597 } 598 if ( StrLen(tmp->share_name) != (p - path)501 p = path + strlen(path); 502 } 503 if (strlen(tmp->share_name) != (p - path) 599 504 || (p == path || ph->fsphStrNICmp(path, tmp->share_name, p - path))) 600 505 { 601 StrNCpy(tmp->share_name, path, p - path);506 strncpy(tmp->share_name, path, p - path); 602 507 tmp->share_name[p - path] = 0; 603 508 newlevel = 1; … … 623 528 } 624 529 625 StrCpy(result, "\\");626 StrNCat(result, path, CCHMAXPATH);530 strcpy(result, "\\"); 531 strncat(result, path, CCHMAXPATH); 627 532 628 533 return rc; … … 698 603 else 699 604 { 700 MemSet(pRes, 0, sizeof(Resource));605 memset(pRes, 0, sizeof(Resource)); 701 606 //pRes->objany = objany; 702 607 // parse init string … … 728 633 Resource *pRes = (Resource *)resource; 729 634 dircache_delete(pRes->pdc); 730 MemSet(&pRes->srv, 0, sizeof(pRes->srv));635 memset(&pRes->srv, 0, sizeof(pRes->srv)); 731 636 free(pRes); 732 637 debuglocal(9,"NdpFreeResource %d\n", NO_ERROR); … … 791 696 } break; 792 697 } 793 *poutlen = StrLen(s) + 1;698 *poutlen = strlen(s) + 1; 794 699 if (*poutlen > insize) 795 700 { … … 798 703 else 799 704 { 800 MemCpy(pdata, s, *poutlen);705 memcpy(pdata, s, *poutlen); 801 706 } 802 707 … … 885 790 return rc; 886 791 } 887 MemSet(pConn, 0, sizeof(Connection));792 memset(pConn, 0, sizeof(Connection)); 888 793 pConn->pRes = pRes; 889 794 pConn->file.fd = -1; … … 997 902 break; 998 903 } 999 StrNCpy(finfo.fname, path, sizeof(finfo.fname) - 1);904 strncpy(finfo.fname, path, sizeof(finfo.fname) - 1); 1000 905 debuglocal(9,"NdpQueryPathInfo smbwrp_getattr for <%s>\n", path); 1001 906 rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo); … … 1072 977 debug_printf("NdpFindStart in\n"); 1073 978 1074 StrNCpy(dir, szPath, sizeof(dir) - 1);979 strncpy(dir, szPath, sizeof(dir) - 1); 1075 980 if (pel) 1076 981 { 1077 982 mask = pel->name; 1078 dir[ StrLen(szPath) - pel->length] = 0;1079 } 1080 action = StrLen(dir) - 1;983 dir[strlen(szPath) - pel->length] = 0; 984 } 985 action = strlen(dir) - 1; 1081 986 if (dir[action] == '\\') 1082 987 { … … 1088 993 return rc; 1089 994 } 1090 action = StrLen(path) - 1;995 action = strlen(path) - 1; 1091 996 if (path[action] != '\\') 1092 997 { 1093 StrNCat(path, "\\", sizeof(path) - 1);1094 } 1095 StrCpy(dir, path);1096 StrNCat(path, mask, sizeof(path) - 1);998 strncat(path, "\\", sizeof(path) - 1); 999 } 1000 strcpy(dir, path); 1001 strncat(path, mask, sizeof(path) - 1); 1097 1002 1098 1003 // this structure will be used by libsmb callbacks, so we store here all we need … … 1190 1095 } 1191 1096 1192 MemSet(&finfo, 0, sizeof(finfo));1193 1194 StrNCpy(finfo.fname, path, sizeof(finfo.fname) - 1);1097 memset(&finfo, 0, sizeof(finfo)); 1098 1099 strncpy(finfo.fname, path, sizeof(finfo.fname) - 1); 1195 1100 fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(finfo.mtime)); 1196 1101 finfo.attr = pfi->stat.attrFile & 0x37; … … 1243 1148 pfeadest->cbValue = pfea->cbValue; 1244 1149 pfeadest->fEA = 0; 1245 StrCpy((char *)(pfeadest + 1), name);1246 MemCpy((char *)(pfeadest + 1) + pfea->cbName + 1, (char *)(pfea + 1) + pfea->cbName + 1, pfea->cbValue);1150 strcpy((char *)(pfeadest + 1), name); 1151 memcpy((char *)(pfeadest + 1) + pfea->cbName + 1, (char *)(pfea + 1) + pfea->cbName + 1, pfea->cbValue); 1247 1152 pfeadest = (FEA *)((char *)pFEAList + ddone); 1248 1153 } … … 1585 1490 break; 1586 1491 } 1587 l1 = StrLen(szSrc);1588 l2 = StrLen(src);1492 l1 = strlen(szSrc); 1493 l2 = strlen(src); 1589 1494 if (l1 > l2) 1590 1495 { … … 1648 1553 } 1649 1554 1650 StrNCpy(pConn->file.fullname, szFileName, sizeof(pConn->file.fullname) - 1);1651 StrNCpy(pConn->file.fname, path, sizeof(pConn->file.fname) - 1);1555 strncpy(pConn->file.fullname, szFileName, sizeof(pConn->file.fullname) - 1); 1556 strncpy(pConn->file.fname, path, sizeof(pConn->file.fname) - 1); 1652 1557 flags |= O_BINARY; 1653 1558 switch (ulOpenMode & 3) … … 1718 1623 } 1719 1624 1720 MemSet(&finfo, 0, sizeof(finfo));1721 StrNCpy(finfo.fname, path, sizeof(finfo.fname) - 1);1625 memset(&finfo, 0, sizeof(finfo)); 1626 strncpy(finfo.fname, path, sizeof(finfo.fname) - 1); 1722 1627 finfo.attr = usAttr & 0x37; 1723 1628 rc = smbwrp_setattr(pConn->cli, &finfo); … … 1765 1670 break; 1766 1671 } 1767 StrNCpy(finfo.fname, pConn->file.fname, sizeof(finfo.fname) - 1);1672 strncpy(finfo.fname, pConn->file.fname, sizeof(finfo.fname) - 1); 1768 1673 rc = smbwrp_fgetattr(pConn->cli, &pConn->file, &finfo); 1769 1674 if (!rc)
Note:
See TracChangeset
for help on using the changeset viewer.