void fnewDIR(char* path) { #ifdef DEBUG DEBUG_printf("BOS v. 0.0.3\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__); #endif FILE *RetFile = (FILE*) calloc(sizeof(FILE)); char **MyPath = strexp(path, '/'); int x = 0; while(MyPath[x++]); x--; x--; strcpy(RetFile->Name, MyPath[x]); DEBUG_printf("A"); // free(MyPath[x], 128); char* tempCharPointer = MyPath[x]; DEBUG_printf("B"); MyPath[x] = (char*)0; DEBUG_printf("C"); RetFile->Flags = FF_DIR; RetFile->PartID = GetPartByName(MyPath[1]); if(MyFileSystems->entry[MyPartitions->entry[RetFile->PartID]->FSid]) if(MyFileSystems->entry[MyPartitions->entry[RetFile->PartID]->FSid]->newFile) MyFileSystems->entry[MyPartitions->entry[RetFile->PartID]->FSid]->newFile(RetFile, MyPath); DEBUG_printf("D"); MyPath[x] = tempCharPointer; freestrexp(MyPath); DEBUG_printf("E"); fclose(RetFile); DEBUG_printf("F"); }
FILE *fopen(char* path) { #ifdef DEBUG DEBUG_printf("BOS v. 0.0.3\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__); #endif FILE *RetFile = (FILE*) calloc(sizeof(FILE)); #ifdef DEBUG DEBUG_printf("BOS v. 0.0.3\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__); #endif RetFile->Flags = FF_INVALID; // path should be in this format /PARTITION/DIR/DIR/FILE char **MyPath = strexp(path, '/'); RetFile->PartID = GetPartByName(MyPath[1]); #ifdef DEBUG DEBUG_printf("%i\n", RetFile->PartID); DEBUG_printf("BOS v. 0.0.3\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__); #endif if(RetFile->PartID != 0xFFFFFFFF) if(MyFileSystems->entry[MyPartitions->entry[RetFile->PartID]->FSid]) if(MyFileSystems->entry[MyPartitions->entry[RetFile->PartID]->FSid]->open) MyFileSystems->entry[MyPartitions->entry[RetFile->PartID]->FSid]->open(RetFile, MyPath); #ifdef DEBUG DEBUG_printf("BOS v. 0.0.3\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__); #endif freestrexp(MyPath); #ifdef DEBUG DEBUG_printf("BOS v. 0.0.3\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__); #endif return RetFile; }
static int getfmt(Sfio_t* sp, void* vp, Sffmt_t* dp) { register Fmt_t* fp = (Fmt_t*)dp; register Arg_t* ap = fp->ap++; Value_t* value = (Value_t*)vp; Cxoperand_t ret; if (ap->expr && cxeval(fp->cx, ap->expr, fp->data, &ret) < 0 || cxcast(fp->cx, &ret, ap->variable, ap->cast, fp->data, ap->details)) { fp->errors++; return -1; } fp->fmt.flags |= SFFMT_VALUE; switch (ap->type) { case DSS_FORMAT_char: fp->fmt.size = sizeof(int); if (ret.value.number < 1) value->c = 0; else if (ret.value.number > UCHAR_MAX) value->c = UCHAR_MAX; else value->c = (unsigned char)ret.value.number; break; case DSS_FORMAT_float: fp->fmt.size = sizeof(double); value->f = ret.value.number; break; case DSS_FORMAT_int: #if 0 /* * this code is technically correct but overly * complicates script portability between architectures * with differing sizeof(int) and/or sizeof(long) */ fp->fmt.size = sizeof(int); if (((ret.value.number >= 0) ? ret.value.number : -ret.value.number) < 1) value->i = 0; else if (ret.value.number > UINT_MAX) value->i = INT_MAX; else if (ret.value.number < INT_MIN) value->i = INT_MAX; else value->i = (unsigned int)ret.value.number; break; #endif case DSS_FORMAT_long: fp->fmt.size = sizeof(Sflong_t); if (((ret.value.number >= 0) ? ret.value.number : -ret.value.number) < 1) value->q = 0; else if (ret.value.number > FLTMAX_UINTMAX_MAX) value->q = FLTMAX_INTMAX_MAX; else if (ret.value.number < FLTMAX_INTMAX_MIN) value->q = FLTMAX_INTMAX_MAX; else value->q = (Sfulong_t)((Sflong_t)ret.value.number); break; case DSS_FORMAT_string: if (ap->fmt & (FMT_EXP_CHAR|FMT_EXP_LINE|FMT_EXP_NOCR|FMT_EXP_NONL|FMT_EXP_WIDE)) ret.value.string.size = strexp(ret.value.string.data, ap->fmt); if (ap->edit) cxsub(fp->cx, ap->edit, &ret); if (ap->flags & DSS_FORMAT_quote) ret.value.string.size = strlen(ret.value.string.data = fmtquote(ret.value.string.data, ap->qb, ap->qe, ret.value.string.size, ap->fmt)); value->s = ret.value.string.data; fp->fmt.size = ret.value.string.size; break; } return 0; }
int stresc(register char* s) { return strexp(s, FMT_EXP_CHAR|FMT_EXP_LINE|FMT_EXP_WIDE); }