type stringclasses 5
values | content stringlengths 9 163k |
|---|---|
functions | void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) {
struct PIT_CHANNEL *channel = gptp->channel;
/* Disable timer and disable interrupts */
channel->TCTRL = 0;
/* Clear the interrupt flag */
channel->TFLG |= PIT_TFLGn_TIF;
/* Set the interval */
channel->LDVAL = (gptp->clock / gpt... |
includes |
#include <stdarg.h> |
includes | #include <stddef.h> |
includes | #include <stdint.h> |
includes | #include <setjmp.h> |
includes | #include <cmocka.h> |
structs | struct test_ctx {
}; |
functions | int setup_context(void **state)
{
struct test_ctx *test_ctx;
test_ctx = talloc_zero(NULL, struct test_ctx);
assert_non_null(test_ctx);
*state = test_ctx;
return 0;
} |
functions | int teardown_context(void **state)
{
struct test_ctx *test_ctx =
talloc_get_type_abort(*state, struct test_ctx);
talloc_free(test_ctx);
return 0;
} |
functions | schema_conv process_data_blob(void **state, DATA_BLOB input)
{
struct test_ctx *test_ctx =
talloc_get_type_abort(*state, struct test_ctx);
struct conv_options opt;
struct schema_conv ret;
assert_non_null(test_ctx);
assert_non_null(input.data);
opt.in = fmemopen(input.data, input.length, "r");
opt.out = fopen... |
functions | void test_unknown_syntax_oid(void **state)
{
struct schema_conv ret;
ret = process_data_blob(state, data_blob_string_const(
"attributetype ( 999.555.999.555.999\n"
"NAME 'mailLocalAddress'\n"
"DESC 'RFC822 email address of this recipient'\n"
"EQUALITY caseIgnoreIA5Match\n"
"SYNTAX 999.555.999.555.999{256} |
functions | void test_unterminated_token_value(void **state)
{
struct schema_conv ret;
ret = process_data_blob(state, data_blob_string_const(
"attributetype ( 2.16.840.1.113730.3.1.47\n"
"\tNAME 'mailRoutingAX 1.3.6.1.4.1.1466.115.121.1.26{256} |
functions | void test_unterminated_must_value(void **state)
{
struct schema_conv ret;
ret = process_data_blob(state, data_blob_string_const(
"attributetype ( 1\n"
"\tSYNTAX 1./)# MUST ( foobar $\n"
));
assert_int_equal(ret.count, 1);
assert_int_equal(ret.failures, 1);
} |
functions | void test_unterminated_may_value(void **state)
{
struct schema_conv ret;
ret = process_data_blob(state, data_blob_string_const(
"attributetype ( 1\n"
"\tSYNTAX 1.3.6.1.4.1.1466.115.121.1./)# MAY ( javaClassNames $\n"
));
assert_int_equal(ret.count, 1);
assert_int_equal(ret.failures, 1);
} |
functions | void test_unterminated_sup_value(void **state)
{
struct schema_conv ret;
ret = process_data_blob(state, data_blob_string_const(
"attributetype ( 1\n"
"\tSYNTAX 1./)# SUP ( foobar $\n"
));
assert_int_equal(ret.count, 1);
assert_int_equal(ret.failures, 1);
} |
functions | void test_unknown_token(void **state)
{
struct schema_conv ret;
ret = process_data_blob(state, data_blob_string_const(
"attributetype ( 1\n"
"\tFOOBAR 123\n"
" )\n"
));
assert_int_equal(ret.count, 1);
assert_int_equal(ret.failures, 1);
} |
functions | void test_missing_name(void **state)
{
struct schema_conv ret;
ret = process_data_blob(state, data_blob_string_const(
"objectclass ( 1.3.6.3.6.1.4.1.1466.115.121.1.26{256} |
main | int main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_unknown_syntax_oid,
setup_context,
teardown_context),
cmocka_unit_test_setup_teardown(test_unterminated_token_value,
setup_context,
teardown_context),
cmocka_unit_test_setup_teardown(test_unterminate... |
includes | #include <windows.h> |
includes | #include <winsock2.h> |
includes | #include <tchar.h> |
includes | #include <strsafe.h> |
includes |
#include <stdlib.h> |
includes | #include <stdio.h> |
includes | #include <stdarg.h> |
includes | #include <errno.h> |
includes | #include <string.h> |
includes | #include <errno.h> |
includes | #include <time.h> |
includes | #include <resolv.h> |
includes | #include <sys/socket.h> |
includes | #include <pthread.h> |
defines | #define WIN32_LEAN_AND_MEAN |
defines |
#define MAX_THREADS 5000 |
defines | #define INITIALBUFS 1000 |
defines | #define MAXHEADERS 500 |
defines | #define MAXBUFS 100000000 |
defines | #define TRACE |
defines | #define ssize_t int |
structs | struct thread_data{
int thread_id; // 0,1,..
int maxiter; // how many iterations to run
char* ip; // ip to open
int port; // port to open
char* urlpart; // urlpart to open like /dserve?op=search
char* verify; // string to look for
int res; // stored by thread
}; |
functions | endif
for(iter=0; iter<1; iter++) {
// run just once
for(tid=0;tid<tmax;tid++) {
tdata[tid].thread_id=tid;
tdata[tid].maxiter=maxiter;
tdata[tid].ip=ip;
tdata[tid].port=portnr;
tdata[tid].urlpart=urlpart;
tdata[tid].verify=verify;
tdata[tid].res=0;
#i... |
functions | finish
for(tid=0;tid<tmax;tid++) {
pthread_join(threads[tid],NULL);
//printf("thread %d finished with res %d\n",
// tdata[tid].thread_id,tdata[tid].res);
} |
functions | WINAPI process(LPVOID targ) {
#else
void *process(void *targ) {
#endif
struct thread_data *tdata;
int i,j,k,tid,iter,maxiter,len,clenheader_len,toread,nread;
int sockfd, bytes_read, ok;
struct sockaddr_in dest;
char *buffer, *bufp, *tp;
char *loc,*clenheader;
#if _MSC_VER
#else
// setup nanosleep ... |
functions | else if (nread<toread) {
// ok, read all we had to
bufp+=nread;
*bufp='\0';
} |
functions | void err_exit(int sockfd, char *buffer, int tid) {
#if _MSC_VER
shutdown(sockfd,SD_RECEIVE);
closesocket(sockfd);
if (buffer!=NULL) free(buffer);
ExitThread(1);
#else
shutdown(sockfd,SHUT_RDWR);
close(sockfd);
if (buffer!=NULL) free(buffer);
pthread_exit((void*) tid);
#endif
} |
functions | ssize_t readn(int fd, void *usrbuf, size_t n) {
size_t nleft = n;
ssize_t nread;
char *bufp = usrbuf;
while (nleft>0) {
if ((nread=recv(fd, bufp, nleft, 0)) < 0) {
if (errno==EINTR) nread=0;/* interrupted by sig handler return */
/* and call recv() again */
else {
//f... |
functions | void errhalt(char *str) {
printf("Error: %s\n",str);
#if _MSC_VER
WSACleanup();
#endif
exit(-1);
} |
functions | void usleep(__int64 usec) {
HANDLE timer;
LARGE_INTEGER ft;
ft.QuadPart = -(10*usec); // Convert to 100 nanosecond interval, negative value indicates relative time
timer = CreateWaitableTimer(NULL, TRUE, NULL);
SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
WaitForSingleObject(timer, INFINITE);
C... |
functions | void win_err_handler(LPTSTR lpszFunction) {
// Retrieve the system error message for the last-error code.
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
... |
main | int main(int argc, char **argv) {
int i,tmax,iter,maxiter,rc;
char ip[100], urlpart[2000];
int portnr=0;
#if _MSC_VER
WSADATA wsaData;
HANDLE thandle;
HANDLE thandlearray[MAX_THREADS];
DWORD threads[MAX_THREADS];
#else
pthread_t threads[MAX_THREADS];
pthread_attr_t attr;
#endif
struct thread... |
defines | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
functions | int
os_is_setuid()
{
return 0;
} |
includes | #include <curl/curl.h> |
includes | #include <json-glib/json-glib.h> |
includes | #include <stdio.h> |
includes | #include <stdlib.h> |
includes | #include <unistd.h> |
includes | #include <inttypes.h> |
defines |
#define piwigo_EXTRA_VERBOSE FALSE |
defines |
#define MAX_ALBUM_NAME_SIZE 100 |
functions | size_t curl_write_data_cb(void *ptr, size_t size, size_t nmemb, void *data)
{
GString *string = (GString *)data;
g_string_append_len(string, ptr, size * nmemb);
#if piwigo_EXTRA_VERBOSE == TRUE
g_printf("server reply: %s\n", string->str);
#endif
return size * nmemb;
} |
functions | void _piwigo_ctx_destroy(_piwigo_api_context_t **ctx)
{
if(*ctx)
{
curl_easy_cleanup((*ctx)->curl_ctx);
if((*ctx)->cookie_file) g_unlink((*ctx)->cookie_file);
g_object_unref((*ctx)->json_parser);
g_free((*ctx)->cookie_file);
g_free((*ctx)->url);
g_free((*ctx)->server);
g_free((*ctx)->use... |
functions | void _piwigo_free_account(void *data)
{
_piwigo_account_t *account = (_piwigo_account_t *)data;
g_free(account->server);
g_free(account->username);
g_free(account->password);
} |
functions | void _piwigo_load_account(dt_storage_piwigo_gui_data_t *ui)
{
if(!ui->accounts)
{
g_list_free_full(ui->accounts, _piwigo_free_account);
ui->accounts = NULL;
} |
functions | void _piwigo_set_account(dt_storage_piwigo_gui_data_t *ui)
{
/// serialize data;
JsonBuilder *builder = json_builder_new();
json_builder_begin_object(builder);
json_builder_set_member_name(builder, "server");
json_builder_add_string_value(builder, gtk_entry_get_text(ui->server_entry));
json_builder_set_memb... |
functions | void _piwigo_set_status(dt_storage_piwigo_gui_data_t *ui, gchar *message, gchar *color)
{
if(!color) color = "#ffffff";
gchar mup[512] = { 0 } |
functions | int _piwigo_api_post_internal(_piwigo_api_context_t *ctx, GList *args, char *filename, gboolean isauth)
{
curl_mime *form = NULL;
GString *url = g_string_new(ctx->url);
// send the requests
GString *response = g_string_new("");
dt_curl_init(ctx->curl_ctx, piwigo_EXTRA_VERBOSE);
curl_easy_setopt(ctx->cur... |
functions | void _piwigo_api_authenticate(_piwigo_api_context_t *ctx)
{
GList *args = NULL;
args = _piwigo_query_add_arguments(args, "method", "pwg.session.login");
args = _piwigo_query_add_arguments(args, "username", ctx->username);
args = _piwigo_query_add_arguments(args, "password", ctx->password);
if(!strcmp(ctx->se... |
functions | void _piwigo_api_post(_piwigo_api_context_t *ctx, GList *args, char *filename, gboolean isauth)
{
int res = _piwigo_api_post_internal(ctx, args, filename, isauth);
if(res == CURLE_COULDNT_CONNECT || res == CURLE_SSL_CONNECT_ERROR)
{
#if piwigo_EXTRA_VERBOSE == TRUE
g_printf("curl post error (%d), try authent... |
functions | again
if(ctx->response && !ctx->error_occured)
{
ctx->authenticated = TRUE;
#if piwigo_EXTRA_VERBOSE == TRUE
g_printf("authenticated again, retry\n");
#endif
res = _piwigo_api_post_internal(ctx, args, filename, isauth);
#if piwigo_EXTRA_VERBOSE == TRUE
g_printf("second post exit with sta... |
functions | void _piwigo_authenticate(dt_storage_piwigo_gui_data_t *ui)
{
if(!ui->api) ui->api = _piwigo_ctx_init();
ui->api->server = g_strdup(gtk_entry_get_text(ui->server_entry));
ui->api->username = g_uri_escape_string(gtk_entry_get_text(ui->user_entry), NULL, FALSE);
ui->api->password = g_uri_escape_string(gtk_entry_... |
functions | void _piwigo_entry_changed(GtkEntry *entry, gpointer data)
{
dt_storage_piwigo_gui_data_t *ui = (dt_storage_piwigo_gui_data_t *)data;
_piwigo_set_status(ui, _("not authenticated"), "#e07f7f");
gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), FALSE);
if(ui->api) _piwigo_ctx_destroy(&ui->api);
} |
functions | void _piwigo_server_entry_changed(GtkEntry *entry, gpointer data)
{
dt_storage_piwigo_gui_data_t *ui = (dt_storage_piwigo_gui_data_t *)data;
if(ui->api)
{
_piwigo_set_status(ui, _("not authenticated"), "#e07f7f");
_piwigo_ctx_destroy(&ui->api);
gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), FAL... |
functions | void _piwigo_account_changed(GtkComboBox *cb, gpointer data)
{
dt_storage_piwigo_gui_data_t *ui = (dt_storage_piwigo_gui_data_t *)data;
const gchar *value = dt_bauhaus_combobox_get_text(ui->account_list);
const _piwigo_account_t *account = _piwigo_get_account(ui, value);
if(account)
{
gtk_entry_set_text(... |
functions | void _piwigo_album_changed(GtkComboBox *cb, gpointer data)
{
dt_storage_piwigo_gui_data_t *ui = (dt_storage_piwigo_gui_data_t *)data;
const gchar *value = dt_bauhaus_combobox_get_text(ui->album_list);
// early return if the combo is not yet populated
if(value == NULL) return;
if(strcmp(value, _("create new ... |
functions | void _piwigo_refresh_albums(dt_storage_piwigo_gui_data_t *ui, const gchar *select_album)
{
gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(ui->parent_album_list), FALSE);
if(ui->api == NULL || ui->api->authenticated == FALSE)
{
_piwigo_authenticate(ui);
... |
functions | the
if(select_album == NULL)
{
to_select = g_strdup(dt_bauhaus_combobox_get_text(ui->album_list));
if(to_select)
{
// cut the count of picture in album to get the name only
gchar *p = to_select;
while(*p)
{
if(*p == ' ' && *(p+1) == '(')
{
*p = '\0';
... |
functions | gboolean _piwigo_api_create_new_album(dt_storage_piwigo_params_t *p)
{
GList *args = NULL;
args = _piwigo_query_add_arguments(args, "method", "pwg.categories.add");
args = _piwigo_query_add_arguments(args, "name", p->album);
if(p->parent_album_id != 0)
{
char pid[100];
snprintf(pid, sizeof(pid), "%"P... |
functions | gboolean _piwigo_api_upload_photo(dt_storage_piwigo_params_t *p, gchar *fname,
gchar *author, gchar *caption, gchar *description)
{
GList *args = NULL;
char cat[10];
char privacy[10];
// upload picture
snprintf(cat, sizeof(cat), "%"PRId64, p->album_id);
snprintf(pr... |
functions | void _piwigo_login_clicked(GtkButton *button, gpointer data)
{
dt_storage_piwigo_gui_data_t *ui = (dt_storage_piwigo_gui_data_t *)data;
_piwigo_ctx_destroy(&ui->api);
gchar *last_album = dt_conf_get_string("storage/piwigo/last_album");
_piwigo_refresh_albums(ui, last_album);
dt_conf_set_string("storage/piwig... |
functions | void _piwigo_refresh_clicked(GtkButton *button, gpointer data)
{
dt_storage_piwigo_gui_data_t *ui = (dt_storage_piwigo_gui_data_t *)data;
gchar *last_album = dt_conf_get_string("storage/piwigo/last_album");
_piwigo_refresh_albums(ui, NULL);
dt_conf_set_string("storage/piwigo/last_album", last_album);
g_free(... |
functions | void gui_init(dt_imageio_module_storage_t *self)
{
self->gui_data = (dt_storage_piwigo_gui_data_t *)g_malloc0(sizeof(dt_storage_piwigo_gui_data_t));
dt_storage_piwigo_gui_data_t *ui = self->gui_data;
ui->albums = NULL;
ui->accounts = NULL;
ui->api = NULL;
self->widget = gtk_box_new(GTK_ORIENTATION_VERTICA... |
functions | void gui_cleanup(dt_imageio_module_storage_t *self)
{
g_free(self->gui_data);
} |
functions | void gui_reset(dt_imageio_module_storage_t *self)
{
} |
functions | gboolean _finalize_store(gpointer user_data)
{
dt_storage_piwigo_gui_data_t *g = (dt_storage_piwigo_gui_data_t *)user_data;
// notify that uploads are completed to empty the lounge
if(!g->api->error_occured)
{
GList *args = NULL;
args = _piwigo_query_add_arguments(args, "method", "pwg.images.uploadCo... |
functions | void finalize_store(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data)
{
g_main_context_invoke(NULL, _finalize_store, self->gui_data);
} |
functions | int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale, const gboolean export_masks,
dt_colorspac... |
functions | else if(p->new_album)
{
// we do not want to create more albums when multiple upload
p->new_album = FALSE;
_piwigo_refresh_albums(ui, p->album);
} |
functions | size_t params_size(dt_imageio_module_storage_t *self)
{
return sizeof(int64_t);
} |
functions | void init(dt_imageio_module_storage_t *self)
{
} |
functions | uint64_t _piwigo_album_id(const gchar *name, GList *albums)
{
uint64_t id = 0;
for(const GList *a = albums; a; a = g_list_next(a))
{
_piwigo_album_t *album = (_piwigo_album_t *)a->data;
if(!strcmp(name, album->label))
{
id = album->id;
break;
} |
functions | ui
if(ui->api && ui->api->authenticated == TRUE)
{
// create a new context for the import. set username/password to be able to connect.
p->api = _piwigo_ctx_init();
p->api->authenticated = FALSE;
p->api->server = g_strdup(ui->api->server);
p->api->username = g_strdup(ui->api->username);
p->a... |
functions | int set_params(dt_imageio_module_storage_t *self, const void *params, const int size)
{
if(size != self->params_size(self)) return 1;
// gui stuff not updated, as sensitive user data is not stored in the preset.
// TODO: store name/hash in kwallet/etc module and get encrypted stuff from there!
return 0;
} |
functions | int supported(dt_imageio_module_storage_t *storage, dt_imageio_module_format_t *format)
{
if(strcmp(format->mime(NULL), "image/jpeg") == 0)
return 1;
else if(strcmp(format->mime(NULL), "image/png") == 0)
return 1;
return 0;
} |
functions | void free_params(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *params)
{
dt_storage_piwigo_params_t *p = (dt_storage_piwigo_params_t *)params;
if(p)
{
g_free(p->album);
g_free(p->tags);
_piwigo_ctx_destroy(&p->api);
free(p);
} |
includes |
#include <string.h> |
functions | DATA_BLOB data_blob_named(const void *p, size_t length, const char *name)
{
DATA_BLOB ret;
if (p == NULL && length == 0) {
ZERO_STRUCT(ret);
return ret;
} |
functions | DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name)
{
DATA_BLOB ret = data_blob_named(p, length, name);
if (ret.data) {
talloc_steal(mem_ctx, ret.data);
} |
functions | DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length)
{
DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, length);
data_blob_clear(&blob);
return blob;
} |
functions | void data_blob_free(DATA_BLOB *d)
{
if (d) {
talloc_free(d->data);
d->data = NULL;
d->length = 0;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.