727438a3a76e2d885d82d1dd095c644c7e574b05 jcasper Fri May 27 16:43:41 2016 -0700 Mustn't forget the comments and copyright/license info! refs #15312 diff --git src/hg/lib/sessionThumbnail.c src/hg/lib/sessionThumbnail.c index 5828355..8d443a8 100644 --- src/hg/lib/sessionThumbnail.c +++ src/hg/lib/sessionThumbnail.c @@ -1,59 +1,58 @@ -/* +/* sessionThumbnail - get the filename, filesystem path, and web URI + * for the thumbnail image associated with a session. * - */ + * Copyright (C) 2016 The Regents of the University of California + * See README in this or parent directory for licensing information. */ #include "common.h" -//#include "cheapcgi.h" -//#include "jksql.h" #include "dystring.h" #include "hash.h" -//#include "pipeline.h" #include "hgConfig.h" char *sessionThumbnailFileName(char *userIdx, char *encSessionName, char *firstUse) /* Return a pointer to a string containing the name of the thumbnail image that * would be associated with the given user and session name. Result must be freed. * userIdx is a presumed unique ID suitable for being part of a filename. * encSessionName is the cgi-encoded session name, and firstUse is the * mysql-formatted time string for the session's creation date */ { struct dyString *fileName = dyStringCreate("hgPS_%s_%u_%ld.png", userIdx, hashString(encSessionName), dateToSeconds(firstUse, "%Y-%m-%d %T")); return dyStringCannibalize(&fileName); } char *sessionThumbnailFilePath(char *userIdx, char *encSessionName, char *firstUse) /* Returns NULL if the image directory for session thumbnails hasn't been * set in hg.conf. Otherwise, returns the filename and path for the * thumbnail of the specified session */ { char *imgDir = cfgOption("sessionThumbnail.imgDir"); if (imgDir == NULL) return NULL; struct dyString *filePath = dyStringCreate("%s", imgDir); if (lastChar(imgDir) != '/') dyStringAppendC(filePath, '/'); dyStringAppend(filePath, sessionThumbnailFileName(userIdx, encSessionName, firstUse)); return dyStringCannibalize(&filePath); } char *sessionThumbnailFileUri(char *userIdx, char *encSessionName, char *firstUse) /* Returns NULL if the web path to session thumbnails hasn't been * defined in hg.conf. Otherwise, returns the path and filename for the * thumbnail of the specified session */ { char *pathBase = cfgOption("sessionThumbnail.webPath"); if (pathBase == NULL) return NULL; struct dyString *fileUri = dyStringCreate("%s", pathBase); if (lastChar(pathBase) != '/') dyStringAppendC(fileUri, '/'); dyStringAppend(fileUri, sessionThumbnailFileName(userIdx, encSessionName, firstUse)); return dyStringCannibalize(&fileUri); }