Changeset 960


Ignore:
Timestamp:
Aug 16, 2016, 5:41:49 PM (9 years ago)
Author:
Silvan Scherrer
Message:

samba client: add the possibility to have logfiles per share

Location:
trunk/client/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/src/debug.c

    r959 r960  
    3131#include <sys/stat.h>
    3232#include "nversion.h"
     33#include "smbwrp.h"
    3334
    34 int debuglevel = 9; // we set it to 9, so we get all messages
    35 char logfile[_MAX_PATH +1];
    36 char debugfile[_MAX_PATH +1];
    37 char logfilename[] = "log.ndpsmb";
    38 BOOL do_logging;
    39 BOOL firstLogLine;
    40 HMTX logMutex;
    41 char nameMutex[] = "\\SEM32\\NDPSMB";
     35void debugInit(Resource *pRes, char *logfileext, int ifL)
     36{
     37        if (!pRes)
     38           return;
    4239
    43 int debuglvl(int level)
    44 {
    45         return (level <= debuglevel) ? 1 : 0;
    46 }
    47 
    48 BOOL writeLog()
    49 {
    50         return do_logging;
    51 }
    52 
    53 void debugInit()
    54 {
    55         *logfile = '\0';
    56         *debugfile = '\0';
    57         do_logging = FALSE;
    58         firstLogLine = TRUE;
    59         logMutex = NULLHANDLE;
    60         struct stat filestat;
     40        pRes->firstLogLine = 1;
     41        pRes->ifL = ifL;
    6142        APIRET rc = NO_ERROR;
    62 
    63         // create the debugfile name
    64         strncat(debugfile, getenv("ETC"), 2);
    65         strncat(debugfile, "\\", sizeof(debugfile) - strlen(debugfile) -1);
    66         strncat(debugfile, "ndpsmb.dbg", sizeof(debugfile) - strlen(debugfile) -1);
    67 
    68         // is the file around? if not we have no debug
    69         if (stat(debugfile, &filestat) !=0)
    70            return;
    7143
    7244        //create the logfile variable
     
    7446        if (env != NULL)
    7547        {
    76            strncat(logfile, env, sizeof(logfile) -1);
    77            strncat(logfile, "\\", sizeof(logfile) - strlen(logfile) -1);
    78            strncat(logfile, logfilename, sizeof(logfile) - strlen(logfile) -1); 
     48           snprintf(pRes->logfile, sizeof(pRes->logfile), "%s/%s.%s", env, "log.ndpsmb", logfileext);
     49           snprintf(pRes->smb_logfile, sizeof(pRes->smb_logfile), "%s/%s.%s", env, "log.smbc", logfileext);
    7950        }
    8051        else
    81            strncat(logfile, logfilename, sizeof(logfile) -1);
    82        
    83         // set the samba logging stuff
    84         do_logging = TRUE;
    85 
    86         // now we create a sem, so that logging from different threads works
    87         rc = DosCreateMutexSem(nameMutex, &logMutex, 0, FALSE);
    88         if (rc == ERROR_DUPLICATE_NAME)
    89            rc = DosOpenMutexSem(nameMutex, &logMutex);
     52        {
     53           snprintf(pRes->logfile, sizeof(pRes->logfile), "%s.%s", "log.ndpsmb", logfileext);
     54           snprintf(pRes->smb_logfile, sizeof(pRes->smb_logfile), "%s.%s", "log.smbc", logfileext);
     55        }
     56        pRes->logfileFH = NULL;
    9057
    9158        return;
     
    9461void debugDelete()
    9562{
    96         DosCloseMutexSem(logMutex);
    9763        return;
    9864}
    9965
    100 void debuglocal(int level, const char * fmt, ...)
     66void debugClose(Resource *pRes)
    10167{
    102         FILE *f=NULL;
     68        if (pRes && pRes->logfileFH)
     69        {
     70           fclose(pRes->logfileFH);
     71           pRes->logfileFH = NULL;
     72        }
     73        return;
     74}
    10375
     76void debuglocal(Resource *pRes, int level, const char * fmt, ...)
     77{
     78        FILE *f = NULL;
    10479        // do we have to log at all
    105         if (!do_logging)
     80        if (pRes && (level > pRes->loglevel))
    10681           return;
    107 
    108         // if the sem is created we request it
    109         if (logMutex)
    110            DosRequestMutexSem(logMutex, (ULONG) SEM_INDEFINITE_WAIT);
    11182
    11283        do {
     
    11485           char buf[80] = {0};
    11586           va_list args;
    116            if (logfile[0])
     87           if (pRes)
    11788           {
    118               f = fopen(logfile, "a");
    119               if (!f)
     89              if (!pRes->logfileFH)
     90                 pRes->logfileFH = fopen(pRes->logfile, "a");
     91              if (!pRes->logfileFH)
    12092                 break;
     93              else
     94                 f = pRes->logfileFH;
    12195           }
    12296           else
     
    12498
    12599           // in the first log line we write our version of the client
    126            if (firstLogLine)
     100           if (pRes && pRes->firstLogLine)
    127101           {
    128102              fprintf(f, "Samba client %s build %s based on %s\n", VERSION, BUILD, smbwrp_getVersion());
    129103              fprintf(f, "This build is maintained by %s\n", VENDOR);
    130               firstLogLine = FALSE;
     104              fprintf(f, "Working with %s bit fileio NDFS\n", pRes->ifL ? "64" : "32");
     105
     106              pRes->firstLogLine = 0;
    131107           }
    132108
     
    137113           vfprintf(f, fmt, args);
    138114           va_end(args);
    139            if (logfile)
    140               fclose(f);
    141115
    142116        } while (0);
    143117
    144         // if the sem is created we release it
    145         if (logMutex)
    146            DosReleaseMutexSem(logMutex);
    147 
    148118        return;
    149119}
  • trunk/client/src/dircache.c

    r958 r960  
    109109       
    110110
    111 static int dceCreate (DirectoryCacheEntry **ppdce, DirectoryCache *pdc, const char *path, int cFiles)
     111static int dceCreate (DirectoryCacheEntry **ppdce, Resource *pRes, const char *path, int cFiles)
    112112{
    113113    DirectoryCacheEntry *pdce = (DirectoryCacheEntry *)malloc(sizeof(DirectoryCacheEntry));
     
    128128    pdce->ulHash = computehash (path);
    129129    pdce->ulLastUpdateTime = 0;
    130     pdce->pdc = pdc;
     130    pdce->pdc = pRes->pdc;
    131131    pdce->fInvalid = 0;
    132132
     
    155155}
    156156
    157 static void dceWriteEntry (DirectoryCacheEntry *pdce, const smbwrp_fileinfo *finfo)
     157static void dceWriteEntry (Resource *pRes, DirectoryCacheEntry *pdce, const smbwrp_fileinfo *finfo)
    158158{
    159159    if (pdce->cInfos >= pdce->cInfosAllocated)
     
    165165                                                                cNewAllocated * sizeof (smbwrp_fileinfo));
    166166
    167         debuglocal(9, "dceWriteEntry: [%s] realloc %d -> %d\n", pdce->pszPath, pdce->cInfosAllocated, cNewAllocated);
     167        debuglocal(pRes, 9, "dceWriteEntry: [%s] realloc %d -> %d\n", pdce->pszPath, pdce->cInfosAllocated, cNewAllocated);
    168168        if (pNewInfos)
    169169        {
     
    183183}
    184184
    185 static void dceAdjust (DirectoryCacheEntry *pdce)
     185static void dceAdjust (Resource *pRes, DirectoryCacheEntry *pdce)
    186186{
    187187    /* If the entry has too many preallocated info structures, adjust the memory allocation */
     
    196196                                                                cNewAllocated * sizeof (smbwrp_fileinfo));
    197197
    198         debuglocal(9, "dceAdjust: [%s] realloc %d -> %d\n", pdce->pszPath, pdce->cInfosAllocated, cNewAllocated);
     198        debuglocal(pRes, 9, "dceAdjust: [%s] realloc %d -> %d\n", pdce->pszPath, pdce->cInfosAllocated, cNewAllocated);
    199199        if (pNewInfos)
    200200        {
     
    209209}
    210210
    211 static int dcePathEqualsTo (DirectoryCacheEntry *pdce, const char *path)
    212 {
    213     debuglocal(9, "dcePathEqualTo: [%s] [%s]\n", path, pdce->pszPath);
     211static int dcePathEqualsTo (Resource *pRes, DirectoryCacheEntry *pdce, const char *path)
     212{
     213    debuglocal(pRes, 9, "dcePathEqualTo: [%s] [%s]\n", path, pdce->pszPath);
    214214    return ph->fsphStrICmp (path, pdce->pszPath) == 0;
    215215}
     
    225225}
    226226               
    227 static struct DirectoryCacheEntry *dcFindDirCache (struct DirectoryCache *pdc, const char *path, int fPrefix)
     227static struct DirectoryCacheEntry *dcFindDirCache (Resource *pRes, const char *path, int fPrefix)
    228228{
    229229    unsigned long hash = computehash (path);
    230230
    231     DirectoryCacheEntry *iter = pdc->pEntriesHead;
    232 
    233     debuglocal(9, "findDirCache: [%s]\n", path);
     231    DirectoryCacheEntry *iter = pRes->pdc->pEntriesHead;
     232
     233    debuglocal(pRes, 9, "findDirCache: [%s]\n", path);
    234234
    235235    while (iter != NULL)
    236236    {
    237         debuglocal(9, "findDirCache: entry [%s]\n", iter->pszPath);
     237        debuglocal(pRes, 9, "findDirCache: entry [%s]\n", iter->pszPath);
    238238        if (fPrefix)
    239239        {
     
    246246        {
    247247            if (    iter->ulHash == hash
    248                  && dcePathEqualsTo (iter, path)
     248                 && dcePathEqualsTo (pRes, iter, path)
    249249               )
    250250            {
     
    255255    }
    256256
    257     debuglocal(9, "findDirCache: %p\n", iter);
     257    debuglocal(pRes, 9, "findDirCache: %p\n", iter);
    258258
    259259    return iter;
     
    363363};
    364364
    365 static int dcExistsInCache (DirectoryCache *pdc, const char *path)
     365static int dcExistsInCache (Resource *pRes, const char *path)
    366366{
    367367    int rc = CacheFault;
    368368       
    369     if (pdc->fEnabled)
    370     {
    371         if (dcFindDirCache (pdc, path, 0) != NULL)
     369    if (pRes->pdc->fEnabled)
     370    {
     371        if (dcFindDirCache (pRes, path, 0) != NULL)
    372372        {
    373373            rc = CacheOk;
    374374        }
    375375       
    376         debuglocal(9, "ExistsInCache: [%s], %d\n", path, rc);
     376        debuglocal(pRes, 9, "ExistsInCache: [%s], %d\n", path, rc);
    377377    }
    378378   
     
    380380}
    381381       
    382 static int dcRead (DirectoryCache *pdc, const char *path,
     382static int dcRead (Resource *pRes, const char *path,
    383383                   PFNADDDIRENTRY fn,
    384384                   filelist_state *state,
     
    387387    int i;
    388388   
     389    DirectoryCache *pdc = pRes->pdc;
    389390    int rc = CacheFault;
    390391       
     
    393394        DirectoryCacheEntry *pdce;
    394395
    395         pdce = dcFindDirCache (pdc, path, 0);
     396        pdce = dcFindDirCache (pRes, path, 0);
    396397       
    397398        if (pdce)
    398399        {
    399             debuglocal(9, "CacheRead: entry %p found for [%s]\n", pdce, path);
     400            debuglocal(pRes, 9, "CacheRead: entry %p found for [%s]\n", pdce, path);
    400401           
    401402            if (fForceCache)
     
    412413                if (dceExpired (pdce, pdc->ulExpirationTime))
    413414                {
    414                     debuglocal(9, "CacheRead: expired\n");
     415                    debuglocal(pRes, 9, "CacheRead: expired\n");
    415416                    dcRemoveEntry (pdce);
    416417                    dceDelete (pdce);
     
    433434        }
    434435       
    435         debuglocal(9, "CacheRead: [%s], %d\n", path, rc);
     436        debuglocal(pRes, 9, "CacheRead: [%s], %d\n", path, rc);
    436437    }
    437438   
     
    439440}
    440441
    441 static DirectoryCacheEntry *dcWriteBegin (DirectoryCache *pdc, const char *path, int cFiles)
     442static DirectoryCacheEntry *dcWriteBegin (Resource *pRes, const char *path, int cFiles)
    442443{
    443444    DirectoryCacheEntry *pdce = NULL;
    444445
    445     if (pdc->fEnabled)
    446     {
    447         pdce = dcFindDirCache (pdc, path, 0);
     446    if (pRes->pdc->fEnabled)
     447    {
     448        pdce = dcFindDirCache (pRes, path, 0);
    448449       
    449450        if (!pdce)
    450451        {
    451452            /* Does not exist in the cache yet. */
    452             dceCreate (&pdce, pdc, path, cFiles);
     453            dceCreate (&pdce, pRes, path, cFiles);
    453454        }
    454455        else
     
    465466        }
    466467       
    467         debuglocal(9, "CacheWriteBegin: %s\n", path);
     468        debuglocal(pRes, 9, "CacheWriteBegin: %s\n", path);
    468469    }
    469470   
     
    472473
    473474
    474 static void dcInvalidate (DirectoryCache *pdc, const char *path, int fPrefix)
     475static void dcInvalidate (Resource *pRes, const char *path, int fPrefix)
    475476{
    476477    DirectoryCacheEntry *pdce;
    477478   
    478     debuglocal(9, "CacheInvalidate: [%s]\n", path);
    479 
    480     pdce = dcFindDirCache (pdc, path, fPrefix);
     479    debuglocal(pRes, 9, "CacheInvalidate: [%s]\n", path);
     480
     481    pdce = dcFindDirCache (pRes, path, fPrefix);
    481482
    482483    while (pdce)
     
    485486        dceDelete (pdce);
    486487       
    487         pdce = dcFindDirCache (pdc, path, fPrefix);
    488     }
    489 }
    490 
    491 static int dcFindPath (DirectoryCache *pdc,
     488        pdce = dcFindDirCache (pRes, path, fPrefix);
     489    }
     490}
     491
     492static int dcFindPath (Resource *pRes, DirectoryCache *pdc,
    492493                       const char *path,
    493494                       const char *parent,
     
    500501    unsigned long hash = computehash (parent);
    501502
    502     debuglocal(9, "dcFindPath: [%s][%s]\n", parent, name);
     503    debuglocal(pRes, 9, "dcFindPath: [%s][%s]\n", parent, name);
    503504
    504505    while (pdce != NULL)
    505506    {
    506         debuglocal(9, "dcFindPath: entry [%s]\n", pdce->pszPath);
     507        debuglocal(pRes, 9, "dcFindPath: entry [%s]\n", pdce->pszPath);
    507508
    508509        if (   pdce->ulHash == hash
    509             && dcePathEqualsTo (pdce, parent))
     510            && dcePathEqualsTo (pRes, pdce, parent))
    510511        {
    511512            /* This entry should contain the path. */
     
    517518                    *finfo = pdce->aInfos[i];
    518519                    *pulAge = timesec () - pdce->ulLastUpdateTime;
    519                     debuglocal(9, "dircache: FindPath %s found, age %d\n", path, *pulAge);
     520                    debuglocal(pRes, 9, "dircache: FindPath %s found, age %d\n", path, *pulAge);
    520521                    return 1;
    521522                }
     
    526527    }
    527528
    528     debuglocal(9, "dircache: FindPath %s not found\n", path);
     529    debuglocal(pRes, 9, "dircache: FindPath %s not found\n", path);
    529530    return 0;
    530531}
     
    561562 */
    562563
    563 int dircache_create(DirectoryCache **ppdc, unsigned long ulExpirationTime, int cMaxEntries)
    564 {
     564int dircache_create(Resource *pRes)
     565{
     566    struct DirectoryCache **ppdc = &pRes->pdc;
     567    unsigned long ulExpirationTime = pRes->cachetimeout;
     568    int cMaxEntries = pRes->cachedepth;
    565569    int rc;
    566570
    567     debuglocal(9, "dircache_create: %u seconds, %d entries\n", ulExpirationTime, cMaxEntries);
     571    debuglocal(pRes, 9, "dircache_create: %u seconds, %d entries\n", ulExpirationTime, cMaxEntries);
    568572
    569573    rc = dcCreate(ppdc);
     
    574578    }
    575579
    576     debuglocal(9, "dircache_create: %p, rc = %d\n", *ppdc, rc);
     580    debuglocal(pRes, 9, "dircache_create: %p, rc = %d\n", *ppdc, rc);
    577581    return rc;
    578582}
    579583
    580 void dircache_delete(DirectoryCache *pdc)
    581 {
    582     debuglocal(9, "dircache_delete: %p\n", pdc);
     584void dircache_delete(Resource *pRes)
     585{
     586    DirectoryCache *pdc = pRes->pdc;
     587    debuglocal(pRes, 9, "dircache_delete: %p\n", pdc);
    583588
    584589    if (pdc)
     
    603608    }
    604609
    605     debuglocal(9, "dircache_list_files [%s]\n", path);
     610    debuglocal(state->pConn->pRes, 9, "dircache_list_files [%s]\n", path);
    606611
    607612    if (!pdc)
     
    612617    lockRequest (pdc->mutex);
    613618
    614     rc = dcRead (pdc, path, fn, state, ptotal_received, 0);
     619    rc = dcRead (state->pConn->pRes, path, fn, state, ptotal_received, 0);
    615620
    616621    lockRelease (pdc->mutex);
     
    632637    }
    633638
    634     debuglocal(9, "dircache_write_begin pdc %p path [%s]\n", pdc, path);
     639    debuglocal(state->pConn->pRes, 9, "dircache_write_begin pdc %p path [%s]\n", pdc, path);
    635640
    636641    if (!pdc)
     
    650655    }
    651656   
    652     pdce = dcWriteBegin (pdc, path, cFiles);
     657    pdce = dcWriteBegin (state->pConn->pRes, path, cFiles);
    653658   
    654659    lockRelease (pdc->mutex);
    655660
    656     debuglocal(9, "dircache_write_begin returning ctx %p\n", pdce);
     661    debuglocal(state->pConn->pRes, 9, "dircache_write_begin returning ctx %p\n", pdce);
    657662    return (void *)pdce;
    658663}
    659664
    660 void dircache_write_entry(void *dircachectx, const smbwrp_fileinfo *finfo)
     665void dircache_write_entry(Resource *pRes, void *dircachectx, const smbwrp_fileinfo *finfo)
    661666{
    662667    DirectoryCacheEntry *pdce = (DirectoryCacheEntry *)dircachectx;
    663668
    664     debuglocal(9, "dircache_write_entry %p\n", pdce);
     669    debuglocal(pRes, 9, "dircache_write_entry %p\n", pdce);
    665670   
    666671    if (!pdce)
     
    671676    lockRequest (pdce->pdc->mutex);
    672677   
    673     dceWriteEntry (pdce, finfo);
     678    dceWriteEntry (pRes, pdce, finfo);
    674679   
    675680    lockRelease (pdce->pdc->mutex);
    676681}
    677682
    678 void dircache_write_end(void *dircachectx)
     683void dircache_write_end(Resource *pRes, void *dircachectx)
    679684{
    680685    DirectoryCacheEntry *pdce = (DirectoryCacheEntry *)dircachectx;
    681686    DirectoryCache *pdc;
    682687
    683     debuglocal(9, "dircache_write_end: pdce %p\n", pdce);
     688    debuglocal(pRes, 9, "dircache_write_end: pdce %p\n", pdce);
    684689
    685690    if (!pdce)
     
    699704    else
    700705    {
    701         dceAdjust (pdce);
     706        dceAdjust (pRes, pdce);
    702707        dcInsertEntry (pdce);
    703708    }
     
    707712
    708713void dircache_invalidate(const char *path,
    709                          struct DirectoryCache *pdc,
     714                         Resource *pRes,
    710715                         int fParent)
    711716{
    712     debuglocal(9, "dircache_invalidate [%s], parent %d\n", path, fParent);
     717    struct DirectoryCache *pdc = pRes->pdc;
     718    debuglocal(pRes, 9, "dircache_invalidate [%s], parent %d\n", path, fParent);
    713719
    714720    if (!pdc)
     
    728734        {
    729735            *lastSlash = 0;
    730             dcInvalidate (pdc, p, 0);
     736            dcInvalidate (pRes, p, 0);
    731737        }
    732738        else
    733739        {
    734             dcInvalidate (pdc, "", 0);
     740            dcInvalidate (pRes, "", 0);
    735741        }
    736742    }
    737743    else
    738744    {
    739         dcInvalidate (pdc, path, 0);
     745        dcInvalidate (pRes, path, 0);
    740746    }
    741747   
     
    745751}
    746752
    747 int dircache_find_path(struct DirectoryCache *pdc,
     753int dircache_find_path(Resource *pRes,
    748754                       const char *path,
    749755                       smbwrp_fileinfo *finfo,
    750756                       unsigned long *pulAge)
    751757{
     758    struct DirectoryCache *pdc = pRes->pdc;
    752759    int cb;
    753760    char *p;
     
    755762    int fFound = 0;
    756763
    757     debuglocal(9, "dircache_find_path [%s]\n", path);
     764    debuglocal(pRes, 9, "dircache_find_path [%s]\n", path);
    758765
    759766    if (!pdc)
     
    778785    {
    779786        *lastSlash = 0;
    780         fFound = dcFindPath (pdc, path, p, lastSlash + 1, finfo, pulAge);
     787        fFound = dcFindPath (pRes, pdc, path, p, lastSlash + 1, finfo, pulAge);
    781788    }
    782789    else
    783790    {
    784791        /* Find in the root directory. p is the name. */
    785         fFound = dcFindPath (pdc, path, "", p, finfo, pulAge);
     792        fFound = dcFindPath (pRes, pdc, path, "", p, finfo, pulAge);
    786793    }
    787794   
  • trunk/client/src/help/changelog.txt

    r883 r960  
    912912:ul.
    913913#endif
     914
    914915 <$UL>beta1:
    915916#ifndef txt
     
    930931#endif
    931932
     933 <$UL>GA:
     934#ifndef txt
     935:ul compact.
     936#endif
     937#ifdef en
     938   <$LI> added the possibility to create logfiles per share
     939#endif
     940#ifdef fr
     941   <$LI> added the possibility to create logfiles per share
     942#endif
     943#ifdef de
     944   <$LI> M”glichkeit um Logfiles pro Freigabe zu erstellen hinzugefgt
     945#endif
     946
    932947#ifndef txt
    933948:eul.:eul.
  • trunk/client/src/ndpsmb.c

    r959 r960  
    3535
    3636/* time conversion functions: SMB protocol sends timestamps in GMT time,
    37 * os2 api uses localtime,
    38 * emx/klibc uses timezone and daylight saving to convert GMT timestamps,
    39 * so only the timezone must be counted in conversion.
    40 */
    41 void fsphUnixTimeToDosDate( time_t time, FDATE* fdate, FTIME *ftime)
     37 * os2 api uses localtime,
     38 * emx/klibc uses timezone and daylight saving to convert GMT timestamps,
     39 * so only the timezone must be counted in conversion.
     40 */
     41void fsphUnixTimeToDosDate(Resource *pRes, time_t time, FDATE* fdate, FTIME *ftime)
    4242{
    4343        struct tm* gmt = localtime( &time);
     
    4545        if (gmt->tm_isdst>0)
    4646        {
    47            debuglocal(9, "daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
     47           debuglocal(pRes, 9, "daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
    4848           time -= 3600;
    4949           gmt = localtime( &time);
     
    5656        ftime->minutes = gmt->tm_min;
    5757        ftime->hours = gmt->tm_hour;
    58 }
    59 
    60 void fsphDosDateToUnixTime( FDATE fdate, FTIME ftime, ULONG* time)
     58        return;
     59}
     60
     61void fsphDosDateToUnixTime(Resource *pRes, FDATE fdate, FTIME ftime, ULONG* time)
    6162{
    6263        struct tm gmtime = { 0 };
    6364
    64         debuglocal(9, "fsphDosDateToUnixTime time %02d:%02d:%02d\n", ftime.hours, ftime.minutes, ftime.twosecs*2);
     65        debuglocal(pRes, 9, "fsphDosDateToUnixTime time %02d:%02d:%02d\n", ftime.hours, ftime.minutes, ftime.twosecs*2);
    6566        gmtime.tm_mday = fdate.day;
    6667        gmtime.tm_mon = fdate.month-1;
     
    7273
    7374        *time = mktime( &gmtime);
    74         debuglocal(9, "fsphDosDateToUnixTime time1 %d %s", *time, ctime( (time_t*)time));
     75        debuglocal(pRes, 9, "fsphDosDateToUnixTime time1 %d %s", *time, ctime( (time_t*)time));
    7576#if 0 // as mktime() already does dst we don't need to add something
    7677        struct tm* gmt;
     
    7879        if (gmt->tm_isdst>0)
    7980        {
    80            debuglocal(9, "fsphDosDateToUnixTime daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
     81           debuglocal(pRes, 9, "fsphDosDateToUnixTime daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
    8182           *time += 3600;
    8283        }
    83         debuglocal(9, "fsphDosDateToUnixTime time2 %d %s", *time, ctime( (time_t*)time));
     84        debuglocal(pRes, 9, "fsphDosDateToUnixTime time2 %d %s", *time, ctime( (time_t*)time));
    8485#endif
     86        return;
    8587}
    8688       
     
    111113        {ND_PROP_ULONG, 0, "CLD", "32"},
    112114        {ND_PROP_ULONG, 0, "EASUPPORT", "1"},
     115        {ND_PROP_ULONG, 0, "LOGLEVEL", "0"},
    113116        {ND_PROP_STRING, 0, NULL, NULL}
    114117};
     
    154157        if (rcLock != NO_ERROR)     \
    155158           return rcLock;           \
     159        smbwrp_Logging(pRes);       \
    156160} while (0)
    157161
     
    165169#endif
    166170
    167 int helperEASet (cli_state *cli, FEALIST *pFEAList, char *path)
     171int helperEASet (Resource *pRes, cli_state *cli, FEALIST *pFEAList, char *path)
    168172{
    169173        int rc = 0;
     
    181185           while (done < pFEAList->cbList)
    182186           {
    183               rc = smbwrp_setea(cli, path, (char*)(pfea + 1), pfea->cbValue ? (char *)(pfea + 1) + pfea->cbName + 1: NULL, pfea->cbValue);
     187              rc = smbwrp_setea(pRes, cli, path, (char*)(pfea + 1), pfea->cbValue ? (char *)(pfea + 1) + pfea->cbName + 1: NULL, pfea->cbValue);
    184188              if (rc)
    185189                 break;
     
    201205
    202206        lockInit();
    203         debugInit();
    204         debuglocal(9,"Working with %s bit fileio NDFS\n", ifL ? "64" : "32");
    205207        return NO_ERROR;
    206208}
     
    234236        stat->attrFile = (finfo->attr & 0x37);
    235237
    236         fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);
    237         fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);
    238         fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);
     238        fsphUnixTimeToDosDate(pConn->pRes, finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);
     239        fsphUnixTimeToDosDate(pConn->pRes, finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);
     240        fsphUnixTimeToDosDate(pConn->pRes, finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);
    239241        return;
    240242}
     
    259261        stat.attrFile = (finfo->attr & 0x37);
    260262
    261         fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);
    262         fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);
    263         fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);
    264         debuglocal(9, "fname %s\n", finfo->fname);
    265         debuglocal(9, "mtime %d %s", finfo->mtime, ctime( (time_t*)&finfo->mtime));
    266         debuglocal(9, "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2);
     263        fsphUnixTimeToDosDate(pConn->pRes, finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);
     264        fsphUnixTimeToDosDate(pConn->pRes, finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);
     265        fsphUnixTimeToDosDate(pConn->pRes, finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);
     266        debuglocal(pConn->pRes, 9, "fname %s\n", finfo->fname);
     267        debuglocal(pConn->pRes, 9, "mtime %d %s", finfo->mtime, ctime( (time_t*)&finfo->mtime));
     268        debuglocal(pConn->pRes, 9, "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2);
    267269
    268270        ph->fsphAddFile32L(plist, &stat, name, strlen(name), finfo, sizeof(*finfo), 0);
     
    344346#endif
    345347        pRes->pdc = NULL;
     348        pRes->loglevel = 0;
    346349
    347350        t = 0, q = NULL;
     
    451454        }
    452455
     456        t = 0;
     457        rc = ph->fsphQueryUlongProperty (properties, "LOGLEVEL", &t);
     458        if (!rc)
     459        {
     460           if (t > 10)
     461              rc = ERROR_INVALID_PARAMETER;
     462           else
     463              pRes->loglevel = t;
     464        }
     465
     466        // figure out the used share/server/workgroup
     467        char *logfileext = '\0';
     468        if (pRes->srv.share_name)
     469           logfileext = pRes->srv.share_name;
     470        if (!logfileext && pRes->srv.server_name)
     471           logfileext = pRes->srv.server_name;
     472        if (!logfileext && pRes->srv.workgroup)
     473           logfileext = pRes->srv.workgroup;
     474
     475        // init debug and write the very first message
     476        debugInit(pRes, logfileext, ifL);
     477        debuglocal(pRes, 9, "NdpMountResource initResource\n");
     478
     479        // init code
     480        smbwrp_init(pRes);
     481
    453482        /*
    454483         * Create a directory cache with expiration time and cache listings
    455484         * the above values come from the gui. default: timeout 10; listings: 32
    456485        */
    457         dircache_create(&pRes->pdc, pRes->cachetimeout, pRes->cachedepth);
     486        dircache_create(pRes);
    458487
    459488        return rc;
     
    562591              // reconnect to server here, first test new connection
    563592              cli_state* tmp_cli = NULL;
    564               rc = smbwrp_connect( &tmpRes, &tmp_cli);
     593              rc = smbwrp_connect(&tmpRes, &tmp_cli);
    565594              if (!rc)
    566595              {
    567596                 // new connection is ok, disconnect old one
    568597                 cli_state* cli = pConn->cli;
    569                  smbwrp_disconnect( pRes, cli);
     598                 smbwrp_disconnect(pRes, cli);
    570599                 // save tmp data structure
    571600                 memcpy( pRes, &tmpRes, sizeof( tmpRes));
     
    582611
    583612/* check if the requested resource is available */
    584 static int checkMountResource( Resource* pRes)
     613static int checkMountResource(Resource* pRes)
    585614{
    586615        int rc;
     
    588617        cli_state* cli = NULL;
    589618
    590         debuglocal(9, "checkMountResource in tid#%d\n", _gettid());
    591         rc = smbwrp_connect( pRes, &cli);
     619        debuglocal(pRes, 9, "checkMountResource in tid#%d\n", _gettid());
     620        rc = smbwrp_connect(pRes, &cli);
    592621        switch (rc)
    593622        {
     
    620649        } /* endswitch */
    621650
    622         smbwrp_disconnect( pRes, cli);
     651        smbwrp_disconnect(pRes, cli);
    623652        return rc;
    624653}
     
    631660
    632661        ENTER();
    633 
    634         debuglocal(9,"NdpMountResource in\n");
    635         // init code
    636         smbwrp_init();
    637662
    638663        /*
     
    666691        }
    667692
    668         debuglocal(9, "NdpMountResource rc=%d\n", rc);
     693        debuglocal(pRes, 9, "NdpMountResource rc=%d\n", rc);
    669694        LEAVE();
    670695        return rc;
     
    675700        Resource *pRes = (Resource *)resource;
    676701        ENTER();
    677         dircache_delete(pRes->pdc);
     702        dircache_delete(pRes);
    678703        memset(&pRes->srv, 0, sizeof(pRes->srv));
     704        debuglocal(pRes, 9, "NdpFreeResource %d\n", NO_ERROR);
     705        debugClose(pRes);
    679706        free(pRes);
    680         debuglocal(9, "NdpFreeResource %d\n", NO_ERROR);
    681707        LEAVE();
    682708        return NO_ERROR;
     
    689715        int rc = ND_RSRC_DIFFERENT;
    690716
    691         debuglocal(9, "NdpRsrcCompare in\n");
     717        debuglocal(pRes, 9, "NdpRsrcCompare in\n");
    692718        if (ph->fsphStrICmp(pRes->srv.server_name, pRes2->srv.server_name) == 0
    693719           && ph->fsphStrICmp(pRes->srv.share_name, pRes2->srv.share_name) == 0
     
    699725        }
    700726
    701         debuglocal(9, "NdpRsrcCompare %d\n", rc);
     727        debuglocal(pRes, 9, "NdpRsrcCompare %d\n", rc);
    702728        return rc;
    703729}
     
    706732{
    707733        // do nothing
    708         debuglocal(9, "NdpRsrcUpdate %d\n", NO_ERROR);
     734        Resource *pRes = (Resource *)resource;
     735        debuglocal(pRes, 9, "NdpRsrcUpdate %d\n", NO_ERROR);
    709736        return NO_ERROR;
    710737}
     
    716743        char s[4096];
    717744
    718         debuglocal(9, "NdpRsrcQueryInfo in\n");
     745        debuglocal(pRes, 9, "NdpRsrcQueryInfo in\n");
    719746
    720747        switch (pRes->rootlevel)
     
    739766           memcpy(pdata, s, *poutlen);
    740767
    741         debuglocal(9, "NdpRsrcQueryInfo %d\n", rc);
     768        debuglocal(pRes, 9, "NdpRsrcQueryInfo %d\n", rc);
    742769        return rc;
    743770}
     
    759786
    760787        ENTER();
    761         debuglocal(9, "NdpRsrcQueryFSAllocate %08x\n", pfsa);
     788        debuglocal(pRes, 9, "NdpRsrcQueryFSAllocate %08x\n", pfsa);
    762789
    763790        if (!pfsa)
     
    767794        }
    768795
    769         debuglocal(9, "NdpRsrcQueryFSAllocate in tid#%d\n", _gettid());
    770         rc = smbwrp_connect( pRes, &cli);
     796        debuglocal(pRes, 9, "NdpRsrcQueryFSAllocate in tid#%d\n", _gettid());
     797        rc = smbwrp_connect(pRes, &cli);
    771798        if (rc)
    772799        {
    773            debuglocal(9, "NdpRsrcQueryFSAllocate smbwrp_connect failed rc=%d\n", rc);   
     800           debuglocal(pRes, 9, "NdpRsrcQueryFSAllocate smbwrp_connect failed rc=%d\n", rc);     
    774801           pfsa->cSectorUnit = 1;
    775802           pfsa->cUnit = 123456;
     
    781808        }
    782809
    783         rc = smbwrp_dskattr( cli, &fsa);
     810        rc = smbwrp_dskattr(pRes, cli, &fsa);
    784811        if (rc)
    785812        {
     
    798825        }
    799826
    800         smbwrp_disconnect( pRes, cli);
    801         debuglocal(9, "NdpRsrcQueryFSAllocate %d/%d (cUnit = %d/cUnitAvail = %d/cbSector = %d)\n", rc, rc1, pfsa->cUnit, pfsa->cUnitAvail, pfsa->cbSector);
     827        smbwrp_disconnect(pRes, cli);
     828        debuglocal(pRes, 9, "NdpRsrcQueryFSAllocate %d/%d (cUnit = %d/cUnitAvail = %d/cbSector = %d)\n", rc, rc1, pfsa->cUnit, pfsa->cUnitAvail, pfsa->cbSector);
    802829
    803830        LEAVE();
     
    814841        ENTER();
    815842
    816         debuglocal(9, "NdpCreateConnection in\n");
     843        debuglocal(pRes, 9, "NdpCreateConnection in\n");
    817844
    818845        pConn = malloc( sizeof(Connection));
     
    822849        if (rc)
    823850        {
    824            debuglocal(9, "NdpCreateConnection ERROR_NOT_ENOUGH_MEMORY %d\n", rc);
     851           debuglocal(pRes, 9, "NdpCreateConnection ERROR_NOT_ENOUGH_MEMORY %d\n", rc);
    825852           LEAVE();
    826853           return rc;
     
    831858        pConn->file.fd = -1;
    832859
    833         debuglocal(9, "NdpCreateConnection send CONNECT\n");
    834         rc = smbwrp_connect( pRes, &pConn->cli);
     860        debuglocal(pRes, 9, "NdpCreateConnection send CONNECT\n");
     861        rc = smbwrp_connect(pRes, &pConn->cli);
    835862        if (rc)
    836863        {
     
    841868
    842869        *pconn = (HCONNECTION)pConn;
    843         debuglocal(9, "NdpCreateConnection [%p] %d\n", pConn, rc);
     870        debuglocal(pRes, 9, "NdpCreateConnection [%p] %d\n", pConn, rc);
    844871
    845872        LEAVE();
     
    855882        ENTER();
    856883
    857         debuglocal(9, "NdpFreeConnection in [%p]\n", pConn);
     884        debuglocal(pRes, 9, "NdpFreeConnection in [%p]\n", pConn);
    858885        if (pConn->file.fd >= 0)
    859886        {
    860            rc = smbwrp_close( pConn->cli, &pConn->file);
     887           rc = smbwrp_close(pRes, pConn->cli, &pConn->file);
    861888           pConn->file.fd = -1;
    862889        }
    863890
    864         smbwrp_disconnect( pRes, pConn->cli);
    865 
     891        smbwrp_disconnect(pRes, pConn->cli);
     892
     893        debuglocal(pRes, 9, "NdpFreeConnection %d\n", NO_ERROR);
    866894        free(pConn);
    867         debuglocal(9, "NdpFreeConnection %d\n", NO_ERROR);
    868895
    869896        LEAVE();
     
    900927        ENTER();
    901928
    902         debuglocal(9, "NdpQueryPathInfo in [%p] <%s>\n", pConn, szPath);
     929        debuglocal(pRes, 9, "NdpQueryPathInfo in [%p] <%s>\n", pConn, szPath);
    903930       
    904931        /*
     
    915942           // First check if there is information in the directory cache.
    916943           unsigned long ulAge = 0;
    917            if (dircache_find_path(pRes->pdc, szPath, &finfo, &ulAge))
     944           if (dircache_find_path(pRes, szPath, &finfo, &ulAge))
    918945           {
    919946              if (ulAge <= 15) /* @todo configurable. */
     
    927954
    928955           rc = pathparser(pRes, pConn, szPath, path);
    929            debuglocal(9, "NdpQueryPathInfo pathparser for <%s> rc=%d\n", path, rc);
     956           debuglocal(pRes, 9, "NdpQueryPathInfo pathparser for <%s> rc=%d\n", path, rc);
    930957           switch (rc)
    931958           {
     
    944971
    945972           strncpy(finfo.fname, path, sizeof(finfo.fname) - 1);
    946            debuglocal(9, "NdpQueryPathInfo smbwrp_getattr for <%s>\n", path);
    947            rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
     973           debuglocal(pRes, 9, "NdpQueryPathInfo smbwrp_getattr for <%s>\n", path);
     974           rc = smbwrp_getattr(pRes, &pRes->srv, pConn->cli, &finfo);
    948975           if (rc)
    949976           {
     
    952979              {
    953980                 // free current cli resources
    954                  smbwrp_disconnect( pRes, pConn->cli);
     981                 smbwrp_disconnect(pRes, pConn->cli);
    955982                 // reconnect
    956                  rcCon = smbwrp_connect( pRes, &pConn->cli);
     983                 rcCon = smbwrp_connect(pRes, &pConn->cli);
    957984                 if (rcCon != NO_ERROR)
    958                     debuglocal(9, "NdpQueryPathInfo smbwrp_connect rc = %d\n", rcCon);
     985                    debuglocal(pRes, 9, "NdpQueryPathInfo smbwrp_connect rc = %d\n", rcCon);
    959986                 // try file list again if reconnecting worked
    960987                 if (rcCon == NO_ERROR)
    961                     rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
     988                    rc = smbwrp_getattr(pRes, &pRes->srv, pConn->cli, &finfo);
    962989              }
    963990
    964               debuglocal(9, "NdpQueryPathInfo smbwrp_getattr, rc = %d\n", rc);
     991              debuglocal(pRes, 9, "NdpQueryPathInfo smbwrp_getattr, rc = %d\n", rc);
    965992              switch (rc)
    966993              {
     
    9891016              {
    9901017                 *p = 0;
    991                  rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
    992                  debuglocal(9, "NdpQueryPathInfo upper path in <%s>, rc = %d\n",  finfo.fname, rc);
     1018                 rc = smbwrp_getattr(pRes, &pRes->srv, pConn->cli, &finfo);
     1019                 debuglocal(pRes, 9, "NdpQueryPathInfo upper path in <%s>, rc = %d\n",  finfo.fname, rc);
    9931020                 if (rc == NO_ERROR)
    9941021                    rc = (finfo.attr & FILE_DIRECTORY) !=0 ? ERROR_FILE_NOT_FOUND:ERROR_PATH_NOT_FOUND;
     
    9981025           }
    9991026        } while (0);
    1000         debuglocal(9, "NdpQueryPathInfo <%s> (%s) %d\n", szPath, path, rc);
     1027        debuglocal(pRes, 9, "NdpQueryPathInfo <%s> (%s) %d\n", szPath, path, rc);
    10011028
    10021029        LEAVE();
     
    10201047        ENTER();
    10211048
    1022         debuglocal(9, "NdpFindStart in [%p]\n", pConn);
     1049        debuglocal(pRes, 9, "NdpFindStart in [%p]\n", pConn);
    10231050
    10241051        strncpy(dir, szPath, sizeof(dir) - 1);
     
    10761103           strcpy(state.mask, "\\*");
    10771104
    1078         debuglocal(9, "NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
     1105        debuglocal(pRes, 9, "NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
    10791106        state.dir, state.dir_mask, state.mask, state.fullpath);
    1080         rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
     1107        rc = smbwrp_filelist(pRes, &pRes->srv, pConn->cli, &state);
    10811108        /*
    10821109         * we need to handle reconnection also here, because NdpQueryPathInfo
     
    10871114        {
    10881115           // free current cli resources
    1089            smbwrp_disconnect( pRes, pConn->cli);
     1116           smbwrp_disconnect(pRes, pConn->cli);
    10901117           // reconnect
    1091            smbwrp_connect( pRes, &pConn->cli);
     1118           smbwrp_connect(pRes, &pConn->cli);
    10921119           // try file list again next loop
    1093            rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    1094            debuglocal(9, "NdpFindStart remote connection lost, rc = %d\n", rc);
    1095         }
    1096 
    1097         debuglocal(9, "NdpFindStart <%s> (%s) cnt %d %d\n", szPath, path, count, rc);
     1120           rc = smbwrp_filelist(pRes, &pRes->srv, pConn->cli, &state);
     1121           debuglocal(pRes, 9, "NdpFindStart remote connection lost, rc = %d\n", rc);
     1122        }
     1123
     1124        debuglocal(pRes, 9, "NdpFindStart <%s> (%s) cnt %d %d\n", szPath, path, count, rc);
    10981125
    10991126        LEAVE();
     
    11031130int APIENTRY NdpDeletePathInfo (HRESOURCE resource, NDFILEINFOL *pfi)
    11041131{
    1105         debuglocal(9, "NdpDeletePathInfo %d\n", 0);
     1132        Resource * pRes = (Resource *)resource;
     1133        debuglocal(pRes, 9, "NdpDeletePathInfo %d\n", 0);
    11061134        return NO_ERROR;
    11071135}
     
    11091137int APIENTRY NdpRefresh (HCONNECTION conn, char *path, int tree)
    11101138{
    1111         debuglocal(9, "NdpRefresh <%s> %d\n", path, 0);
     1139        Connection *pConn = (Connection *)conn;
     1140        debuglocal(pConn->pRes, 9, "NdpRefresh <%s> %d\n", path, 0);
    11121141        return NO_ERROR;
    11131142}
     
    11211150        */
    11221151
    1123         debuglocal(9, "NdpDicardresourceData %d\n", 0);
     1152        Resource * pRes = (Resource *)resource;
     1153        debuglocal(pRes, 9, "NdpDicardresourceData %d\n", 0);
    11241154        return NO_ERROR;
    11251155}
     
    11361166        ENTER();
    11371167
    1138         debuglocal(9, "NdpSetPathInfo in [%p]\n", pConn);
     1168        debuglocal(pRes, 9, "NdpSetPathInfo in [%p]\n", pConn);
    11391169
    11401170        // delete the dir cache
    1141         dircache_invalidate(szPathName, pRes->pdc, 1);
     1171        dircache_invalidate(szPathName, pRes, 1);
    11421172
    11431173        do {
     
    11481178           memset(&finfo, 0, sizeof(finfo));
    11491179           strncpy(finfo.fname, path, sizeof(finfo.fname) - 1);
    1150            fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(finfo.mtime));
     1180           fsphDosDateToUnixTime(pRes, pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(finfo.mtime));
    11511181           finfo.attr = pfi->stat.attrFile & 0x37;
    1152            rc = smbwrp_setattr(pConn->cli, &finfo);
     1182           rc = smbwrp_setattr(pRes, pConn->cli, &finfo);
    11531183        } while (0);
    11541184
    1155         debuglocal(9, "NdpSetPathInfo <%s> (%s) %d\n", szPathName, path, rc);
    1156 
    1157         LEAVE();
    1158         return rc;
    1159 }
    1160 
    1161 int buildFEALIST(FEALIST *pFEASrc, GEALIST *pGEAList, FEALIST *pFEAList)
     1185        debuglocal(pRes, 9, "NdpSetPathInfo <%s> (%s) %d\n", szPathName, path, rc);
     1186
     1187        LEAVE();
     1188        return rc;
     1189}
     1190
     1191int buildFEALIST(Resource *pRes, FEALIST *pFEASrc, GEALIST *pGEAList, FEALIST *pFEAList)
    11621192{
    11631193        int rc = 0;
     
    11731203        pfeadest = pFEAList->list;
    11741204        dsize = pFEAList->cbList;
    1175         //debuglocal(9,"buildFEALIST in destsize %d srcsize %d pGEAList=%08x pGEAList->cbList=%d\n", dsize, ddone, size, pGEAList, pGEAList ? pGEAList->cbList : 0);
     1205        //debuglocal(pRes, 9,"buildFEALIST in destsize %d srcsize %d pGEAList=%08x pGEAList->cbList=%d\n", dsize, ddone, size, pGEAList, pGEAList ? pGEAList->cbList : 0);
    11761206
    11771207        while (done < size)
     
    11871217              while (done < size)
    11881218              {
    1189                  //debuglocal(9,"comp <%s> <%s>\n", name, pgea->szName);
     1219                 //debuglocal(pRes, 9,"comp <%s> <%s>\n", name, pgea->szName);
    11901220                 if (!ph->fsphStrNCmp(name, pgea->szName, pgea->cbName))
    11911221                 {
     
    12111241           }
    12121242           done += sizeof(FEA) + pfea->cbName + 1 + pfea->cbValue;
    1213            //debuglocal(9,"buuildfea <%s> insert=%d pfea->cbName=%d pfea->cbValue=%d srcdone=%d destdone=%d pfeadest=%08x pfea=%08x\n", name, insert, pfea->cbName, pfea->cbValue, done, ddone, pfeadest, pfea);
     1243           //debuglocal(pRes, 9,"buuildfea <%s> insert=%d pfea->cbName=%d pfea->cbValue=%d srcdone=%d destdone=%d pfeadest=%08x pfea=%08x\n", name, insert, pfea->cbName, pfea->cbValue, done, ddone, pfeadest, pfea);
    12141244           pfea = (FEA *)((char *)pFEASrc + done);
    12151245        }
     
    12191249           rc = ERROR_BUFFER_OVERFLOW;
    12201250
    1221         debuglocal(9, "buildFEALIST rc=%d destsize=%d destdone=%d srcsize=%d pGEAList=%08x\n", rc, dsize, ddone, size, pGEAList);
     1251        debuglocal(pRes, 9, "buildFEALIST rc=%d destsize=%d destdone=%d srcsize=%d pGEAList=%08x\n", rc, dsize, ddone, size, pGEAList);
    12221252        return rc;
    12231253}
     
    12441274        if (rc || !fdata.ulSize || !fdata.pData)
    12451275        {
    1246            debuglocal(9, "NdpEAQuery: ph->fsphGetFileInfoData = %d/%d %08x\n", rc, fdata.ulSize, fdata.pData);
     1276           debuglocal(pRes, 9, "NdpEAQuery: ph->fsphGetFileInfoData = %d/%d %08x\n", rc, fdata.ulSize, fdata.pData);
    12471277           return ERROR_EAS_NOT_SUPPORTED;
    12481278        }
     
    12521282        finfo = (smbwrp_fileinfo *)fdata.pData;
    12531283        path = finfo->fname;
    1254         debuglocal(9, "NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0);
     1284        debuglocal(pRes, 9, "NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0);
    12551285
    12561286        char *pchBuffer = (char *)malloc(cbBuffer);
     
    12621292
    12631293        do {
    1264            rc = smbwrp_listea( pConn->cli, path, pchBuffer, cbBuffer);
     1294           rc = smbwrp_listea(pRes, pConn->cli, path, pchBuffer, cbBuffer);
    12651295           pFEASrc = (FEALIST*) pchBuffer;
    12661296           if (rc)
     
    12811311           }
    12821312           else
    1283               rc = buildFEALIST((FEALIST *)pFEASrc, pGEAList, pFEAList);
     1313              rc = buildFEALIST(pRes, (FEALIST *)pFEASrc, pGEAList, pFEAList);
    12841314        } while (0);
    12851315
    12861316        free(pchBuffer);
    1287         debuglocal(9, "NdpEAQuery <%s> %d %d %d\n", pfi->pszName, rc, pFEASrc->cbList, pFEAList->cbList);
     1317        debuglocal(pRes, 9, "NdpEAQuery <%s> %d %d %d\n", pfi->pszName, rc, pFEASrc->cbList, pFEAList->cbList);
    12881318
    12891319        LEAVE();
     
    13011331        smbwrp_fileinfo *finfo;
    13021332
    1303         debuglocal(9, "NdpEASet in [%p]\n", pConn);
     1333        debuglocal(pRes, 9, "NdpEASet in [%p]\n", pConn);
    13041334
    13051335        if (!pfi || !pfi->pszName)
     
    13121342        if (rc || !fdata.ulSize || !fdata.pData)
    13131343        {
    1314            debuglocal(9, "NdpEASet: ph->fsphGetFileInfoData = %d/%d/%08x\n", rc, fdata.ulSize, fdata.pData);
     1344           debuglocal(pRes, 9, "NdpEASet: ph->fsphGetFileInfoData = %d/%d/%08x\n", rc, fdata.ulSize, fdata.pData);
    13151345           return ERROR_EAS_NOT_SUPPORTED;
    13161346        }
     
    13191349        path = finfo->fname;
    13201350
    1321         rc = helperEASet(pConn->cli, pFEAList, path);
    1322         debuglocal(9, "NdpEASet %d\n", rc);
     1351        rc = helperEASet(pRes, pConn->cli, pFEAList, path);
     1352        debuglocal(pRes, 9, "NdpEASet %d\n", rc);
    13231353        return rc;
    13241354}
     
    13461376        if (rc || !fdata.ulSize || !fdata.pData)
    13471377        {
    1348            debuglocal(9, "NdpEASize: ph->fsphGetFileInfoData = %d/%d/%08x\n", rc, fdata.ulSize, fdata.pData);
     1378           debuglocal(pRes, 9, "NdpEASize: ph->fsphGetFileInfoData = %d/%d/%08x\n", rc, fdata.ulSize, fdata.pData);
    13491379           return ERROR_EAS_NOT_SUPPORTED;
    13501380        }
     
    13591389        {
    13601390           *pulEASize = easize;
    1361            debuglocal(9, "NdpEASize <%s> cached %d\n", path, easize);
     1391           debuglocal(pRes, 9, "NdpEASize <%s> cached %d\n", path, easize);
    13621392           LEAVE();
    13631393           return NO_ERROR;
    13641394        }
    13651395
    1366         debuglocal(9, "NdpEASize in [%p] <%s> \n", pConn, path);
     1396        debuglocal(pRes, 9, "NdpEASize in [%p] <%s> \n", pConn, path);
    13671397
    13681398        char *pchBuffer = (char *)malloc(cbBuffer);
     
    13741404
    13751405        do {
    1376            rc = smbwrp_listea(pConn->cli, path, pchBuffer, cbBuffer);
     1406           rc = smbwrp_listea(pRes, pConn->cli, path, pchBuffer, cbBuffer);
    13771407           pfealist = (FEALIST*)pchBuffer;
    13781408           if (rc)
     
    13941424
    13951425        free(pchBuffer);
    1396         debuglocal(9, "NdpEASize <%s> %d %d\n", pfi->pszName, *pulEASize, rc);
     1426        debuglocal(pRes, 9, "NdpEASize <%s> %d %d\n", pfi->pszName, *pulEASize, rc);
    13971427
    13981428        LEAVE();
     
    14081438        char path[CCHMAXPATH+1] = {0};
    14091439       
    1410         debuglocal(9, "NdpSetCurrentDir in [%p]\n", pConn);
     1440        debuglocal(pRes, 9, "NdpSetCurrentDir in [%p]\n", pConn);
    14111441
    14121442        ENTER();
     
    14171447              break;
    14181448
    1419         rc = smbwrp_chdir(&pRes->srv, pConn->cli, path);
     1449        rc = smbwrp_chdir(pRes, &pRes->srv, pConn->cli, path);
    14201450        } while (0);
    14211451
    1422         debuglocal(9, "NdpSetCurrentDir <%s> (%s) %d\n", szPath, path, rc);
     1452        debuglocal(pRes, 9, "NdpSetCurrentDir <%s> (%s) %d\n", szPath, path, rc);
    14231453
    14241454        LEAVE();
     
    14281458int APIENTRY NdpCopy (HCONNECTION conn, NDFILEINFOL *pfiDst, char *szDst, NDFILEINFOL *pfiSrc, char *szSrc, ULONG ulOption)
    14291459{
    1430         debuglocal(9, "NdpCopy <%s> -> <%s> %d\n", szSrc, szDst, ERROR_CANNOT_COPY);
     1460        Connection *pConn = (Connection *)conn;
     1461        Resource *pRes = pConn->pRes;
     1462        debuglocal(pRes, 9, "NdpCopy <%s> -> <%s> %d\n", szSrc, szDst, ERROR_CANNOT_COPY);
    14311463        return ERROR_CANNOT_COPY;
    14321464}
     
    14341466int APIENTRY NdpCopy2 (HCONNECTION conn, HRESOURCE resDst, NDFILEINFOL *pfiDst, char *szDst, NDFILEINFOL *pfiSrc, char *szSrc, ULONG ulOption)
    14351467{
    1436         debuglocal(9, "NdpCopy2 <%s> -> <%s> %d\n", szSrc, szDst, ERROR_CANNOT_COPY);
     1468        Connection *pConn = (Connection *)conn;
     1469        Resource *pRes = pConn->pRes;
     1470        debuglocal(pRes, 9, "NdpCopy2 <%s> -> <%s> %d\n", szSrc, szDst, ERROR_CANNOT_COPY);
    14371471        return ERROR_CANNOT_COPY;
    14381472}
     
    14481482        ENTER();
    14491483
    1450         debuglocal(9, "NdpForceDelete in [%p]\n", pConn);
    1451 
    1452         dircache_invalidate(szFile, pRes->pdc, 1);
     1484        debuglocal(pRes, 9, "NdpForceDelete in [%p]\n", pConn);
     1485
     1486        dircache_invalidate(szFile, pRes, 1);
    14531487
    14541488        do {
     
    14571491              break;
    14581492
    1459            rc = smbwrp_unlink(pConn->cli, path);
     1493           rc = smbwrp_unlink(pRes, pConn->cli, path);
    14601494        } while (0);
    14611495
    1462         debuglocal(9, "NdpForceDelete <%s> (%s) %d\n", szFile, path, rc);
     1496        debuglocal(pRes, 9, "NdpForceDelete <%s> (%s) %d\n", szFile, path, rc);
    14631497
    14641498        LEAVE();
     
    14771511        ENTER();
    14781512
    1479         debuglocal(9, "NdpCreateDir in [%p]\n", pConn);
    1480 
    1481         dircache_invalidate(szDirName, pRes->pdc, 1);
     1513        debuglocal(pRes, 9, "NdpCreateDir in [%p]\n", pConn);
     1514
     1515        dircache_invalidate(szDirName, pRes, 1);
    14821516
    14831517        do {
     
    14861520              break;
    14871521
    1488            rc = smbwrp_mkdir(pConn->cli, path);
     1522           rc = smbwrp_mkdir(pRes, pConn->cli, path);
    14891523        } while (0);
    14901524
     
    14921526
    14931527        if (path && pRes->easupport)
    1494            rcEASet = helperEASet(pConn->cli, pFEAList, path);
    1495 
    1496         debuglocal(9, "NdpCreateDir <%s> (%s) rc=%d, EASupport=%s rc=%d\n", szDirName, path, rc, pRes->easupport?"yes":"no", rcEASet);
     1528           rcEASet = helperEASet(pRes, pConn->cli, pFEAList, path);
     1529
     1530        debuglocal(pRes, 9, "NdpCreateDir <%s> (%s) rc=%d, EASupport=%s rc=%d\n", szDirName, path, rc, pRes->easupport?"yes":"no", rcEASet);
    14971531
    14981532        return rc;
     
    15091543        ENTER();
    15101544
    1511         debuglocal(9, "NdpDeleteDir in [%p]\n", pConn);
    1512 
    1513         dircache_invalidate(szDir, pRes->pdc, 1);
     1545        debuglocal(pRes, 9, "NdpDeleteDir in [%p]\n", pConn);
     1546
     1547        dircache_invalidate(szDir, pRes, 1);
    15141548
    15151549        do {
     
    15181552              break;
    15191553
    1520            rc = smbwrp_rmdir(pConn->cli, path);
     1554           rc = smbwrp_rmdir(pRes, pConn->cli, path);
    15211555        } while (0);
    15221556
    1523         debuglocal(9, "NdpDeleteDir <%s> (%s) %d\n", szDir, path, rc);
     1557        debuglocal(pRes, 9, "NdpDeleteDir <%s> (%s) %d\n", szDir, path, rc);
    15241558
    15251559        LEAVE();
     
    15391573        ENTER();
    15401574
    1541         debuglocal(9, "NdpMove in [%p] from <%s> to <%s>\n", pConn, szSrc, szDst);
    1542 
    1543         dircache_invalidate(szSrc, pRes->pdc, 1);
    1544         dircache_invalidate(szDst, pRes->pdc, 1);
     1575        debuglocal(pRes, 9, "NdpMove in [%p] from <%s> to <%s>\n", pConn, szSrc, szDst);
     1576
     1577        dircache_invalidate(szSrc, pRes, 1);
     1578        dircache_invalidate(szDst, pRes, 1);
    15451579
    15461580        do
     
    15651599              p = szDst + l1 - l2 + 1;
    15661600           }
    1567            rc = smbwrp_rename(pConn->cli, src, p);
     1601           rc = smbwrp_rename(pRes, pConn->cli, src, p);
    15681602        } while (0);
    15691603
    1570         debuglocal(9, "NdpMove <%s> -> <%s> (%s) %d\n", szSrc, szDst, src, rc);
     1604        debuglocal(pRes, 9, "NdpMove <%s> -> <%s> (%s) %d\n", szSrc, szDst, src, rc);
    15711605
    15721606        LEAVE();
     
    15761610int APIENTRY NdpMove2 (HCONNECTION conn, HRESOURCE resDst, NDFILEINFOL *pfiDst, char *szDst, NDFILEINFOL *pfiSrc, char *szSrc)
    15771611{
    1578         debuglocal(9, "NdpMove2 <%s> -> <%s> %d\n", szSrc, szDst, ERROR_WRITE_PROTECT);
     1612        Connection *pConn = (Connection *)conn;
     1613        Resource *pRes = pConn->pRes;
     1614        debuglocal(pRes, 9, "NdpMove2 <%s> -> <%s> %d\n", szSrc, szDst, ERROR_WRITE_PROTECT);
    15791615        return ERROR_WRITE_PROTECT;
    15801616}
     
    16001636        ENTER();
    16011637
    1602         debuglocal(9, "smbopen in [%p] %d\n", pConn, pConn->file.fd);
     1638        debuglocal(pRes, 9, "smbopen in [%p] %d\n", pConn, pConn->file.fd);
    16031639
    16041640        if (flags & O_CREAT)
    1605            dircache_invalidate(szFileName, pRes->pdc, 1);
     1641           dircache_invalidate(szFileName, pRes, 1);
    16061642
    16071643        do {
     
    16371673           pConn->file.openattr = ulAttribute & 0x37;
    16381674           pConn->file.denymode = (ulOpenMode & 0x70) >> 4;
    1639            rc = smbwrp_open(pConn->cli, &pConn->file);
     1675           rc = smbwrp_open(pConn->pRes, pConn->cli, &pConn->file);
    16401676        } while (0);
    16411677
    1642         debuglocal(9, "smbopen <%s> (%s) %08x %08x %08x %d. file = %d\n", szFileName, path, flags, ulOpenMode, ulAttribute, rc, pConn->file.fd);
     1678        debuglocal(pRes, 9, "smbopen <%s> (%s) %08x %08x %08x %d. file = %d\n", szFileName, path, flags, ulOpenMode, ulAttribute, rc, pConn->file.fd);
    16431679        if (!rc && pFEAList)
    16441680        {
    16451681           int rc1 = NdpFileEASet((HCONNECTION)pConn, (NDFILEHANDLE)0, pFEAList);
    1646            debuglocal(9, "smbopen NdpFileEASet %d. pFEAList->cbList %d\n", rc1, pFEAList->cbList);
     1682           debuglocal(pRes, 9, "smbopen NdpFileEASet %d. pFEAList->cbList %d\n", rc1, pFEAList->cbList);
    16471683        }
    16481684
     
    16901726        ENTER();
    16911727
    1692         debuglocal(9, "NdpSetFileAttribute in [%p]\n", pConn);
     1728        debuglocal(pRes, 9, "NdpSetFileAttribute in [%p]\n", pConn);
    16931729        do {
    16941730           rc = pathparser(pRes, pConn, szFileName, path);
     
    16991735           strncpy(finfo.fname, path, sizeof(finfo.fname) - 1);
    17001736           finfo.attr = usAttr & 0x37;
    1701            rc = smbwrp_setattr(pConn->cli, &finfo);
     1737           rc = smbwrp_setattr(pRes, pConn->cli, &finfo);
    17021738        } while (0);
    17031739
    1704         debuglocal(9, "NdpSetFileAttribute <%s> (%s) %04x %d\n", szFileName, path, usAttr, rc);
     1740        debuglocal(pRes, 9, "NdpSetFileAttribute <%s> (%s) %04x %d\n", szFileName, path, usAttr, rc);
    17051741
    17061742        LEAVE();
     
    17101746int APIENTRY NdpFlush (HRESOURCE resource)
    17111747{
    1712         debuglocal(9, "NdpFlush %d\n", ERROR_NOT_SUPPORTED);
     1748        Resource *pRes = (Resource *)resource;
     1749        debuglocal(pRes, 9, "NdpFlush %d\n", ERROR_NOT_SUPPORTED);
    17131750        return ERROR_NOT_SUPPORTED;
    17141751}
     
    17221759int APIENTRY NdpIOCTL (int type, HRESOURCE resource, char *path, int function, void *in, ULONG insize, PULONG poutlen)
    17231760{
     1761        Resource *pRes = (Resource *)resource;
    17241762        if (function == ND_PL_INIT_THREAD)
    17251763        {
    17261764           smbwrp_initthread();
    1727            debuglocal(9, "NdpIOCTL init thread\n");
     1765           debuglocal(pRes, 9, "NdpIOCTL init thread\n");
    17281766           return NO_ERROR;
    17291767        }
    17301768
    1731         debuglocal(9, "NdpIOCTL <%s> %d\n", path, function);
     1769        debuglocal(pRes, 9, "NdpIOCTL <%s> %d\n", path, function);
    17321770
    17331771        if (in && insize > 4096)
     
    17531791        ENTER();
    17541792
    1755         debuglocal(9, "NdpFileQueryInfo in [%p]\n", pConn);
     1793        debuglocal(pRes, 9, "NdpFileQueryInfo in [%p]\n", pConn);
    17561794        do {
    17571795           if (pConn->file.fd < 0 || !*pConn->file.fname)
     
    17611799           }
    17621800           strncpy(finfo.fname, pConn->file.fname, sizeof(finfo.fname) - 1);
    1763            rc = smbwrp_fgetattr(pConn->cli, &pConn->file, &finfo);
     1801           rc = smbwrp_fgetattr(pRes, pConn->cli, &pConn->file, &finfo);
    17641802           if (!rc)
    17651803           {
     
    17691807        } while (0);
    17701808
    1771         debuglocal(9, "NdpFileQueryInfo <%s> %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, rc);
     1809        debuglocal(pRes, 9, "NdpFileQueryInfo <%s> %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, rc);
    17721810
    17731811        LEAVE();
     
    17891827           return ERROR_EAS_NOT_SUPPORTED;
    17901828
    1791         debuglocal(9, "NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList);
     1829        debuglocal(pRes, 9, "NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList);
    17921830
    17931831        char *pchBuffer = (char *)malloc(cbBuffer);
     
    18031841              break;
    18041842           }
    1805            rc = smbwrp_flistea(pConn->cli, &pConn->file, pchBuffer, cbBuffer);
     1843           rc = smbwrp_flistea(pRes, pConn->cli, &pConn->file, pchBuffer, cbBuffer);
    18061844           pFEASrc = (FEALIST *)pchBuffer;
    18071845           if (rc)
     
    18221860           }
    18231861           else
    1824               rc = buildFEALIST(pFEASrc, pGEAList, pFEAList);
     1862              rc = buildFEALIST(pRes, pFEASrc, pGEAList, pFEAList);
    18251863
    18261864        } while (0);
    18271865
    18281866        free(pchBuffer);
    1829         debuglocal(9, "NdpFileEAQuery out <%s>/%d pFEASrc->cbList=%d pFEAList->cbList=%d rc=%d\n", pConn->file.fname, pConn->file.fd, pFEASrc->cbList, pFEAList->cbList, rc);
     1867        debuglocal(pRes, 9, "NdpFileEAQuery out <%s>/%d pFEASrc->cbList=%d pFEAList->cbList=%d rc=%d\n", pConn->file.fname, pConn->file.fd, pFEASrc->cbList, pFEAList->cbList, rc);
    18301868
    18311869        LEAVE();
     
    18401878        unsigned long action;
    18411879
    1842         debuglocal(9, "NdpFileEASet in [%p]\n", pConn);
     1880        debuglocal(pRes, 9, "NdpFileEASet in [%p]\n", pConn);
    18431881
    18441882        if (!pFEAList || pFEAList->cbList <= sizeof(long))
     
    18631901           while (done < pFEAList->cbList)
    18641902           {
    1865               rc = smbwrp_fsetea(pConn->cli, &pConn->file, (char *)(pfea + 1), pfea->cbValue ? (char *)(pfea + 1) + pfea->cbName + 1: NULL, pfea->cbValue);
     1903              rc = smbwrp_fsetea(pRes, pConn->cli, &pConn->file, (char *)(pfea + 1), pfea->cbValue ? (char *)(pfea + 1) + pfea->cbName + 1: NULL, pfea->cbValue);
    18661904              if (rc)
    18671905                 break;
     
    18731911        } while (0);
    18741912
    1875         debuglocal(9, "NdpFileEASet %d\n", rc);
     1913        debuglocal(pRes, 9, "NdpFileEASet %d\n", rc);
    18761914
    18771915        LEAVE();
     
    18951933           return ERROR_EAS_NOT_SUPPORTED;
    18961934
    1897         debuglocal(9, "NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd);
     1935        debuglocal(pRes, 9, "NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd);
    18981936
    18991937        char *pchBuffer = (char *)malloc(cbBuffer);
     
    19091947              break;
    19101948           }
    1911            rc = smbwrp_flistea(pConn->cli, &pConn->file, pchBuffer, cbBuffer);
     1949           rc = smbwrp_flistea(pRes, pConn->cli, &pConn->file, pchBuffer, cbBuffer);
    19121950           pFEAList = (FEALIST*)pchBuffer;
    19131951           if (rc)
     
    19291967
    19301968        free(pchBuffer);
    1931         debuglocal(9, "NdpFileEASize %d %d\n", *pulEASize, rc);
     1969        debuglocal(pRes, 9, "NdpFileEASize %d %d\n", *pulEASize, rc);
    19321970
    19331971        LEAVE();
     
    19441982        ENTER();
    19451983
    1946         debuglocal(9, "NdpFileSetInfo in [%p]\n", pConn);
     1984        debuglocal(pRes, 9, "NdpFileSetInfo in [%p]\n", pConn);
    19471985
    19481986        // delete the dir cache
    1949         dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
     1987        dircache_invalidate(pConn->file.fullname, pRes, 1);
    19501988
    19511989        do {
     
    19581996           // deferred setinfo - on closing the file
    19591997           pConn->file.openattr = attrFile;
    1960            fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(pConn->file.mtime));
    1961            fsphDosDateToUnixTime(pfi->stat.fdateCreation, pfi->stat.ftimeCreation, &(pConn->file.ctime));
     1998           fsphDosDateToUnixTime(pRes, pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(pConn->file.mtime));
     1999           fsphDosDateToUnixTime(pRes, pfi->stat.fdateCreation, pfi->stat.ftimeCreation, &(pConn->file.ctime));
    19622000           pConn->file.updatetime = 2;
    1963            debuglocal(9, "NdpFileSetInfo mtime %d\n", pConn->file.mtime);
     2001           debuglocal(pRes, 9, "NdpFileSetInfo mtime %d\n", pConn->file.mtime);
    19642002        } while (0);
    19652003
    1966         debuglocal(9, "NdpFileSetInfo <%s> %08x %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, attrFile, rc);
     2004        debuglocal(pRes, 9, "NdpFileSetInfo <%s> %08x %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, attrFile, rc);
    19672005
    19682006        LEAVE();
     
    19792017        ENTER();
    19802018
    1981         debuglocal(9, "NdpFileSetFilePtrL in [%p]\n", pConn);
     2019        debuglocal(pRes, 9, "NdpFileSetFilePtrL in [%p]\n", pConn);
    19822020
    19832021        do {
     
    19882026           }
    19892027
    1990            rc = smbwrp_lseek(pConn->cli, &pConn->file, ulMethod, llOffset);
     2028           rc = smbwrp_lseek(pRes, pConn->cli, &pConn->file, ulMethod, llOffset);
    19912029           if (!rc)
    19922030              *pllActual = pConn->file.offset;
     
    19942032        } while (0);
    19952033
    1996         debuglocal(9, "NdpFileSetFilePtrL <%s> %lld %lu %lld %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llOffset, ulMethod, *pllActual, rc);
     2034        debuglocal(pRes, 9, "NdpFileSetFilePtrL <%s> %lld %lu %lld %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llOffset, ulMethod, *pllActual, rc);
    19972035
    19982036        LEAVE();
     
    20022040int APIENTRY NdpFileSetFilePtr (HCONNECTION conn, NDFILEHANDLE handle, LONG lOffset, ULONG ulMethod, ULONG *pulActual)
    20032041{
     2042        Connection *pConn = (Connection *)conn;
    20042043        LONGLONG llActual;
    20052044        int rc = NdpFileSetFilePtrL(conn, handle, lOffset, ulMethod, &llActual);
    20062045        *pulActual = llActual & 0xFFFFFFFF;
    2007         debuglocal(9, "NdpFileSetFilePtr %ld %lu %ld %d\n", lOffset, ulMethod, *pulActual, rc);
     2046        debuglocal(pConn->pRes, 9, "NdpFileSetFilePtr %ld %lu %ld %d\n", lOffset, ulMethod, *pulActual, rc);
    20082047        return rc;
    20092048}
     
    20182057        ENTER();
    20192058
    2020         debuglocal(9, "NdpFileClose in [%p] %d <%s>\n", pConn, pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
     2059        debuglocal(pRes, 9, "NdpFileClose in [%p] %d <%s>\n", pConn, pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
    20212060
    20222061        do {
     
    20272066           }
    20282067
    2029            rc = smbwrp_close(pConn->cli, &pConn->file);
     2068           rc = smbwrp_close(pRes, pConn->cli, &pConn->file);
    20302069
    20312070        } while (0);
    20322071
    2033         debuglocal(9, "NdpFileClose %d %d\n", pConn->file.fd, rc);
     2072        debuglocal(pRes, 9, "NdpFileClose %d %d\n", pConn->file.fd, rc);
    20342073        pConn->file.fd = -1;
    20352074
     
    20402079int APIENTRY NdpFileCommit (HCONNECTION conn, NDFILEHANDLE handle)
    20412080{
    2042         debuglocal(9, "NdpFileCommit %d\n", NO_ERROR);
     2081        Connection *pConn = (Connection *)conn;
     2082        debuglocal(pConn->pRes, 9, "NdpFileCommit %d\n", NO_ERROR);
    20432083        return NO_ERROR;
    20442084}
     
    20462086int APIENTRY NdpFileNewSize (HCONNECTION conn, NDFILEHANDLE handle, ULONG ulLen)
    20472087{
     2088        Connection *pConn = (Connection *)conn;
    20482089        int rc = NdpFileNewSizeL(conn, handle, ulLen);
    2049         debuglocal(9, "NdpFileNewSize %ld %d\n", ulLen, rc);
     2090        debuglocal(pConn->pRes, 9, "NdpFileNewSize %ld %d\n", ulLen, rc);
    20502091        return rc;
    20512092}
     
    20602101        ENTER();
    20612102
    2062         debuglocal(9, "NdpFileNewSizeL in [%p]\n", pConn);
     2103        debuglocal(pRes, 9, "NdpFileNewSizeL in [%p]\n", pConn);
    20632104
    20642105        do {
     
    20692110           }
    20702111
    2071            rc = smbwrp_setfilesize(pConn->cli, &pConn->file, llLen);
     2112           rc = smbwrp_setfilesize(pRes, pConn->cli, &pConn->file, llLen);
    20722113
    20732114        } while (0);
    20742115
    2075         debuglocal(9, "NdpFileNewSizeL <%s> %lld %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llLen, rc);
     2116        debuglocal(pRes, 9, "NdpFileNewSizeL <%s> %lld %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llLen, rc);
    20762117
    20772118        LEAVE();
     
    20932134        ENTER();
    20942135
    2095         debuglocal(9, "NdpFileRead in [%p]\n", pConn);
     2136        debuglocal(pRes, 9, "NdpFileRead in [%p]\n", pConn);
    20962137
    20972138        do {
     
    21062147              ULONG ulActual;
    21072148              ULONG ulToRead = ulRead - ulReadCompleted;
    2108               debuglocal(9, "NdpFileRead completed %d, to read %d\n", ulReadCompleted, ulToRead);
     2149              debuglocal(pRes, 9, "NdpFileRead completed %d, to read %d\n", ulReadCompleted, ulToRead);
    21092150
    21102151              if (ulToRead > NDPSMB_READ_MAX_SIZE)
    21112152              ulToRead = NDPSMB_READ_MAX_SIZE;
    21122153
    2113               rc = smbwrp_read(pConn->cli, &pConn->file, (char *)pBuffer + ulReadCompleted, ulToRead, &ulActual);
     2154              rc = smbwrp_read(pRes, pConn->cli, &pConn->file, (char *)pBuffer + ulReadCompleted, ulToRead, &ulActual);
    21142155              if (ulActual == 0 || rc != NO_ERROR)
    21152156                 break;
     
    21252166           *pulActual = ulReadCompleted;
    21262167
    2127         debuglocal(9, "NdpFileRead <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulRead, *pulActual, rc);
     2168        debuglocal(pRes, 9, "NdpFileRead <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulRead, *pulActual, rc);
    21282169
    21292170        LEAVE();
     
    21422183        ENTER();
    21432184
    2144         debuglocal(9, "NdpFileWrite in [%p]\n", pConn);
     2185        debuglocal(pRes, 9, "NdpFileWrite in [%p]\n", pConn);
    21452186
    21462187        /*
     
    21512192         * a new function needs to be done to update only one file in the cache
    21522193        */
    2153         dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
     2194        dircache_invalidate(pConn->file.fullname, pRes, 1);
    21542195
    21552196        do {
     
    21592200              break;
    21602201           }
    2161            rc = smbwrp_write(pConn->cli, &pConn->file, pBuffer, ulWrite, pulActual);
     2202           rc = smbwrp_write(pRes, pConn->cli, &pConn->file, pBuffer, ulWrite, pulActual);
    21622203
    21632204        } while (0);
    21642205
    2165         debuglocal(9, "NdpFileWrite <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulWrite, *pulActual, rc);
    2166 
    2167         LEAVE();
    2168         return rc;
    2169 }
     2206        debuglocal(pRes, 9, "NdpFileWrite <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulWrite, *pulActual, rc);
     2207
     2208        LEAVE();
     2209        return rc;
     2210}
  • trunk/client/src/rc/rc.dlg

    r519 r960  
    66DLGTEMPLATE DLG_ID LOADONCALL MOVEABLE DISCARDABLE
    77BEGIN
    8     DIALOG  "", DLG_ID, 24, 44, 253, 187, WS_VISIBLE, FCF_SYSMENU |
     8    DIALOG  "", DLG_ID, 24, 44, 253, 216, WS_VISIBLE, FCF_SYSMENU |
    99            FCF_TITLEBAR
    1010    BEGIN
    11         CTEXT           "SMB resource properties:", LBL_PROP, 197, 151, 12,
     11        CTEXT           "SMB resource properties:", LBL_PROP, 197, 180, 12,
    1212                        10, DT_VCENTER | NOT WS_VISIBLE
    13         LTEXT           "Workgroup:", LBL_WORKGRP, 13, 161, 52, 10,
     13        GROUPBOX        "CIFS/SMB resource properties", GB_PROPERTIES, 5, 152,
     14                        244, 58
     15                        PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
     16                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
     17        LTEXT           "Workgroup:", LBL_WORKGRP, 13, 192, 52, 10,
    1418                        DT_BOTTOM
    15         ENTRYFIELD      "", ENT_WORKGRP, 71, 163, 100, 8, ES_MARGIN
    16         LTEXT           "Server:", LBL_SERVER, 13, 146, 52, 10, DT_BOTTOM
    17         ENTRYFIELD      "", ENT_SERVER, 71, 148, 100, 8, ES_MARGIN
    18         LTEXT           "Share:", LBL_SHARE, 13, 132, 52, 10, DT_BOTTOM
    19         ENTRYFIELD      "", ENT_SHARE, 71, 133, 100, 8, ES_MARGIN
    20         LTEXT           "User ID:", LBL_USER, 13, 100, 53, 10, DT_BOTTOM
    21         ENTRYFIELD      "", ENT_USER, 71, 102, 100, 8, ES_MARGIN
    22         LTEXT           "Password:", LBL_PASS, 13, 87, 53, 10, DT_BOTTOM
    23         ENTRYFIELD      "", ENT_PASS, 71, 88, 100, 8, ES_MARGIN |
     19        ENTRYFIELD      "", ENT_WORKGRP, 71, 192, 100, 8, ES_MARGIN
     20        LTEXT           "Server:", LBL_SERVER, 13, 177, 52, 10, DT_BOTTOM
     21        ENTRYFIELD      "", ENT_SERVER, 71, 177, 100, 8, ES_MARGIN
     22        LTEXT           "Share:", LBL_SHARE, 13, 161, 52, 10, DT_BOTTOM
     23        ENTRYFIELD      "", ENT_SHARE, 71, 161, 100, 8, ES_MARGIN
     24        LTEXT           "Supports EA", LBL_EASUPPORT, 195, 159, 52, 10,
     25                        DT_WORDBREAK
     26        AUTOCHECKBOX    "", CHK_EASUPPORT, 180, 161, 10, 10, WS_GROUP
     27        GROUPBOX        "Login as", GB_LOGIN, 5, 111, 244, 40
     28                        PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
     29                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
     30        LTEXT           "User ID:", LBL_USER, 13, 131, 53, 10, DT_BOTTOM
     31        ENTRYFIELD      "", ENT_USER, 71, 131, 100, 8, ES_MARGIN
     32        LTEXT           "Password:", LBL_PASS, 13, 117, 53, 10, DT_BOTTOM
     33        ENTRYFIELD      "", ENT_PASS, 71, 117, 100, 8, ES_MARGIN |
    2434                        ES_UNREADABLE
    25         ENTRYFIELD      "", ENT_SPASS, 180, 88, 56, 8, ES_MARGIN |
     35        ENTRYFIELD      "", ENT_SPASS, 180, 117, 56, 8, ES_MARGIN |
    2636                        ES_UNREADABLE | NOT WS_TABSTOP | NOT WS_VISIBLE
    27         LTEXT           "Master:", LBL_MASTER, 12, 60, 52, 10, DT_BOTTOM
    28         CONTROL         "", CMB_MASTER, 69, 37, 71, 33, WC_COMBOBOX,
     37        GROUPBOX        "Browse", GB_BROWSE, 5, 82, 244, 26
     38                        PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
     39                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
     40        LTEXT           "Master:", LBL_MASTER, 12, 89, 52, 10, DT_BOTTOM
     41        CONTROL         "", CMB_MASTER, 69, 66, 71, 30, WC_COMBOBOX,
    2942                        CBS_DROPDOWNLIST | WS_GROUP | WS_TABSTOP |
    3043                        WS_VISIBLE
    31         ENTRYFIELD      "", ENT_MASTER, 147, 60, 90, 8, ES_MARGIN
    32         LTEXT           "Supports EA", LBL_EASUPPORT, 195, 130, 52, 10,
    33                         DT_WORDBREAK
    34         AUTOCHECKBOX    "", CHK_EASUPPORT, 180, 132, 10, 10, WS_GROUP
     44        ENTRYFIELD      "", ENT_MASTER, 147, 89, 90, 8, ES_MARGIN
     45        GROUPBOX        "Cache", GB_CACHE, 5, 53, 244, 26
     46                        PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
     47                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
     48        LTEXT           "Cache timeout:", LBL_CACHETIMEOUT, 12, 59, 55, 8, DT_BOTTOM
     49        CONTROL         "", SPIN_CACHETIMEOUT, 69, 59, 32, 12, WC_SPINBUTTON
     50                        SPBS_NUMERICONLY | SPBS_JUSTRIGHT | SPBS_MASTER | WS_GROUP | WS_TABSTOP |
     51                        WS_VISIBLE
     52        LTEXT           "Cache listings:", LBL_CACHEDEPTH, 134, 59, 55, 8, DT_BOTTOM
     53        CONTROL         "", SPIN_CACHEDEPTH, 194, 59, 39, 12, WC_SPINBUTTON
     54                        SPBS_NUMERICONLY | SPBS_JUSTRIGHT | SPBS_MASTER | WS_GROUP | WS_TABSTOP |
     55                        WS_VISIBLE
     56        GROUPBOX        "Logging", GB_CACHE, 5, 24, 244, 26
     57                        PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
     58                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
     59        LTEXT           "Loglevel:", LBL_LOGLEVEL, 12, 30, 55, 8, DT_BOTTOM
     60        CONTROL         "", SPIN_LOGLEVEL, 69, 30, 39, 12, WC_SPINBUTTON
     61                        SPBS_NUMERICONLY | SPBS_JUSTRIGHT | SPBS_MASTER | WS_GROUP | WS_TABSTOP |
     62                        WS_VISIBLE
    3563        PUSHBUTTON      "Cancel", DID_CANCEL, 7, 6, 56, 14
    3664                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
     
    4169        PUSHBUTTON      "Help", BTN_HELP, 190, 6, 56, 14, BS_HELP
    4270                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    43         GROUPBOX        "CIFS/SMB resource properties", GB_PROPERTIES, 5, 125,
    44                         244, 58
    45                         PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
    46                         PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    47         GROUPBOX        "Login as", GB_LOGIN, 5, 82, 244, 40
    48                         PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
    49                         PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    50         GROUPBOX        "Cache", GB_CACHE, 5, 24, 244, 26
    51                         PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
    52                         PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    53         GROUPBOX        "Browse", GB_BROWSE, 5, 53, 244, 26
    54                         PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
    55                         PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    56         LTEXT           "Cache timeout:", LBL_CACHETIMEOUT, 12, 30, 55, 8, DT_BOTTOM
    57         CONTROL         "", SPIN_CACHETIMEOUT, 69, 30, 32, 12, WC_SPINBUTTON
    58                         SPBS_NUMERICONLY | SPBS_JUSTRIGHT | SPBS_MASTER | WS_GROUP | WS_TABSTOP |
    59                         WS_VISIBLE
    60         LTEXT           "Cache listings:", LBL_CACHEDEPTH, 134, 30, 55, 8, DT_BOTTOM
    61         CONTROL         "", SPIN_CACHEDEPTH, 194, 30, 39, 12, WC_SPINBUTTON
    62                         SPBS_NUMERICONLY | SPBS_JUSTRIGHT | SPBS_MASTER | WS_GROUP | WS_TABSTOP |
    63                         WS_VISIBLE
    6471    END
    6572END
  • trunk/client/src/rc/rc.h

    r519 r960  
    2121#define GB_LOGIN                    1024
    2222#define GB_PROPERTIES               1026
    23 #define GB_CACHE                     1025
     23#define GB_CACHE                    1025
    2424#define GB_BROWSE                   1027
    25 #define LBL_CACHETIMEOUT        1014
    26 #define SPIN_CACHETIMEOUT       1015
    27 #define LBL_CACHEDEPTH          1017
    28 #define SPIN_CACHEDEPTH         1018
     25#define LBL_CACHETIMEOUT            1014
     26#define SPIN_CACHETIMEOUT           1015
     27#define LBL_CACHEDEPTH              1017
     28#define SPIN_CACHEDEPTH             1018
     29#define LBL_LOGLEVEL                1019
     30#define SPIN_LOGLEVEL               1020
  • trunk/client/src/rc/rc.rc_

    r756 r960  
    3838   "Help for command line utility:\r\n"
    3939   "\r\n"
    40    "nd mount smbfs s:\\mountpoint ;workgroup=...;server=...;share=...;user=...;password=...;master=...;mastertype=...;easupport=...\r\n"
     40   "nd mount smbfs s:\\mountpoint ;workgroup=...;server=...;share=...;user=...;password=...;master=...;mastertype=...;easupport=...;loglevel=...\r\n"
    4141   "\r\n"
    4242   "    workgroup - name of workgroup\r\n"
     
    4848   "    mastertype - 0 if 'master' is the name of master server, 1 if 'master' is the name of master workgroup\r\n"
    4949   "    easupport - 0 to not support EA, 1 to support\r\n"
     50   "    loglevel - 0 no log, 2 standard log, 5 verbose, 10 very big log\r\n"
    5051   "\r\n"
    5152}
     
    126127RCDATA (DLG_ID + 11)
    127128{
     129    SPIN_LOGLEVEL, PARMTYPE_INT, 0L, 10L, "loglevel", "%d", 0L
     130}
     131
     132RCDATA (DLG_ID + 12)
     133{
    128134    1
    129135}
  • trunk/client/src/smbwrp.c

    r959 r960  
    4040}
    4141
    42 void smbwrp_Logging()
    43 {
    44         char slogfile[_MAX_PATH +1] = {0};
    45         char slogfilename[] = "log.smbc";
    46         char *env = getenv("LOGFILES");
    47         if (env != NULL)
    48         {
    49            strncpy(slogfile, env, sizeof(slogfile) -1);
    50            strncat(slogfile, "\\", sizeof(slogfile) - strlen(slogfile) -1);
    51            strncat(slogfile, slogfilename, sizeof(slogfile) - strlen(slogfile) -1);
    52         }
    53         else
    54            strncpy(slogfile, slogfilename, sizeof(slogfile) -1);
    55 
    56         // init samba for debug messages
    57         setup_logging("ndpsmb", DEBUG_FILE);
    58         lp_set_logfile(slogfile);
    59         lp_set_cmdline("log level", "10");
    60         reopen_logs();
     42void smbwrp_Logging(Resource *pRes)
     43{
     44        if (pRes && pRes->loglevel > 0)
     45        {
     46           // init samba for debug messages
     47           setup_logging("ndpsmb", DEBUG_FILE);
     48
     49           char smblevel[3];
     50           itoa(pRes->loglevel, smblevel, 10);
     51           lp_set_logfile(pRes->smb_logfile);
     52           lp_set_cmdline("log level", smblevel);
     53           reopen_logs();
     54        }
    6155
    6256        return;
     
    7670 * initialise structures
    7771 */
    78 int _System smbwrp_init(void)
    79 {
    80         static int initialised = 0;
     72int _System smbwrp_init(Resource *pRes)
     73{
    8174        char *p;
    8275
    83         if (initialised)
     76        if (pRes->smb_initialised)
    8477           return 0;
    8578
    86         initialised = 1;
     79        pRes->smb_initialised = 1;
    8780
    8881        lp_set_in_client(true); // Make sure that we tell lp_load we are client
     
    9184
    9285        if (!lp_load(get_dyn_CONFIGFILE(),true,false,false,true))
    93            debuglocal(0,("The initial smb.conf is missing, defaults are used!\n"));
     86           debuglocal(pRes, 0,("The initial smb.conf is missing, defaults are used!\n"));
    9487
    9588        load_interfaces();
     
    9891           return 1;
    9992
    100         if (writeLog())
    101            smbwrp_Logging();
    102 
     93        smbwrp_Logging(pRes);
     94
     95        debuglocal(pRes, 5,("smbwrp_init done\n"));
    10396        /*
    10497        if ((p=smbw_getshared("RESOLVE_ORDER")))
     
    116109        */
    117110        BlockSignals(True, SIGPIPE);
     111        return;
    118112}
    119113
     
    214208 * return a connection to a server
    215209 */
    216 int _System smbwrp_connect( Resource* pRes, cli_state ** cli)
     210int _System smbwrp_connect(Resource* pRes, cli_state ** cli)
    217211{
    218212        smbwrp_server * srv = &pRes->srv;
     
    231225        zero_sockaddr(&ss);
    232226
    233         debuglocal(1,"Connecting to \\\\%s:*********@%s:%s\\%s. Master %s:%d\n", srv->username,  workgroup, server, share, srv->master, srv->ifmastergroup);
     227        debuglocal(pRes, 1,"Connecting to \\\\%s:*********@%s:%s\\%s. Master %s:%d\n", srv->username,  workgroup, server, share, srv->master, srv->ifmastergroup);
    234228
    235229        if (!*server) {
     
    273267        if (pRes->krb5support == 1)
    274268        {
    275            debuglocal(1,"Kerberos support enabled\n");
     269           debuglocal(pRes, 1,"Kerberos support enabled\n");
    276270           c->use_kerberos = True;
    277271        }
     
    289283        }
    290284
    291         debuglocal(4," session request ok\n");
     285        debuglocal(pRes, 4,"session request ok\n");
    292286
    293287        if (!NT_STATUS_IS_OK(cli_negprot(c))) {
     
    296290        }
    297291
    298         debuglocal(4," session setuping for <%s>/<********> in <%s> %08x %08x %08x\n", srv->username,  workgroup, c->protocol, c->sec_mode, c->capabilities);
     292        debuglocal(pRes, 4,"session setuping for <%s>/<********> in <%s> %08x %08x %08x\n", srv->username,  workgroup, c->protocol, c->sec_mode, c->capabilities);
    299293
    300294        if (!NT_STATUS_IS_OK(cli_session_setup(c, srv->username,
     
    303297              workgroup)))
    304298        {
    305            debuglocal(4,"%s/******** login failed\n", srv->username);
     299           debuglocal(pRes, 4,"%s/******** login failed\n", srv->username);
    306300           loginerror = 1; // save the login error
    307301
    308302           // try an anonymous login if it failed
    309303           if (!NT_STATUS_IS_OK(cli_session_setup(c, "", "", 0,"", 0, workgroup))) {
    310               debuglocal(4,"Anonymous login failed\n");
     304              debuglocal(pRes, 4,"Anonymous login failed\n");
    311305              cli_shutdown(c);
    312306              return 6;
    313307           }
    314            debuglocal(4,"Anonymous login successful\n");
     308           debuglocal(pRes, 4,"Anonymous login successful\n");
    315309           status = cli_init_creds(c, "", lp_workgroup(), "");
    316310        } else {
     
    319313
    320314        if (!NT_STATUS_IS_OK(status)) {
    321            debuglocal(4,"cli_init_creds() failed\n");
     315           debuglocal(pRes, 4,"cli_init_creds() failed\n");
    322316           cli_shutdown(c);
    323317           // if loginerror is != 0 means normal login failed, but anonymous login worked
     
    328322        }
    329323
    330         debuglocal(4," session setup ok. Sending tconx <%s> <********>\n", share);
     324        debuglocal(pRes, 4,"session setup ok. Sending tconx <%s> <********>\n", share);
    331325
    332326        // YD ticket:58 we need to check resource type to avoid connecting to printers.
     
    348342        }
    349343
    350         debuglocal(4," tconx ok. cli caps %08x\n", c->capabilities);
     344        debuglocal(pRes, 4,"tconx ok. cli caps %08x\n", c->capabilities);
    351345       
    352346        // save cli_state pointer
     
    359353 * close a connection to a server
    360354 */
    361 void _System smbwrp_disconnect( Resource* pRes, cli_state * cli)
     355void _System smbwrp_disconnect(Resource* pRes, cli_state * cli)
    362356{
    363357        // this call will free all buffers, close handles and free cli mem
     
    369363 * a wrapper for open()
    370364 */
    371 int _System smbwrp_open(cli_state * cli, smbwrp_file * file)
     365int _System smbwrp_open(Resource *pRes, cli_state * cli, smbwrp_file * file)
    372366{
    373367        uint16_t fd = 0;
     
    379373           file->denymode = DENY_NONE;
    380374
    381         debuglocal(4,"cli_open(%s) attr %08x mode %02x denymode %02x\n", file->fname, file->openattr, file->openmode, file->denymode);
     375        debuglocal(pRes, 4,"cli_open(%s) attr %08x mode %02x denymode %02x\n", file->fname, file->openattr, file->openmode, file->denymode);
    382376        if (!NT_STATUS_IS_OK(cli_open(cli, file->fname, file->openmode, file->denymode, &fd)))
    383377           return os2cli_errno(cli);
     
    392386 * a wrapper for read()
    393387 */
    394 int _System smbwrp_read(cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result)
     388int _System smbwrp_read(Resource *pRes, cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result)
    395389{
    396390        int ret;
     
    412406 * a wrapper for write()
    413407 */
    414 int _System smbwrp_write(cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result)
     408int _System smbwrp_write(Resource *pRes, cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result)
    415409{
    416410        NTSTATUS status;
     
    421415       
    422416        *result = 0;
    423         //debuglocal(1,("Write %x %d %lld %d", cli, file->fd, file->offset, count));
     417        debuglocal(pRes, 10, "Write %x %d %lld %d\n", cli, file->fd, file->offset, count);
    424418        status = cli_writeall(cli, file->fd, 0, buf, file->offset, count, &ret);
    425419        if (!NT_STATUS_IS_OK(status))
     
    435429 * a wrapper for close()
    436430 */
    437 int _System smbwrp_close(cli_state * cli, smbwrp_file * file)
     431int _System smbwrp_close(Resource *pRes, cli_state * cli, smbwrp_file * file)
    438432{
    439433        int rc = 0;
     
    441435           return maperror(EINVAL);
    442436
    443         debuglocal(4,"smpwrp_close updatetime: %d\n", file->updatetime);
     437        debuglocal(pRes, 4,"smpwrp_close updatetime: %d\n", file->updatetime);
    444438
    445439        if (file->updatetime == 1)
    446440        {
    447441           file->mtime = time(NULL);
    448            debuglocal(4,"cli_close new mtime %lu\n", file->mtime);
     442           debuglocal(pRes, 4,"cli_close new mtime %lu\n", file->mtime);
    449443        }
    450444       
     
    454448        if (!rc && (file->openattr || file->mtime || file->ctime))
    455449        {
    456            debuglocal(4,"Set pathinfo on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->ctime);
    457            if (!NT_STATUS_IS_OK(cli_setpathinfo_basic(cli, file->fname, file->ctime, 0, file->mtime, 0, file->openattr)))
    458               debuglocal(4,"Set pathinfo on close failed %d\n", os2cli_errno(cli));
     450           debuglocal(pRes, 4,"Set pathinfo on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->ctime);
     451           if (!NT_STATUS_IS_OK(cli_setpathinfo_basic(cli, file->fname, file->ctime, 0, file->mtime, 0, file->openattr)))
     452           {
     453              debuglocal(pRes, 4,"Set pathinfo on close failed %d\n", os2cli_errno(cli));
     454           }
    459455        }
    460456
     
    469465}
    470466
    471 int _System smbwrp_setfilesize(cli_state * cli, smbwrp_file * file, long long newsize)
     467int _System smbwrp_setfilesize(Resource *pRes, cli_state * cli, smbwrp_file * file, long long newsize)
    472468{
    473469        int rc = 0;
     
    475471           return maperror(EINVAL);
    476472
    477         debuglocal(4,"cli_setnewfilesize(%s) %lld\n", file->fname, newsize);
     473        debuglocal(pRes, 4,"cli_setnewfilesize(%s) %lld\n", file->fname, newsize);
    478474        if (!NT_STATUS_IS_OK(cli_ftruncate(cli, file->fd, newsize)))
    479475        {
     
    489485           file->openmode &= ~(O_CREAT | O_EXCL);
    490486           file->openmode |= O_TRUNC;
    491            debuglocal(4,"cli_setnewfileszie : cli_open(%s) attr %08x mode %02x denymode %02x\n", file->fname, file->openattr, file->openmode, file->denymode);
     487           debuglocal(pRes, 4,"cli_setnewfileszie : cli_open(%s) attr %08x mode %02x denymode %02x\n", file->fname, file->openattr, file->openmode, file->denymode);
    492488           if (!NT_STATUS_IS_OK(cli_open(cli, file->fname, file->openmode, file->denymode, &fd)))
    493489              return os2cli_errno(cli);
     
    501497 * a wrapper for rename()
    502498 */
    503 int _System smbwrp_rename(cli_state * cli, char *oldname, char *newname)
     499int _System smbwrp_rename(Resource *pRes, cli_state * cli, char *oldname, char *newname)
    504500{
    505501        if (!cli || !oldname || !newname)
    506502           return maperror(EINVAL);
    507503
    508         debuglocal(1,"Rename <%s> -> <%s>\n", oldname, newname);
     504        debuglocal(pRes, 4,"Rename <%s> -> <%s>\n", oldname, newname);
    509505        if (!NT_STATUS_IS_OK(cli_rename(cli, oldname, newname)))
    510506           return os2cli_errno(cli);
     
    517513 * a wrapper for chmod()
    518514 */
    519 int _System smbwrp_setattr(cli_state * cli, smbwrp_fileinfo *finfo)
     515int _System smbwrp_setattr(Resource *pRes, cli_state * cli, smbwrp_fileinfo *finfo)
    520516{
    521517        if (!cli || !finfo || !*finfo->fname)
    522518           return maperror(EINVAL);
    523519
    524         debuglocal(4,"Setting on <%s> attr %04x, time %lu (timezone /%lu\n", finfo->fname, finfo->attr, finfo->mtime, finfo->mtime + get_time_zone(finfo->mtime));
     520        debuglocal(pRes, 4,"Setting on <%s> attr %04x, time %lu (timezone /%lu\n", finfo->fname, finfo->attr, finfo->mtime, finfo->mtime + get_time_zone(finfo->mtime));
    525521        // we already have gmt time, so no need to add timezone
    526522        // if (!cli_setatr(cli, finfo->fname, finfo->attr, finfo->mtime + (finfo->mtime == 0 ? 0 : get_time_zone(finfo->mtime)))
     
    535531 * a wrapper for unlink()
    536532 */
    537 int _System smbwrp_unlink(cli_state * cli, const char *fname)
     533int _System smbwrp_unlink(Resource *pRes, cli_state * cli, const char *fname)
    538534{
    539535        if (!cli || !fname)
     
    561557 * a wrapper for lseek()
    562558 */
    563 int _System smbwrp_lseek(cli_state * cli, smbwrp_file * file, int whence, long long offset)
     559int _System smbwrp_lseek(Resource *pRes, cli_state * cli, smbwrp_file * file, int whence, long long offset)
    564560{
    565561        off_t size;
     
    567563           return maperror(EINVAL);
    568564
    569         debuglocal(4,"lseek %d %lld %lld\n", whence, offset, file->offset);
     565        debuglocal(pRes, 4,"lseek %d %lld %lld\n", whence, offset, file->offset);
    570566
    571567        switch (whence) {
     
    599595 * this is needed because win95 sometimes refuses the qpathinfo
    600596 */
    601 int _System smbwrp_getattr(smbwrp_server *srv, cli_state * cli, smbwrp_fileinfo *finfo)
     597int _System smbwrp_getattr(Resource *pRes, smbwrp_server *srv, cli_state * cli, smbwrp_fileinfo *finfo)
    602598{
    603599        SMB_INO_T ino = 0;
     
    609605           return maperror(EINVAL);
    610606
    611         debuglocal(4,"getattr %d %d <%s>\n", cli->capabilities & CAP_NOPATHINFO2, cli->capabilities & CAP_NT_SMBS, finfo->fname);
     607        debuglocal(pRes, 4,"getattr %d %d <%s>\n", cli->capabilities & CAP_NOPATHINFO2, cli->capabilities & CAP_NT_SMBS, finfo->fname);
    612608        if (!(cli->capabilities & CAP_NOPATHINFO2) &&
    613609            NT_STATUS_IS_OK(cli_qpathinfo2(cli, finfo->fname, &ctime, &atime,
     
    636632            || (strncmp(cli->dev,"LPT",3) == 0))
    637633        {
    638            debuglocal(4,"getattr not a share.\n");
     634           debuglocal(pRes, 4,"getattr not a share.\n");
    639635           *(time_t *)&finfo->ctime = time (NULL);
    640636           *(time_t *)&finfo->atime = time (NULL);
     
    663659        if (NT_STATUS_IS_OK(cli_getatr(cli, finfo->fname, (unsigned short *)&finfo->attr, &finfo->size, (time_t *)&finfo->mtime)))
    664660        {
    665            //debuglocal(2,("gotattr1 %08x <%s>\n", finfo->attr, finfo->fname));
     661           debuglocal(pRes, 10,("gotattr1 %08x <%s>\n", finfo->attr, finfo->fname));
    666662           finfo->mtime -= get_time_zone(finfo->mtime);
    667663           finfo->atime = finfo->atime;  //was mtime
     
    678674 * this is needed because win95 sometimes refuses the qpathinfo
    679675 */
    680 int _System smbwrp_fgetattr(cli_state * cli, smbwrp_file *file, smbwrp_fileinfo *finfo)
     676int _System smbwrp_fgetattr(Resource *pRes, cli_state * cli, smbwrp_file *file, smbwrp_fileinfo *finfo)
    681677{
    682678        struct timespec ctime;
     
    725721        if (state && finfo)
    726722        {
    727            filelist_state * st  = (filelist_state *)state;
     723           filelist_state *st  = (filelist_state *)state;
    728724           char fullname[ _MAX_PATH] = {0};
    729            debuglocal(8,"adding <%s> %d %d %d\n", finfo->fname, sizeof(st->finfo), st->datalen, sizeof(st->finfo.fname));
     725           debuglocal(st->pConn->pRes, 8,"adding <%s> %d %d %d\n", finfo->fname, sizeof(st->finfo), st->datalen, sizeof(st->finfo.fname));
    730726           memcpy(&st->finfo, finfo, sizeof(st->finfo));
    731727           strncpy(fullname, st->dir, strlen(st->dir));
    732728           strncat(fullname, finfo->fname, sizeof(fullname) - strlen(fullname) -1);
    733729           strncpy(st->finfo.fname, fullname, sizeof(st->finfo.fname));
    734            getfindinfoL( st->pConn, st->plist, &st->finfo, st->ulAttribute, st->dir_mask);
     730           getfindinfoL(st->pConn, st->plist, &st->finfo, st->ulAttribute, st->dir_mask);
    735731        }
    736732        return;
     
    796792static int list_files(struct cli_state *cli, const char *mask, uint16 attribute,
    797793                  void (*fn)(const char *, smbwrp_fileinfo *, const char *,
    798                              void *), void *state)
     794                             void *), filelist_state *state)
    799795{
    800796        TALLOC_CTX *frame = talloc_stackframe();
     
    807803        void *dircachectx = NULL;
    808804        smbwrp_fileinfo wrpfinfo;
     805        Resource *pRes = state->pConn->pRes;
    809806
    810807        // Try to get the listing from cache.
     
    826823        ? SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_EA_SIZE;
    827824
    828         debuglocal(4,"list_files level %d. mask <%s>\n", info_level, mask);
     825        debuglocal(pRes, 4,"list_files level %d. mask <%s>\n", info_level, mask);
    829826
    830827        req = cli_list_send(frame, ev, cli, mask, attribute, info_level);
     
    843840        dircachectx = dircache_write_begin(state, num_finfo);
    844841
    845         debuglocal(4,"list_files: got %d files\n", num_finfo);
     842        debuglocal(pRes, 4,"list_files: got %d files\n", num_finfo);
    846843
    847844        for (i=0; i<num_finfo; i++) {
     
    857854           fn(cli->dfs_mountpoint, &wrpfinfo, mask, state);
    858855           // Also add the entry to the cache.
    859            dircache_write_entry(dircachectx, &wrpfinfo);
    860         }
    861 
    862         dircache_write_end(dircachectx);
     856           dircache_write_entry(pRes, dircachectx, &wrpfinfo);
     857        }
     858
     859        dircache_write_end(pRes, dircachectx);
    863860 fail:
    864861        TALLOC_FREE(frame);
     
    869866 * open a directory on the server
    870867 */
    871 int _System smbwrp_filelist(smbwrp_server *srv, cli_state * cli, filelist_state * state)
     868int _System smbwrp_filelist(Resource *pRes, smbwrp_server *srv, cli_state * cli, filelist_state * state)
    872869{
    873870        if (!srv || !cli || !state || !*state->mask)
    874871           return maperror(EINVAL);
    875872
    876         debuglocal(1,"Filelist <%s> on master <%s> wgrp <%s> server <%s> share <%s> clidev <%s>\n", state->mask, srv->master, srv->workgroup, srv->server_name, srv->share_name, cli->dev);
     873        debuglocal(pRes, 1,"Filelist <%s> on master <%s> wgrp <%s> server <%s> share <%s> clidev <%s>\n", state->mask, srv->master, srv->workgroup, srv->server_name, srv->share_name, cli->dev);
    877874        if (*srv->workgroup == 0 && *srv->server_name == 0)
    878875        {
     
    915912 * a wrapper for chdir()
    916913 */
    917 int _System smbwrp_chdir(smbwrp_server *srv, cli_state * cli, char *fname)
     914int _System smbwrp_chdir(Resource *pRes, smbwrp_server *srv, cli_state * cli, char *fname)
    918915{
    919916        unsigned short mode = aDIR;
     
    923920
    924921        strncpy(finfo.fname, fname, sizeof(finfo.fname) - 1);
    925         if (smbwrp_getattr(srv, cli, &finfo))
     922        if (smbwrp_getattr(pRes, srv, cli, &finfo))
    926923           return os2cli_errno(cli);
    927924
     
    938935 * a wrapper for mkdir()
    939936 */
    940 int _System smbwrp_mkdir(cli_state * cli, char *fname)
     937int _System smbwrp_mkdir(Resource *pRes, cli_state * cli, char *fname)
    941938{
    942939        if (!cli || !fname)
     
    952949 * a wrapper for rmdir()
    953950 */
    954 int _System smbwrp_rmdir(cli_state * cli, char *fname)
     951int _System smbwrp_rmdir(Resource *pRes, cli_state * cli, char *fname)
    955952{
    956953        if (!cli || !fname)
     
    966963 * set EA for a path
    967964 */
    968 int _System smbwrp_setea(cli_state * cli, char *fname, char * name, unsigned char * value, int size)
     965int _System smbwrp_setea(Resource *pRes, cli_state * cli, char *fname, char * name, unsigned char * value, int size)
    969966{
    970967        if (!cli || !fname || !name)
     
    980977 * set EA for a file
    981978 */
    982 int _System smbwrp_fsetea(cli_state * cli, smbwrp_file *file, char * name, unsigned char * value, int size)
     979int _System smbwrp_fsetea(Resource *pRes, cli_state * cli, smbwrp_file *file, char * name, unsigned char * value, int size)
    983980{
    984981        if (!cli || !file || !name)
     
    10071004#pragma pack()
    10081005
    1009 static int unilistea(cli_state * cli, char *fname, void * buffer, unsigned long size)
     1006static int unilistea(Resource *pRes, cli_state * cli, char *fname, void * buffer, unsigned long size)
    10101007{
    10111008        int fnum, i;
     
    10241021        if (!NT_STATUS_IS_OK(cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list)))
    10251022        {
    1026            debuglocal(4,"ea_get_file list failed - %s\n", cli_errstr(cli));
     1023           debuglocal(pRes, 4,"ea_get_file list failed - %s\n", cli_errstr(cli));
    10271024           talloc_destroy(mem_ctx);
    10281025           return os2cli_errno(cli);
    10291026        }
    10301027
    1031         debuglocal(4,"num_eas = %d\n", num_eas);
     1028        debuglocal(pRes, 4,"num_eas = %d\n", num_eas);
    10321029
    10331030        // we will count that os/2 max EA size for file is 64kb
     
    10361033        {
    10371034           int namelen = strlen(ea_list[i].name);
    1038            debuglocal(4, "%d Got EA <%s> with namelen %d, size %d. Gross %d. Buf %d\n", i, ea_list[i].name, namelen, ea_list[i].value.length, gotsize, size);
     1035           debuglocal(pRes, 4, "%d Got EA <%s> with namelen %d, size %d. Gross %d. Buf %d\n", i, ea_list[i].name, namelen, ea_list[i].value.length, gotsize, size);
    10391036           if (namelen > 0xFF || ea_list[i].value.length > 0xFFFF)
    10401037           {
    1041               debuglocal(4, "Skip EA <%s> with namelen %d, size %d\n", ea_list[i].name, namelen, ea_list[i].value.length);
     1038              debuglocal(pRes, 4, "Skip EA <%s> with namelen %d, size %d\n", ea_list[i].name, namelen, ea_list[i].value.length);
    10421039              continue;
    10431040           }
     
    10561053        }
    10571054        pfealist->cbList = gotsize;
    1058         debuglocal(4,"ret size = %d\n", gotsize);
     1055        debuglocal(pRes, 4,"ret size = %d\n", gotsize);
    10591056
    10601057        talloc_destroy(mem_ctx);
     
    10651062 * lists EA of a path
    10661063 */
    1067 int _System smbwrp_listea(cli_state * cli, char *fname, void * buffer, unsigned long size)
     1064int _System smbwrp_listea(Resource *pRes, cli_state * cli, char *fname, void * buffer, unsigned long size)
    10681065{
    10691066        if (!cli || !fname || !buffer)
    10701067           return maperror(EINVAL);
    10711068
    1072         debuglocal(4,"EALIst for <%s>\n", fname);
    1073         return unilistea(cli, fname, buffer, size);
     1069        debuglocal(pRes, 4,"EALIst for <%s>\n", fname);
     1070        return unilistea(pRes, cli, fname, buffer, size);
    10741071}
    10751072
     
    10771074 * lists EA of a file
    10781075 */
    1079 int _System smbwrp_flistea(cli_state * cli, smbwrp_file *file, void * buffer, unsigned long size)
     1076int _System smbwrp_flistea(Resource *pRes, cli_state * cli, smbwrp_file *file, void * buffer, unsigned long size)
    10801077{
    10811078        if (!cli || !file || !buffer)
    10821079           return maperror(EINVAL);
    10831080
    1084         debuglocal(4,"FEALIst for <%s>\n", file->fname);
    1085         return unilistea(cli, file->fname, buffer, size);
     1081        debuglocal(pRes, 4,"FEALIst for <%s>\n", file->fname);
     1082        return unilistea(pRes, cli, file->fname, buffer, size);
    10861083}
    10871084
     
    10891086 * Check the space on a device.
    10901087 */
    1091 int _System smbwrp_dskattr(cli_state * cli, FSALLOCATE *pfsa)
     1088int _System smbwrp_dskattr(Resource *pRes, cli_state * cli, FSALLOCATE *pfsa)
    10921089{
    10931090        int total, bsize, avail;
     
    10981095        if (!NT_STATUS_IS_OK(cli_dskattr(cli, &bsize, &total, &avail)))
    10991096        {
    1100            debuglocal(4,"Error in dskattr: %s\n",cli_errstr(cli));
    1101            return os2cli_errno(cli);
    1102         }
    1103 
    1104         debuglocal(4,"\n\t\t%d blocks of size %d. %d blocks available\n",
     1097           debuglocal(pRes, 4,"Error in dskattr: %s\n",cli_errstr(cli));
     1098           return os2cli_errno(cli);
     1099        }
     1100
     1101        debuglocal(pRes, 4,"\n\t\t%d blocks of size %d. %d blocks available\n",
    11051102                   total, bsize, avail);
    11061103
  • trunk/client/src/smbwrp.h

    r959 r960  
    142142        int cachedepth;
    143143        int loglevel;
     144        char logfile[_MAX_PATH +1];
     145        FILE *logfileFH;
     146        char smb_logfile[_MAX_PATH +1];
     147        int ifL;
     148        int firstLogLine;
     149        int smb_initialised;
    144150        struct DirectoryCache *pdc;
    145151} Resource;
     
    173179
    174180int _System smbwrp_getclisize(void);
    175 int _System smbwrp_init(void);
     181int _System smbwrp_init(Resource *pRes);
    176182int _System smbwrp_connect(Resource * pRes, cli_state **);
    177183void _System smbwrp_disconnect(Resource * pRes, cli_state *);
    178 int _System smbwrp_open(cli_state * cli, smbwrp_file * file);
    179 int _System smbwrp_read(cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
    180 int _System smbwrp_write(cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
    181 int _System smbwrp_lseek(cli_state * cli, smbwrp_file * file, int whence, long long offset);
    182 int _System smbwrp_close(cli_state * cli, smbwrp_file * file);
    183 int _System smbwrp_setattr(cli_state * cli, smbwrp_fileinfo *finfo);
    184 int _System smbwrp_getattr(smbwrp_server *srv, cli_state * cli, smbwrp_fileinfo *finfo);
    185 int _System smbwrp_fgetattr(cli_state * cli, smbwrp_file *file, smbwrp_fileinfo *finfo);
    186 int _System smbwrp_filelist(smbwrp_server *srv, cli_state * cli, filelist_state * state);
    187 int _System smbwrp_rename(cli_state * cli, char *oldname, char *newname);
    188 int _System smbwrp_chdir(smbwrp_server *srv, cli_state * cli, char *fname);
    189 int _System smbwrp_mkdir(cli_state * cli, char *fname);
    190 int _System smbwrp_rmdir(cli_state * cli, char *fname);
    191 int _System smbwrp_unlink(cli_state * cli, const char *fname);
    192 int _System smbwrp_setfilesize(cli_state * cli, smbwrp_file * file, long long newsize);
    193 int _System smbwrp_setea(cli_state * cli, char *fname, char * name, unsigned char * value, int size);
    194 int _System smbwrp_fsetea(cli_state * cli, smbwrp_file *file, char * name, unsigned char * value, int size);
    195 int _System smbwrp_listea(cli_state * cli, char *fname, void * buffer, unsigned long size);
    196 int _System smbwrp_flistea(cli_state * cli, smbwrp_file *file, void * buffer, unsigned long size);
    197 int _System smbwrp_dskattr(cli_state * cli, FSALLOCATE *pfsa);
     184int _System smbwrp_open(Resource *pRes, cli_state * cli, smbwrp_file * file);
     185int _System smbwrp_read(Resource *pRes, cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
     186int _System smbwrp_write(Resource *pRes, cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
     187int _System smbwrp_lseek(Resource *pRes, cli_state * cli, smbwrp_file * file, int whence, long long offset);
     188int _System smbwrp_close(Resource *pRes, cli_state * cli, smbwrp_file * file);
     189int _System smbwrp_setattr(Resource *pRes, cli_state * cli, smbwrp_fileinfo *finfo);
     190int _System smbwrp_getattr(Resource *pRes, smbwrp_server *srv, cli_state * cli, smbwrp_fileinfo *finfo);
     191int _System smbwrp_fgetattr(Resource *pRes, cli_state * cli, smbwrp_file *file, smbwrp_fileinfo *finfo);
     192int _System smbwrp_filelist(Resource *pRes, smbwrp_server *srv, cli_state * cli, filelist_state * state);
     193int _System smbwrp_rename(Resource *pRes, cli_state * cli, char *oldname, char *newname);
     194int _System smbwrp_chdir(Resource *pRes, smbwrp_server *srv, cli_state * cli, char *fname);
     195int _System smbwrp_mkdir(Resource *pRes, cli_state * cli, char *fname);
     196int _System smbwrp_rmdir(Resource *pRes, cli_state * cli, char *fname);
     197int _System smbwrp_unlink(Resource *pRes, cli_state * cli, const char *fname);
     198int _System smbwrp_setfilesize(Resource *pRes, cli_state * cli, smbwrp_file * file, long long newsize);
     199int _System smbwrp_setea(Resource *pRes, cli_state * cli, char *fname, char * name, unsigned char * value, int size);
     200int _System smbwrp_fsetea(Resource *pRes, cli_state * cli, smbwrp_file *file, char * name, unsigned char * value, int size);
     201int _System smbwrp_listea(Resource *pRes, cli_state * cli, char *fname, void * buffer, unsigned long size);
     202int _System smbwrp_flistea(Resource *pRes, cli_state * cli, smbwrp_file *file, void * buffer, unsigned long size);
     203int _System smbwrp_dskattr(Resource *pRes, cli_state * cli, FSALLOCATE *pfsa);
    198204
    199205/* Directory cache helpers. */
    200 int dircache_create(struct DirectoryCache **ppdc, unsigned long ulExpirationTime, int cMaxEntries);
    201 void dircache_delete(struct DirectoryCache *pdc);
     206int dircache_create(Resource *pRes);
     207void dircache_delete(Resource *pRes);
    202208
    203209typedef void FNADDDIRENTRY(const char*, smbwrp_fileinfo *, const char *, void *);
     
    213219void *dircache_write_begin(filelist_state *state,
    214220                           int cFiles);
    215 void dircache_write_entry(void *dircachectx, const smbwrp_fileinfo *finfo);
    216 void dircache_write_end(void *dircachectx);
     221void dircache_write_entry(Resource *pRes, void *dircachectx, const smbwrp_fileinfo *finfo);
     222void dircache_write_end(Resource *pRes, void *dircachectx);
    217223
    218224void dircache_invalidate(const char *path,
    219                          struct DirectoryCache *pdc,
     225                         Resource *pRes,
    220226                         int fParent);
    221227
    222 int dircache_find_path(struct DirectoryCache *pdc,
     228int dircache_find_path(Resource *pRes,
    223229                       const char *path,
    224230                       smbwrp_fileinfo *finfo,
     
    226232
    227233/* Prototype the debug log helper. */
    228 void debuglocal(int level, const char * fmt, ...);
     234void debuglocal(Resource *pRes, int level, const char * fmt, ...);
    229235
    230236void smbwrp_initthread(void);
Note: See TracChangeset for help on using the changeset viewer.