Mercurial
comparison seobeo/snapshot_creator.c @ 128:7eb79fd91c7e
[Misc] Fixed all bazel targets. I should creat a separate scripts for these lol.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Thu, 08 Jan 2026 19:20:56 -0800 |
| parents | e7899c93da77 |
| children |
comparison
equal
deleted
inserted
replaced
| 127:9af248484ba2 | 128:7eb79fd91c7e |
|---|---|
| 184 // Check status code | 184 // Check status code |
| 185 if (p_resp->status_code != config->expected_status) | 185 if (p_resp->status_code != config->expected_status) |
| 186 { | 186 { |
| 187 fprintf(stderr, " ✗ Status mismatch: expected %d, got %d\n", | 187 fprintf(stderr, " ✗ Status mismatch: expected %d, got %d\n", |
| 188 config->expected_status, p_resp->status_code); | 188 config->expected_status, p_resp->status_code); |
| 189 // fprintf(stderr, "%s", p_resp->body); | |
| 189 Seobeo_Client_Response_Destroy(p_resp); | 190 Seobeo_Client_Response_Destroy(p_resp); |
| 190 Seobeo_Client_Request_Destroy(p_req); | 191 Seobeo_Client_Request_Destroy(p_req); |
| 191 return -1; | 192 return -1; |
| 192 } | 193 } |
| 193 | 194 |
| 194 printf(" ✓ Status: %d\n", p_resp->status_code); | 195 printf(" ✓ Status: %d\n", p_resp->status_code); |
| 195 | |
| 196 // Build full HTTP response | |
| 197 size_t response_len = 0; | |
| 198 char *response = build_full_response(p_resp, &response_len); | |
| 199 | |
| 200 Seobeo_Client_Response_Destroy(p_resp); | |
| 201 Seobeo_Client_Request_Destroy(p_req); | |
| 202 | |
| 203 if (!response || response_len == 0) | |
| 204 { | |
| 205 fprintf(stderr, " ✗ Failed to build response\n"); | |
| 206 if (response) | |
| 207 free(response); | |
| 208 return -1; | |
| 209 } | |
| 210 | 196 |
| 211 // Generate snapshot filename | 197 // Generate snapshot filename |
| 212 char filename[256]; | 198 char filename[256]; |
| 213 path_to_filename(config->path, filename, sizeof(filename)); | 199 path_to_filename(config->path, filename, sizeof(filename)); |
| 214 | 200 |
| 215 char filepath[1024]; | 201 char filepath[1024]; |
| 216 snprintf(filepath, sizeof(filepath), "%s/%s", config->snapshot_dir, filename); | 202 snprintf(filepath, sizeof(filepath), "%s/%s", config->snapshot_dir, filename); |
| 217 | 203 |
| 218 // Write snapshot | 204 // Write snapshot |
| 219 if (write_snapshot(filepath, response, response_len) == 0) | 205 if (write_snapshot(filepath, p_resp->body, p_resp->body_length) == 0) |
| 220 { | 206 { |
| 221 printf(" ✓ Snapshot saved: %s (%zu bytes)\n", filepath, response_len); | 207 printf(" ✓ Snapshot saved: %s (%zu bytes)\n", filepath, p_resp->body_length); |
| 222 free(response); | |
| 223 return 0; | 208 return 0; |
| 224 } | 209 } |
| 225 else | 210 else |
| 226 { | 211 { |
| 227 fprintf(stderr, " ✗ Failed to write snapshot: %s\n", filepath); | 212 fprintf(stderr, " ✗ Failed to write snapshot: %s\n", filepath); |
| 228 free(response); | 213 return -1; |
| 229 return -1; | 214 } |
| 230 } | 215 |
| 216 Seobeo_Client_Response_Destroy(p_resp); | |
| 217 Seobeo_Client_Request_Destroy(p_req); | |
| 231 } | 218 } |
| 232 | 219 |
| 233 int Seobeo_Snapshots_Create_Batch(const SnapshotConfig configs[], int count) | 220 int Seobeo_Snapshots_Create_Batch(const SnapshotConfig configs[], int count) |
| 234 { | 221 { |
| 235 int failed = 0; | 222 int failed = 0; |
| 236 int passed = 0; | 223 int passed = 0; |
| 237 | 224 |
| 238 for (int i = 0; i < count; i++) | 225 for (int i = 0; i < count; i++) |
| 239 { | 226 { |
| 240 if (Seobeo_Snapshot_Create(&configs[i]) == 0) | 227 if (Seobeo_Snapshot_Create(&configs[i]) == 0) |
| 241 { | |
| 242 passed++; | 228 passed++; |
| 243 } | |
| 244 else | 229 else |
| 245 { | |
| 246 failed++; | 230 failed++; |
| 247 } | |
| 248 printf("\n"); | 231 printf("\n"); |
| 249 } | 232 } |
| 250 | 233 |
| 251 printf("=== Summary ===\n"); | 234 printf("=== Summary ===\n"); |
| 252 printf("Created: %d\n", passed); | 235 printf("Created: %d\n", passed); |