| 1905 | } |
| 1906 | |
| 1907 | static boolean |
| 1908 | get_gitinfo(char *githash, char *gitbranch) |
| 1909 | { |
| 1910 | FILE *gifp; |
| 1911 | size_t len; |
| 1912 | char infile[MAXFNAMELEN]; |
| 1913 | char *line, *strval, *opt, *c, *end; |
| 1914 | boolean havebranch = FALSE, havehash = FALSE; |
| 1915 | |
| 1916 | if (!githash || !gitbranch) return FALSE; |
| 1917 | |
| 1918 | Sprintf(infile, DATA_IN_TEMPLATE, GITINFO_FILE); |
| 1919 | if (!(gifp = fopen(infile, RDTMODE))) { |
| 1920 | /* perror(infile); */ |
| 1921 | return FALSE; |
| 1922 | } |
| 1923 | set_fgetline_context(infile, TRUE, TRUE); |
| 1924 | |
| 1925 | /* read the gitinfo file */ |
| 1926 | while ((line = fgetline(gifp)) != 0) { |
| 1927 | strval = strchr(line, '='); |
| 1928 | if (strval && strlen(strval) < (BUFSZ-1)) { |
| 1929 | opt = line; |
| 1930 | *strval++ = '\0'; |
| 1931 | /* strip off the '\n' */ |
| 1932 | if ((c = strchr(strval, '\n')) != 0) |
| 1933 | *c = '\0'; |
| 1934 | if ((c = strchr(opt, '\n')) != 0) |
| 1935 | *c = '\0'; |
| 1936 | /* strip leading and trailing white space */ |
| 1937 | while (*strval == ' ' || *strval == '\t') |
| 1938 | strval++; |
| 1939 | end = eos(strval); |
| 1940 | while (--end >= strval && (*end == ' ' || *end == '\t')) |
| 1941 | *end = '\0'; |
| 1942 | while (*opt == ' ' || *opt == '\t') |
| 1943 | opt++; |
| 1944 | end = eos(opt); |
| 1945 | while (--end >= opt && (*end == ' ' || *end == '\t')) |
| 1946 | *end = '\0'; |
| 1947 | |
| 1948 | len = strlen(opt); |
| 1949 | if ((len >= strlen("gitbranch")) |
| 1950 | && !case_insensitive_comp(opt, "gitbranch")) { |
| 1951 | Strcpy(gitbranch, strval); |
| 1952 | havebranch = TRUE; |
| 1953 | } |
| 1954 | if ((len >= strlen("githash")) |
| 1955 | && !case_insensitive_comp(opt, "githash")) { |
| 1956 | Strcpy(githash, strval); |
| 1957 | havehash = TRUE; |
| 1958 | } |
| 1959 | } |
| 1960 | free((genericptr_t) line); |
| 1961 | } |
| 1962 | Fclose(gifp); |
| 1963 | if (havebranch && havehash) |
| 1964 | return TRUE; |
no test coverage detected