/*+JMJ
* common.c - tir HTML renderer common functions
* Copyright 2011 David Meyer <
[email protected]>
* common.c is part of tirrender
*/
#include <stdio.h>
#include <string.h>
#include "krcompat.h"
#include "tirrender.h"
/* CONSTANTS: ******************************************************/
#define LOCATION_CHAR ".-_~/"
#define FILE_CHAR ".-_~"
/* MACROS: *********************************************************/
/* GLOBALS: ********************************************************/
struct {
char dataset[30];
char root[30];
char group[30];
} dstab[] = { "black", "/path/to/ds/black/root", "black",
"green", "/path/to/ds/green/root", "*" };
/* PROTOTYPES: *****************************************************/
/* FUNCTIONS: ******************************************************/
int render (dataset, location, file)
char dataset[];
char location[];
char file[];
{
printf("render dataset=%s|location=%s|file=%s\n", dataset, location, file);
return 0;
}
int baddataset (dataset)
char dataset[];
{
}
int badfile (file)
char file[];
{
}
int badlocation (location)
char location[];
{
int n;
for (n = 0; n < strlen(location); n++) {
char c = location[n];
if (!isalnum(c) && (strchr(LOCATION_CHAR, c) == NULL)) return 1;
}
if (strcmp(location, "..") || strncmp(location, "../", 3) || strstr(location, "/../") || strcmp(location + strlen(location) - 3, "/..")) return 1;
/* test if location dir exists in dataset */
return 0;
}