C examples

C example: Define a password schema
C example: Store a password
C example: Lookup a password
C example: Remove a password

C example: Define a password schema

Each stored password has a set of attributes which are later used to lookup the password. The names and types of the attributes are defined in a schema. The schema is usually defined once globally. Here's how to define a schema:

			/* in a header: */

			const SecretSchema * example_get_schema (void) G_GNUC_CONST;

			#define EXAMPLE_SCHEMA  example_get_schema ()


			/* in a .c file: */

			const SecretSchema *
			example_get_schema (void)
			{
				static const SecretSchema the_schema = {
					"org.example.Password", SECRET_SCHEMA_NONE,
					{
						{  "number", SECRET_SCHEMA_ATTRIBUTE_INTEGER },
						{  "string", SECRET_SCHEMA_ATTRIBUTE_STRING },
						{  "even", SECRET_SCHEMA_ATTRIBUTE_BOOLEAN },
						{  "NULL", 0 },
					}
				};
				return &the_schema;
			}
			

See the other examples for how to use the schema.