diff --git a/src/driver/toks_driver_ctx.c b/src/driver/toks_driver_ctx.c index a000f59..5354dc7 100644 --- a/src/driver/toks_driver_ctx.c +++ b/src/driver/toks_driver_ctx.c @@ -255,6 +255,7 @@ int toks_get_driver_ctx( size_t keylen; nt_guid svcguid; const char * program; + const char * refstr; const char * ch; int ntokens; int32_t tokpid; @@ -326,6 +327,10 @@ int toks_get_driver_ctx( uuid = entry; break; + case TAG_REFSTR: + refstr = entry->arg; + break; + case TAG_PID: pid = entry; @@ -486,6 +491,8 @@ int toks_get_driver_ctx( ctx->ctx.cctx = &ctx->cctx; ctx->cctx.uuid = &ctx->uuid; + toks_set_driver_refstr(&ctx->ctx,refstr); + if (cctx.drvflags & TOKS_DRIVER_MODE_SERVER) { if (!(ctx->waiters = toks_calloc( TOKS_MAX_WAITERS, diff --git a/src/internal/toksvc_driver_impl.h b/src/internal/toksvc_driver_impl.h index 6fc7471..2057126 100644 --- a/src/internal/toksvc_driver_impl.h +++ b/src/internal/toksvc_driver_impl.h @@ -16,6 +16,12 @@ extern const struct argv_option toks_default_options[]; extern const ntapi_vtbl * toks_ntapi; +size_t toks_strlen(const char * ch); +char * toks_strcpy(char * dst, const char * src); + +void * toks_calloc(size_t n, size_t size); +void toks_free(void *); + #define ntapi toks_ntapi enum app_tags { @@ -30,6 +36,7 @@ enum app_tags { TAG_ACQUIRE, TAG_RELEASE, TAG_TIMEOUT, + TAG_REFSTR, TAG_PID, }; @@ -47,6 +54,7 @@ struct toks_driver_ctx_impl { struct toks_waiter * waiters; struct _nt_port_keys keys; int64_t timeout; + char * refstr; void * hevent; void * hsvcdir; void * hpiddir; @@ -203,6 +211,27 @@ static inline int toks_get_driver_tokpid(const struct toks_driver_ctx * dctx) return ictx->tokpid; } +static inline char * toks_get_driver_refstr(const struct toks_driver_ctx * dctx) +{ + struct toks_driver_ctx_impl * ictx; + ictx = toks_get_driver_ictx(dctx); + return ictx->refstr; +} + +static inline void toks_set_driver_refstr(const struct toks_driver_ctx * dctx, const char * refstr) +{ + struct toks_driver_ctx_impl * ictx; + ictx = toks_get_driver_ictx(dctx); + + if (ictx->refstr) { + toks_free(ictx->refstr); + ictx->refstr = 0; + } + + if (refstr && (ictx->refstr = toks_calloc(1,toks_strlen(refstr)+1))) + toks_strcpy(ictx->refstr,refstr); +} + static inline void toks_query_performance_counters(const struct toks_driver_ctx * dctx, nt_filetime * ticks) { struct toks_driver_ctx_impl * ictx; diff --git a/src/internal/toksvc_nolibc_impl.h b/src/internal/toksvc_nolibc_impl.h index 5d21612..599fe6b 100644 --- a/src/internal/toksvc_nolibc_impl.h +++ b/src/internal/toksvc_nolibc_impl.h @@ -1,3 +1,4 @@ + #ifndef TOKSVC_NOLIBC_IMPL_H #define TOKSVC_NOLIBC_IMPL_H diff --git a/src/skin/toks_skin_default.c b/src/skin/toks_skin_default.c index 36d29ff..a0cdbe7 100644 --- a/src/skin/toks_skin_default.c +++ b/src/skin/toks_skin_default.c @@ -22,6 +22,10 @@ const struct argv_option toks_default_options[] = { {"uuid", 'u',TAG_UUID,ARGV_OPTARG_REQUIRED,0,0,"", "set the service identifier to %s."}, + {"refstr", 'f',TAG_REFSTR,ARGV_OPTARG_REQUIRED,0,0,"", + "include the reference string %s in log records" + "that pertain to this client."}, + {"tokens", 't',TAG_TOKENS,ARGV_OPTARG_REQUIRED,0,0,"", "set the number of available tokens to %s, which should be " "in the range of 1..9999."},