MCPcopy Create free account
hub / github.com/apache/trafficserver / read_sip_file

Function read_sip_file

tools/http_load/http_load.c:879–915  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

877}
878
879static void
880read_sip_file(char *sip_file)
881{
882 FILE *fp;
883 char line[5000];
884
885 fp = fopen(sip_file, "r");
886 if (fp == (FILE *)0) {
887 perror(sip_file);
888 exit(1);
889 }
890
891 max_sips = 100;
892 sips = (sip *)malloc_check(max_sips * sizeof(sip));
893 num_sips = 0;
894 while (fgets(line, sizeof(line), fp) != (char *)0) {
895 /* Nuke trailing newline. */
896 if (line[strlen(line) - 1] == '\n')
897 line[strlen(line) - 1] = '\0';
898
899 /* Check for room in sips. */
900 if (num_sips >= max_sips) {
901 max_sips *= 2;
902 sips = (sip *)realloc_check((void *)sips, max_sips * sizeof(sip));
903 }
904
905 /* Add to table. */
906 sips[num_sips].str = strdup_check(line);
907 (void)memset((void *)&sips[num_sips].sa, 0, sizeof(sips[num_sips].sa));
908 if (!inet_aton(sips[num_sips].str, &sips[num_sips].sa.sin_addr)) {
909 (void)fprintf(stderr, "%s: cannot convert source IP address %s\n", argv0, sips[num_sips].str);
910 exit(1);
911 }
912 ++num_sips;
913 }
914 fclose(fp);
915}
916
917static void
918start_connection(struct timeval *nowP)

Callers 1

mainFunction · 0.85

Calls 4

malloc_checkFunction · 0.85
realloc_checkFunction · 0.85
strdup_checkFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected