42 element = strtok(copy,
"/");
43 if (element ==
NULL) {
50 backup = strdup(element);
51 while (element !=
NULL) {
52 element = strtok(
NULL,
"/");
53 if ((backup !=
NULL) && (element !=
NULL)) {
56 if ((element !=
NULL) && (*element !=
'\0')) {
57 backup = strdup(element);
77 sprintf(tmp,
"mkdir %s --mode=%s -p", pathname, mode);
93 i = strlen(
string) - 1;
96 if ((
string[i] ==
'\n') || (
string[i] ==
'\t') ||
97 (
string[i] ==
' ') || (
string[i] ==
'\f') ||
98 (
string[i] ==
'\r')) {
110 string[strlen(
string) - chopped] =
'\0';
135 while (strarr[n] !=
NULL) {
139 if ((pos < 0) || (pos > (n))) {
141 "insert: invalid line number %i.\n", pos);
146 len = (1 + strlen(str)) *
sizeof(
char);
148 strcpy(strarr[n], str);
150 strarr[n - 1] =
NULL;
154 strcpy(last, strarr[n - 1]);
155 strcpy(insert, strarr[pos]);
157 strarr[
pos] =
malloc((1 + strlen(str)) *
sizeof(
char));
158 strcpy(strarr[pos], str);
160 for (j = pos; j < n - 1; j++) {
161 strcpy(save, strarr[j + 1]);
163 len = (1 + strlen(insert)) *
sizeof(
char);
164 strarr[j + 1] =
malloc(len);
165 strcpy(strarr[j + 1], insert);
167 strcpy(insert, save);
172 strarr[
n] =
malloc((1 + strlen(last)) *
sizeof(
char));
173 strcpy(strarr[n], last);
177 strarr[n - 1] =
NULL;
196 while (strarr[i] !=
NULL) {
200 if ((pos < 0) || (pos > (i))) {
202 "delete: invalid line number %i.\n", pos);
207 while (strarr[i] !=
NULL) {
209 if (strarr[i + 1] !=
NULL) {
210 strarr[i] =
malloc((1 + (strlen(strarr[i + 1]))) *
sizeof(
char));
211 strcpy(strarr[i], strarr[i + 1]);
236 while (strarr[i] !=
NULL) {
240 if ((start < 0) || (start > (i))) {
244 for (j = start; j < (i); j++) {
245 if (strstr(strarr[j], str) !=
NULL) {
263 while (strarr[i] !=
NULL) {
264 fprintf(f,
"%i: %s", i, strarr[i]);
279 sprintf(file,
"%s/%s", path,
"name");
282 f = fopen(file,
"r");
290 "invalid or missing extension name.\n");
312 if (fgets(s, size, stream) ==
NULL) {
316 hashmark = strchr(s,
'#');
318 if (hashmark !=
NULL) {
319 if (s - hashmark == 0) {
327 tmp = strtok(tmp,
"#");
351 if (fgets(s, size, stream) ==
NULL) {
359 tmp =
malloc(
sizeof(
char) * (strlen(s) + 1));
360 tag_content =
malloc(
sizeof(
char) * (strlen(s) + 1));
365 while (*pos !=
'\0') {
368 tag_insert = tag_content;
378 while (*tag !=
'\0') {
387 if (*tag_2 !=
'\n') {
388 if (strstr(tag_content,
"<br>") !=
NULL) {
395 if (strstr(tag_content,
"<BR>") !=
NULL) {
401 if (strstr(tag_content,
"<p>") !=
NULL) {
409 if (strstr(tag_content,
"<P>") !=
NULL) {
449 hashmark = strchr(s,
'#');
451 if (hashmark !=
NULL) {
452 if (s - hashmark == 0) {
460 tmp = strtok(tmp,
"#");
481 for (i = strlen(s) - 1; i >= 0; i--) {
482 if ((s[i] ==
' ') || (s[i] ==
'\t') || (s[i] ==
'\n') ||
483 (s[i] ==
'\f') || (s[i] ==
'\r')) {
505 if (fgets(s, size, stream) ==
NULL) {
515 hashmark = strchr(s,
'#');
517 if (hashmark !=
NULL) {
518 if (s - hashmark == 0) {
526 tmp = strtok(tmp,
"#");
544 fprintf(stdout,
"%s\n", heading);
545 f = fopen(file,
"r");
547 fprintf(stdout,
" No information available.\n");
551 fprintf(stdout,
" %s", tmp);
553 fprintf(stdout,
"\n");
571 strcpy(tmpfile,
"/tmp/grass.extensions.db.XXXXXX");
574 f_out = fopen(tmpfile,
"w+");
577 "could not create temp file '%s': %s\n \
578 Make sure that directory /tmp exists on your system and you have write permission.\n", tmpfile, strerror(
errno));
583 f_in = fopen(file,
"r");
607 strcpy(tmpfile,
"/tmp/grass.extensions.db.XXXXXX");
610 f_out = fopen(tmpfile,
"w+");
613 "could not create temp file '%s': %s\n \
614 Make sure that directory /tmp exists on your system and you have write permission.\n", tmpfile, strerror(
errno));
619 f_in = fopen(file,
"r");
623 fprintf(f_out,
"<p>\n");
626 sprintf(tmp,
"%s <br>\n", line);
650 fprintf(stdout,
"Binary installation files\n");
654 fprintf(stdout,
" None.\n\n");
659 while (dir_entry !=
NULL) {
660 if ((strcmp(dir_entry->d_name,
".")) &&
661 (strcmp(dir_entry->d_name,
"..")) &&
662 (strcmp(dir_entry->d_name,
"src"))
665 sprintf(tmp,
"%s/%s", package, dir_entry->d_name);
667 if (S_ISDIR(buf.st_mode)) {
669 fprintf(stdout,
" %s", dir_entry->d_name);
672 fprintf(stdout,
", %s", dir_entry->d_name);
680 fprintf(stdout,
" None.");
682 fprintf(stdout,
"\n\n");
703 while (dir_entry !=
NULL) {
704 if ((strcmp(dir_entry->d_name,
".")) &&
705 (strcmp(dir_entry->d_name,
"..")) &&
706 (strcmp(dir_entry->d_name,
"src"))
709 sprintf(tmp,
"%s/%s", package, dir_entry->d_name);
711 if (S_ISDIR(buf.st_mode)) {
712 if (!strcmp(dir_entry->d_name, binaries)) {
740 if (strstr(myfile,
".tar.gz") !=
NULL) {
743 if (strstr(myfile,
".tgz") !=
NULL) {
746 if (strstr(myfile,
".tar.bz2") !=
NULL) {
749 if (strstr(myfile,
".tbz") !=
NULL) {
752 if (strstr(myfile,
".zip") !=
NULL) {
755 if (strstr(myfile,
".tar") !=
NULL) {
771 fprintf(stdout,
"Downloading...");
774 sprintf(str,
"wget -N %s", url);
777 sprintf(str,
"wget -N -q %s", url);
782 "could not run 'wget' to download extension. Is it installed?\n");
800 static unsigned long next;
804 next = next * 1103515245 + 54321;
805 next = (next / 65536) % 32768;
807 sprintf(tmpfile,
"%s/gem.test.%i", gisbase, rand());
809 f = fopen(tmpfile,
"w+");
811 if (
errno == EACCES) {
813 "You don't have write access to your local GRASS installation.\nPlease consult your system administrator.\n");
832 int vercmp(
int major,
int minor,
int revision,
int major2,
int minor2,
835 if ((major == major2) && (minor == minor2) && (revision == revision2)) {
838 if (major2 > major) {
841 if (major2 < major) {
844 if (minor2 > minor) {
847 if (minor2 < minor) {
850 if (revision2 > revision) {
853 if (revision2 < revision) {
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void print_error(int err_code, char *msg,...)
#define ERR_DUMP_PLAIN_TXT
#define ERR_REGISTER_ENTRIES_GISMAN