Grabby/CommonCfg/Export/Config.h
snow flurry 69476552e8 Overhaul repository structure to add config
I wish I didn't end up doing this all at once, but ah well. Quick rundown:

- CommonCfg contains config/registry functions shared between Grabby and GrbyCfg.
- GrbyCfg provides a dialog for configuring Grabby.

git-svn-id: svn://vcs.sdm.2ki.xyz/Grabby/trunk@16 27729192-006e-004d-b9b5-06fbd0ef7001
2024-02-26 06:18:00 +00:00

86 lines
2.4 KiB
C

#pragma once
typedef struct _MultiString {
LPTSTR * Values; // Array of string values
size_t Count; // Length of Values
size_t TotalLength; // Used by registry helpers.
// NOTE: This length includes the NULL
// terminator characters of each string
DWORD Reserved[2]; // Used internally
} MultiString;
// Initializes an existing MultiString array, with the given length.
// If dwInitLen is 0, no entries are pre-allocated.
BOOL
MultiString_Init(MultiString *ms,
DWORD dwInitLen);
// Appends a copy of szNew to the end of the list.
//
// NOTE: A new string with the same length as szNew is allocated and
// stored in ms. This makes future internal freeing easier, but means
// the function caller is responsible for freeing the parameter.
BOOL
MultiString_Append(MultiString *ms,
LPCTSTR szNew);
// Removes the string at dwIdx, freeing the memory used.
BOOL
MultiString_Remove(MultiString *ms,
DWORD dwIdx);
// Replaces the string at dwIdx with szNew. Allocations are performed
// similar to MultiString_Append.
BOOL
MultiString_Replace(MultiString *ms,
DWORD dwIdx,
LPCTSTR szNew);
// Frees all memory in a MultiString structure.
void
MultiString_Dispose(MultiString *ms);
typedef enum _HelperShortcut {
HSC_MACOS, // Pretend to be like MacOS (Win+Shift+4)
HSC_WIN10, // Pretend to be like Windows (Win+Shift+S)
HSC_CUSTOM // Use a custom keyboard shortcut
} HlprKbd;
typedef struct _GlobalConfig {
TCHAR ScreenshotDir[MAX_PATH];
BOOL Upload;
BOOL KeepScreenshots;
BOOL HelperStartup;
HlprKbd HelperShortcut;
} Config;
typedef enum _AuthMethod {
CFG_NOAUTH, // Anonymous HTTP requests
CFG_BASICAUTH, // Use HTTP Basic auth
CFG_DIGESTAUTH, // Use HTTP Digest auth
CFG_TOKENAUTH // Use a custom Authorization header
} AuthMethod;
typedef struct _UploadConfig {
LPTSTR Name;
LPTSTR URL;
LPTSTR Method;
/*
* NOTE: If AuthType == CFG_TOKENAUTH, Username is blank/NULL and
* Password is the token.
*/
LPTSTR Username;
LPTSTR Password;
AuthMethod HTTPAuthMethod;
MultiString Headers;
MultiString Parameters;
} UploadConfig;
// Gets the current configuration from the registry.
Config *GetConfig(void);
// Saves the Config object to the registry.
BOOL SaveConfig(Config *cfg);
// Frees all memory associated with the Config object.
void FreeConfig(Config *cfg);