?? test_memopad.c
字號:
#include <stdio.h>#include <stdlib.h>#include "glib.h"#include "memopad.h"#include "memopad_record.h"#include "glist_stable.h"#include "db.h"/*Memo test_data[5] = { {1, "new, dirty" , TRUE, TRUE}, {2, "tst2" , TRUE, TRUE}, {3, "tst3" , TRUE, TRUE}, {1, "not new, dirty" , TRUE, TRUE}, {1, "not new, not dirty", TRUE, FALSE},};*/GList *list;gint sortFunc(gconstpointer a, gconstpointer b) { return ((Memo *) a)->memo_id - ((Memo *) b)->memo_id;}int printRecord(int key, char *data) { Memo *memo; deserialize(&memo, data); //printf("%3d %d %d %s\n", memo->memo_id, memo->new, memo->dirty, memo->content); if (list->data) g_list_append(list, memo); else list->data = memo; return TRUE;}int printPool(int key, char *data) { printf("%d \n", key); return TRUE;}int main(int argc, char **argv) {#ifndef NOGDBM char buf[11]; int db; Memo *temp;// int i; GList *item; db = memopad_record_db_open(); /*memopad_record_save(db, &test_data[0]); memopad_record_save(db, &test_data[1]); memopad_record_save(db, &test_data[2]); memopad_record_save(db, &test_data[3]); for (i = 0; i < 4; i++) { printf("%d %-10s %d %d\n", test_data[i].memo_id, test_data[i].content, test_data[i].new, test_data[i].dirty); }*/ if (!db) exit(1); list = g_list_alloc(); printf("Memopad database records: \n"); /*for (i = 0; i < db->records; i++) { temp = memopad_record_load(db, i + 1); if (temp) { printf("%d %-10s %d %d\n", temp->memo_id, temp->content, temp->new, temp->dirty); memopad_record_close(db, temp); } }*/ db_iterate(db, printRecord); list = g_list_sort_stable(list, sortFunc); for(item = list; item != NULL; item = g_list_next(item)) { temp = (Memo *) item->data; if (temp != NULL) { g_date_strftime(buf, 11, "%Y/%m/%d", &(temp->date)); printf("key = %3d: new (%d), dirty(%d), date(%s), title(%s) encoding(%s), content:\n %s\n", temp->memo_id, temp->new, temp->dirty, buf, temp->title, temp->encoding, temp->content); free(temp); } } g_list_free(list); printf("\nUnused key pool: \n"); db_iterate_pool(db, printPool); memopad_record_db_close(db);#endif return 0;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -