Esempio n. 1
0
extern OSErr get_file_spec(
  FSSpec *spec,
  short listid,
  short item,
  short pathsid)
{
  Str255 itemstr;
  Str255 pathstr;
  int i,n;
  OSErr err;
  int itemlen,pathlen;

  getpstr(itemstr,listid,item);
  err=FSMakeFSSpec(0,0,itemstr,spec);
  if (err==noErr) {
    return err;
  }
  itemlen=itemstr[0];
  n=countstr(pathsid);
  for (i=0; i<n; i++) {
    getpstr(pathstr,pathsid,i);
    pathlen=pathstr[0];
    pathstr[0]=pathlen+itemlen;
    memcpy(pathstr+pathlen+1,itemstr+1,itemlen);
    err=FSMakeFSSpec(0,0,itemstr,spec);
    if (err==noErr) {
      return err;
    }
  }
  return fnfErr;
}
Esempio n. 2
0
void alert_user(
	short type,
	short resource_number,
	short error_number,
	short identifier)
{
	char buffer[50];
	
	psprintf(buffer, "%d", identifier);
	ParamText((StringPtr)getpstr(temporary, resource_number, error_number), (StringPtr)buffer, (StringPtr)"", (StringPtr)"");
	
	switch(type)
	{
		case fatalError:
			Alert(alrtFATAL_ERROR, (ModalFilterUPP) NULL);
			ParamText((StringPtr)"", (StringPtr)"", (StringPtr)"", (StringPtr)"");
			exit(-1);
		
		case infoError:
			Alert(alrtNONFATAL_ERROR, (ModalFilterUPP) NULL);
			break;
		
		default:
			halt();
	}
	
	ParamText((StringPtr)"", (StringPtr)"", (StringPtr)"", (StringPtr)"");
	return;
}
Esempio n. 3
0
bool confirm(char * msg){
	printf("\n\t%s", msg);
	fflush(stdout);
	char* temp = getpstr();
	bool result = (temp[0] == 'Y' || temp[0] == 'y');
	free(temp);
	return result;
}
Esempio n. 4
0
void scene_arrive(){
	printf("\n\tRegister Arrived Bus\n");
	printf("\n\t1. Number  : %s\n", temp->num);
	printf("\t2. Type    : %s\n", temp->type);
	printf("\t3. Capacity: %u\n", temp->capacity);
	printf("\n\t4. Confirm\n");
	printf("\t5. Cancel\n");
	printf("\n\tChoice: ");
	if (!getint(&number)){
		msg("Invalid Action!");
		return;
	}
	switch (number){
	case 1:
		printf("\n\tNumber: ");
		buffer = getpstr();
		for (number = 0; number < strlen(buffer); number++)
			buffer[number] = toupper(buffer[number]);
		if (!bus_validate(buffer) || search_bus(buffer)){
			msg(bus_validate(buffer) ? "Bus already in queue!":"Invalid Number!");
			free(buffer);
			return;
		}
		temp->num = buffer;
		return;
	case 2:
		printf("\n\t1. %s\n", bustype[0]);
		printf("\t2. %s\n", bustype[1]);
		printf("\n\tWhich Type? ");
		fflush(stdout);
		if (!getint(&number)) msg("Invalid Type!")
		else if (number == 1 || number == 2) temp->type = bustype[number - 1];
		else msg("Invalid Type!")
		return;
	case 3:
		printf("\n\tCapacity: ");
		if (!getint(&number) && number < 0){
			msg("Invalid Input!");
			return;
		}
		temp->capacity = number;
		return;
	case 4:
		if (busses.last)busses.last->next = temp;
		if (!busses.first) busses.first = temp;
		busses.last = temp;
		scene = &scene_menu;
		return;
	case 5:
		free(temp);
		scene = &scene_menu;
		return;
	default:
		msg("Invalid Action!");
		return;
	}
}
Esempio n. 5
0
char *getcstr(
	char *buffer,
	short resource_number,
	short string_number)
{
	getpstr(buffer, resource_number, string_number);
	p2cstr((unsigned char *)buffer);
	
	return buffer;
}
Esempio n. 6
0
static void ir_pstrings(psd_file_t f, int level, int len, struct dictentry *parent){
	char *s;

	for(; len > 1; len -= strlen(s)+1){
		// this loop will do the wrong thing
		// if any string contains NUL byte
		s = getpstr(f);
		if(xml){
			fprintf(xml, "%s<NAME>", tabs(level));
			fputsxml(s, xml);
			fputs("</NAME>\n", xml);
		}
		VERBOSE("    %s\n", s);
	}
}
Esempio n. 7
0
void scene_search(){
	printf("\n\tOkay, Google!\n");
	printf("\tSearch: ");
	buffer = getpstr();
	for (number = 0; number < strlen(buffer); number++)
		buffer[number] = toupper(buffer[number]);
	if (bus_validate(buffer) && (number = search_bus(buffer))){
		printf("\n\tThe bus %s is the %d%s bus in queue\n\t", buffer, number, getoi(number));
		pause();
	}
	else if (!number){
		msg("Error 404: Bus Not Found!");
	} else msg("Invalid Keyword!");
	free(buffer);
}
void add_finishing_touches_to_save_file(FileSpecifier &File)
// 	FileDesc *file)
{
    short refnum;
    unsigned char name[64+1];
    OSErr err;

    FSSpec *SpecPtr = &File.GetSpec();

    FInfo finder_info;
    err = FSpGetFInfo((FSSpec *)SpecPtr, &finder_info);
    if (err != noErr) return;

    FSpCreateResFile(SpecPtr,  finder_info.fdCreator, finder_info.fdType, smSystemScript);
    if (ResError() != noErr) return;

    /* Save the STR resource that tells us what our application name is. */
    refnum= FSpOpenResFile(&File.GetSpec(), fsWrPerm);
    // resource_file_ref= FSpOpenResFile((FSSpec *) file, fsWrPerm);
    if (refnum < 0) return;

    Handle resource;

    /* Add in the overhead thumbnail. */
    add_overhead_thumbnail(File);

    /* Add the application name resource.. */
    getpstr(name, strFILENAMES, filenameMARATHON_NAME);
    // add_application_name_to_fsspec((FileDesc *) file, name);

    // LP: copied out of files_macintosh.c -- add_application_name_to_fsspec();
    // this is the only place that uses this code

    /* Add in the application name */
    err= PtrToHand(name, &resource, name[0]+1);
    assert(!err && resource);

    AddResource(resource, 'STR ', -16396, "\p");
    ReleaseResource(resource);

    CloseResFile(refnum);
    // End copying
}
Esempio n. 9
0
short HOpenResFilePath(
	short vRefNum,
	long dirID,
	ConstStr255Param fileName,
	char permission,
	short resource_number)
{
	short hndl= HOpenResFile(vRefNum, dirID, fileName, permission);
	short path_count= countstr(resource_number);
	Str255 new_filename;
	short i;
	
	for (i= 0; i<path_count && hndl==NONE; ++i)
	{
		getpstr((char *)new_filename, resource_number, i);
		pstrcat(new_filename, (unsigned char *) fileName);
		
		hndl= HOpenResFile(0, 0, new_filename, permission);
	}
	
	return hndl;
}
Esempio n. 10
0
OSErr HOpenPath(
	short vRefNum,
	long dirID,
	ConstStr255Param fileName,
	char permission,
	short *refNum,
	short resource_number)
{
	OSErr error= HOpen(vRefNum, dirID, fileName, permission, refNum);
	short path_count= countstr(resource_number);
	Str255 new_filename;
	short i;
	
	for (i= 0; i<path_count && error!=noErr; ++i)
	{
		getpstr((char *)new_filename, resource_number, i);
		pstrcat(new_filename, (unsigned char *) fileName);
		
		error= HOpen(0, 0, new_filename, permission, refNum);
		if (error==noErr) pstrcpy((char *) fileName, (const char *)new_filename);
	}
	
	return error;
}
Esempio n. 11
0
static void ir_pstring(psd_file_t f, int level, int len, struct dictentry *parent){
	if(xml)
		fputsxml(getpstr(f), xml);
}
Esempio n. 12
0
/* Get string and check is that a valid number */
bool getint(int * i){
	char * temp = getpstr(), c;
	bool result = (sscanf(temp, "%d%c", i, &c) == 1);
	free(temp);
	return result;
}