Commit 28c46159 authored by Richard Buckley's avatar Richard Buckley
Browse files

Folded Spinner sources onto TRUNK.

Version 0.06. Tagged as 'builder-0_06'
parent 31f8b0ca
/* (0.06)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.06
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Sep 1997
#define Module_MajorVersion "0.06"
#define Module_MinorVersion ""
#define Module_Date "25 Sep 1997"
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/************************************************************************/
/* Copyright 1997 Acorn Computers Ltd */
/* */
/* This material is the confidential trade secret and proprietary */
/* information of Acorn Computers. It may not be reproduced, used */
/* sold, or transferred to any third party without the prior written */
/* consent of Acorn Computers. All rights reserved. */
/* */
/************************************************************************/
#include <stdlib.h>
#include <string.h>
#include "kernel.h"
#include "gadgets.h"
#include "constants.h"
#include "parse.h"
#include "file.h"
#include "msg.h"
extern build_list_t *build_list;
extern char *build_tree;
/*
* populate the stringset
*/
_kernel_oserror *
build_populate(int window, int gadget)
{
_kernel_oserror *err=NULL;
char *buffer=NULL;
build_list_t *entry;
int count = 0;
/* count strings to malloc a buffer */
entry = build_list;
while (entry) {
count += strlen(entry->name)+1;
entry=entry->next;
}
if ((buffer=malloc(count))==NULL) {
ERR_GOTO(err,msg_error_construct("mem"));
}
strcpy(buffer,"");
entry = build_list;
while (entry) {
if (strlen(buffer)>0) /* more than one, add , */
strcat(buffer,",");
strcat(buffer,entry->name);
entry = entry->next;
}
ERR_GOTO(err,stringset_set_available(0,window,gadget,buffer));
if (build_tree) {
if (strstr(buffer,build_tree)!=NULL) {
ERR_GOTO(err,stringset_set_selected(0,window,gadget,build_tree));
}
}
exit_gracefully:
if (buffer)
free(buffer);
return (err);
}
/*
* add an entry to the list of build directories
*/
_kernel_oserror *
build_add_entry(char *name)
{
_kernel_oserror *err=NULL;
build_list_t *entry;
debug db_printf("build_add_entry %s\n",name);
/*
* make sure it exists
*/
if (file_exists(name)!=2) {
ERR_RETURN(err,msg_error_construct("chk"));
}
/*
* check for duplicates
*/
entry = build_list;
while (entry) {
if (cstrcmp(entry->name,name)==0) {
return (NULL);
}
entry=entry->next;
}
/*
* add entry
*/
if ((entry=malloc(sizeof(build_list_t)))==NULL) {
ERR_RETURN(err,msg_error_construct("mem"));
}
entry->name = strdup(name);
if (strlen(entry->name)>STRINGSET_LIMIT) {
entry->name[STRINGSET_LIMIT] = 0;
}
entry->next = build_list;
build_list = entry;
return (err);
}
/*
* remove an entry from the list of build directories
*/
_kernel_oserror *
build_remove_entry(char *name)
{
_kernel_oserror *err=NULL;
build_list_t *entry,*last=NULL;
debug db_printf("build_remove_entry %s\n",name);
entry = build_list;
while (entry)
{
if (cstrcmp(entry->name,name)==0)
break;
last=entry;
entry=entry->next;
}
if (entry)
{
if (last)
last->next = entry->next;
else
build_list = entry->next;
if (entry->name)
free(entry->name);
free(entry);
}
return (err);
}
/*
* free up all blocks
*/
_kernel_oserror *
build_free(void)
{
build_list_t *entry,*last;
entry = build_list;
while (entry)
{
if (entry->name)
free(entry->name);
last = entry;
entry=entry->next;
free(last);
}
return (NULL);
}
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/************************************************************************/
/* Copyright 1996 Online Media */
/* */
/* This material is the confidential trade secret and proprietary */
/* information of Online Media. It may not be reproduced, used, */
/* sold, or transferred to any third party without the prior written */
/* consent of Online Media. All rights reserved. */
/* */
/************************************************************************/
#include "kernel.h"
#include "swis.h"
/*
* returns 0 - doesn't exist
* 1 - file found
* 2 - directory found
*/
int
file_exists(char *file)
{
_kernel_swi_regs reg;
reg.r[0] = 23; /* no paths */
reg.r[1] = (int)file;
_kernel_swi(OS_File,&reg,&reg);
return (reg.r[0]);
}
/*
* make directory
*/
int
mkdir(char *dir, int mode)
{
_kernel_swi_regs reg;
reg.r[0] = 8;
reg.r[1] = (int)dir;
reg.r[4] = 0;
if (_kernel_swi(OS_File,&reg,&reg))
return (-1);
return (0);
}
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/************************************************************************/
/* Copyright 1996 Acorn Computers Ltd */
/* */
/* This material is the confidential trade secret and proprietary */
/* information of Acorn Computers. It may not be reproduced, used */
/* sold, or transferred to any third party without the prior written */
/* consent of Acorn Computers. All rights reserved. */
/* */
/************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "constants.h"
/*
* compare two strings caselessly
*/
int
cstrcmp(char *a, char *b)
{
int d;
if (a==NULL && b==NULL)
return 0;
if (a==NULL || b==NULL)
return (-1);
while (*a || *b)
{
d = tolower( *(a++) ) - tolower( *(b++) );
if (d) return d;
}
return 0;
}
/*
* malloc an area for a string and copy the string in
*/
char *
strdup(char *str)
{
char *newstr=malloc(str==NULL?1:(strlen(str)+1));
if (newstr != NULL)
{
if (str==NULL)
*newstr = 0;
else
strcpy(newstr, str);
}
return (newstr);
}
/*
* read an environment variable in to a malloced string
*/
char *
read_env(char *variable)
{
char *var=NULL;
char *cp =NULL;
if ((var=getenv(variable))!=NULL)
cp=strdup(var);
return (cp);
}
/*
* identify newline in string and replace with 0
*/
void
chop_newline(char *str)
{
while (*str!=0 && *str!='\n')
str++;
*str=0;
}
/*
* return string in a malloced block, leave pointing at next character
* trashes the string in the process
*/
char *
extract_word(char *str, char **word, int env_var)
{
int len=0;
char *cp;
char *var=NULL;
int end_of_string = FALSE;
if (str==NULL) /* deal with bogus input */
return (NULL);
while ((*str==' ') || (*str==9)) /* skip space chars */
str++;
cp=str;
while ((*cp!=' ') && (*cp!=9) && (*cp!=0))
{
len++;
cp++;
}
if (*cp==0)
end_of_string=TRUE;
else
*cp=0;
if (strlen(str)==0)
*word = NULL;
else
{
if (env_var) /* check for environment variable */
{
if ((var=getenv(str))!=NULL) /* exists */
*word=strdup(var);
else /* does not exist */
*word = strdup(str);
}
else
*word = strdup(str);
}
return (end_of_string==FALSE)?(str+len+1):NULL;
}
/*
* parse the command line to extract arguments in form argc and argv
*/
int
parse_getargs(char *line, char **argv)
{
int argc = 0;
char *cp;
cp = line;
while (*cp != '\0')
{
while (*cp == ' ')
cp++;
if (*cp == '\0')
break;
argv[argc++] = cp;
while (*cp != '\0' && *cp != ' ')
cp++;
if (*cp == 0)
break;
*cp++ = '\0';
}
*cp++ = '\0';
return (argc);
}
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/************************************************************************/
/* Copyright 1996 Acorn Computers Ltd */
/* */
/* This material is the confidential trade secret and proprietary */
/* information of Acorn Computers. It may not be reproduced, used */
/* sold, or transferred to any third party without the prior written */
/* consent of Acorn Computers. All rights reserved. */
/* */
/************************************************************************/
#ifndef __build_h
#define __build_h
_kernel_oserror *build_populate(int window, int gadget);
_kernel_oserror *build_add_entry(char *name);
_kernel_oserror *build_remove_entry(char *name);
_kernel_oserror *build_free(void);
#endif
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/************************************************************************/
/* Copyright 1996 Online Media */
/* */
/* This material is the confidential trade secret and proprietary */
/* information of Online Media. It may not be reproduced, used, */
/* sold, or transferred to any third party without the prior written */
/* consent of Online Media. All rights reserved. */
/* */
/************************************************************************/
#ifndef __file_h
#define __file_h
int file_exists(char *file);
int mkdir(char *dir, int mode);
#endif
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/************************************************************************/
/* Copyright 1997 Acorn Computers Ltd */
/* */
/* This material is the confidential trade secret and proprietary */
/* information of Acorn Computers. It may not be reproduced, used */
/* sold, or transferred to any third party without the prior written */
/* consent of Acorn Computers. All rights reserved. */
/* */
/************************************************************************/
#ifndef __parse_h
#define __parse_h
int cstrcmp(char *a, char *b);
char *strdup(char *str);
char *read_env(char *variable);
void chop_newline(char *str);
char *extract_word(char *str, char **word, int env_var);
int parse_getargs(char *line, char **argv);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment