File tree Expand file tree Collapse file tree 7 files changed +147
-14
lines changed Expand file tree Collapse file tree 7 files changed +147
-14
lines changed Original file line number Diff line number Diff line change @@ -19,25 +19,19 @@ jobs:
1919      - name : Install dependencies 
2020        run : | 
2121          sudo apt-get update 
22-           sudo apt-get install -y libcurl4-openssl-dev cmake  build-essential pkg-config  
22+           sudo apt-get install -y libcurl4-openssl-dev build-essential 
2323
2424      - name : Build and test 
2525        working-directory : c 
2626        run : | 
27-           mkdir build 
28-           cd build 
29-           cmake .. 
30-           make 
3127          make test 
3228
3329      - name : Build example 
3430        working-directory : c 
3531        run : | 
36-           cd build 
3732          make example 
3833
3934      - name : Run example (dry run) 
4035        working-directory : c 
4136        run : | 
42-           cd build 
4337          ./example || true  # Allow failure since we don't have real API keys 
Original file line number Diff line number Diff line change 1+ #  Prerequisites
2+ * .d 
3+ 
4+ #  Object files
5+ * .o 
6+ * .ko 
7+ * .obj 
8+ * .elf 
9+ 
10+ #  Linker output
11+ * .ilk 
12+ * .map 
13+ * .exp 
14+ 
15+ #  Precompiled Headers
16+ * .gch 
17+ * .pch 
18+ 
19+ #  Libraries
20+ * .lib 
21+ * .a 
22+ * .la 
23+ * .lo 
24+ 
25+ #  Shared objects (inc. Windows DLLs)
26+ * .dll 
27+ * .so 
28+ * .so. * 
29+ * .dylib 
30+ 
31+ #  Executables
32+ * .exe 
33+ * .out 
34+ * .app 
35+ * .i * 86 
36+ * .x86_64 
37+ * .hex 
38+ 
39+ #  Debug files
40+ * .dSYM /
41+ * .su 
42+ * .idb 
43+ * .pdb 
44+ 
45+ #  Kernel Module Compile Results
46+ * .mod * 
47+ * .cmd 
48+ .tmp_versions /
49+ modules.order 
50+ Module.symvers 
51+ Mkfile.old 
52+ dkms.conf 
53+ 
54+ #  debug information files
55+ * .dwo 
56+ 
57+ test_authdog 
Original file line number Diff line number Diff line change 1+ CC  = gcc
2+ CFLAGS  = -Wall -Wextra -std=c99 -O2 -D_GNU_SOURCE
3+ INCLUDES  = -Iinclude
4+ LIBS  = -lcurl
5+ 
6+ #  Targets
7+ LIBRARY  = libauthdog.a
8+ TEST_EXECUTABLE  = test_authdog
9+ EXAMPLE_EXECUTABLE  = example
10+ 
11+ #  Source files
12+ LIB_SOURCES  = src/authdog.c
13+ TEST_SOURCES  = tests/test_authdog.c
14+ EXAMPLE_SOURCES  = examples/main.c
15+ 
16+ #  Object files
17+ LIB_OBJECTS  = $(LIB_SOURCES:.c=.o ) 
18+ TEST_OBJECTS  = $(TEST_SOURCES:.c=.o ) 
19+ EXAMPLE_OBJECTS  = $(EXAMPLE_SOURCES:.c=.o ) 
20+ 
21+ #  Default target
22+ all : $(LIBRARY )  $(TEST_EXECUTABLE )  $(EXAMPLE_EXECUTABLE ) 
23+ 
24+ #  Build static library
25+ $(LIBRARY ) $(LIB_OBJECTS ) 
26+ 	ar rcs $@  $^ 
27+ 
28+ #  Build test executable
29+ $(TEST_EXECUTABLE ) $(TEST_OBJECTS )  $(LIBRARY ) 
30+ 	$(CC )  $(CFLAGS )  -o $@  $^  $(LIBS ) 
31+ 
32+ #  Build example executable
33+ $(EXAMPLE_EXECUTABLE ) $(EXAMPLE_OBJECTS )  $(LIBRARY ) 
34+ 	$(CC )  $(CFLAGS )  -o $@  $^  $(LIBS ) 
35+ 
36+ #  Compile source files
37+ % .o% .c
38+ 	$(CC )  $(CFLAGS )  $(INCLUDES )  -c $<  -o $@ 
39+ 
40+ #  Run tests
41+ test : $(TEST_EXECUTABLE ) 
42+ 	./$(TEST_EXECUTABLE ) 
43+ 
44+ #  Clean build artifacts
45+ clean :
46+ 	rm -f $(LIB_OBJECTS )  $(TEST_OBJECTS )  $(EXAMPLE_OBJECTS )  $(LIBRARY )  $(TEST_EXECUTABLE )  $(EXAMPLE_EXECUTABLE ) 
47+ 
48+ #  Install (basic)
49+ install : $(LIBRARY ) 
50+ 	mkdir -p /usr/local/lib /usr/local/include
51+ 	cp $(LIBRARY )  /usr/local/lib/
52+ 	cp include/authdog.h /usr/local/include/
53+ 
54+ #  Uninstall
55+ uninstall :
56+ 	rm -f /usr/local/lib/$(LIBRARY )  /usr/local/include/authdog.h
57+ 
58+ .PHONY : all test clean install uninstall
Original file line number Diff line number Diff line change @@ -72,6 +72,11 @@ void authdog_user_info_free(authdog_user_info_t *user_info);
7272 */ 
7373const  char *  authdog_error_message (authdog_error_t  error );
7474
75+ /** 
76+  * Cleanup global resources (call at program end) 
77+  */ 
78+ void  authdog_cleanup (void );
79+ 
7580#ifdef  __cplusplus 
7681}
7782#endif 
Original file line number Diff line number Diff line change @@ -112,6 +112,13 @@ authdog_client_t* authdog_client_create(const authdog_config_t *config) {
112112        return  NULL ;
113113    }
114114
115+     // Initialize curl globally (only once) 
116+     static  int  curl_initialized  =  0 ;
117+     if  (!curl_initialized ) {
118+         curl_global_init (CURL_GLOBAL_DEFAULT );
119+         curl_initialized  =  1 ;
120+     }
121+     
115122    authdog_client_t  * client  =  malloc (sizeof (authdog_client_t ));
116123    if  (!client ) {
117124        return  NULL ;
@@ -161,6 +168,11 @@ void authdog_client_destroy(authdog_client_t *client) {
161168    free (client );
162169}
163170
171+ // Cleanup function for global curl resources 
172+ void  authdog_cleanup (void ) {
173+     curl_global_cleanup ();
174+ }
175+ 
164176authdog_error_t  authdog_get_user_info (authdog_client_t  * client , authdog_user_info_t  * * user_info ) {
165177    if  (!client  ||  !user_info ) {
166178        return  AUTHDOG_ERROR_INVALID_PARAM ;
Original file line number Diff line number Diff line change 99#define  TEST_ACCESS_TOKEN  "test_token"
1010#define  TEST_API_KEY  "test_api_key"
1111
12- // Mock test data 
13- static  const  char *  mock_user_info_json  =  
14-     "{\"id\":\"123\",\"email\":\"[email protected] \",\"name\":\"Test User\",\"photo_url\":\"https://example.com/photo.jpg\"}" ;
 12+ // Helper function to duplicate strings 
13+ static  char *  test_strdup (const  char *  s ) {
14+     if  (!s ) return  NULL ;
15+     size_t  len  =  strlen (s ) +  1 ;
16+     char *  copy  =  malloc (len );
17+     if  (copy ) {
18+         strcpy (copy , s );
19+     }
20+     return  copy ;
21+ }
1522
1623// Test helper functions 
1724static  void  test_client_creation () {
@@ -106,10 +113,10 @@ static void test_user_info_free() {
106113    printf ("Testing user info free...\n" );
107114
108115    authdog_user_info_t  * user_info  =  malloc (sizeof (authdog_user_info_t ));
109-     user_info -> id  =  strdup ("123" );
110-     user_info -> email  =  strdup (
"[email protected] " );
 111-     user_info -> name  =  strdup ("Test User" );
112-     user_info -> photo_url  =  strdup ("https://example.com/photo.jpg" );
116+     user_info -> id  =  test_strdup ("123" );
117+     user_info -> email  =  test_strdup (
"[email protected] " );
 118+     user_info -> name  =  test_strdup ("Test User" );
119+     user_info -> photo_url  =  test_strdup ("https://example.com/photo.jpg" );
113120
114121    authdog_user_info_free (user_info );
115122
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments