static pn_object *PnStdio_PrintLine(pn_world *world, pn_object *object, pn_object *params[], int length) { PN_ASSERT(world != NULL); PN_ASSERT(object != NULL); PN_ASSERT(length == 1); pn_object *a_param = NULL; if (IS_STRING(params[0])) a_param = params[0]; else a_param = PnFunction_ExecuteByObject("to_str", world, params[0], NULL, 0); PN_ASSERT(IS_STRING(a_param)); __print(a_param->val.str_val); __print("\n"); size_t len = strlen(a_param->val.str_val); char *s = (char *)malloc(sizeof(char) * (len + 2)); strcpy(s, a_param->val.str_val); s[len] = '\n'; s[len+1] = 0; pn_object *ret = PnString_Create(world, s); PN_ASSERT(ret != NULL); PN_ASSERT(IS_STRING(ret)); free(s); return ret; }
//______________________________________________________________________________________ int writeI2C( _i2c *p, char *dBuffer, int length) { static int nrpt=3; int to=__time__+25; if(p) { memcpy(p->txbuf,dBuffer,length); p->ntx=length; I2C_ITConfig(I2C1, (I2C_IT_EVT | I2C_IT_BUF), ENABLE); I2C_GenerateSTART(I2C1, ENABLE); while(p->ntx && __time__< to) _proc_loop(); if(p->ntx) { Reset_I2C(p); if(--nrpt) return writeI2C(p, dBuffer, length); } nrpt=3; if(p->ntx) { return(0); } } _CLEAR_ERROR(pfm,PFM_I2C_ERR); if(_DBG(pfm,_DBG_I2C_TX)) { _io *io=_stdio(__dbug); int i; __print(":%04d",__time__ % 10000); for(i=0;i<length;++i) __print(" %02X",p->txbuf[i]); __print("\r\n>"); _stdio(io); } return(-1); }
void removeKeysFromLuksVolume( const char * device ) { process_t p ; __print( "remove a key from a luks volume using a key: " ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-r","-d",device,"-p",key,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; __print( "remove a key from a luks volume using a keyfile: " ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-r","-d",device,"-f",keyfile,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; }
static void __print(avltree_t* me, int idx, int d) { int i; for (i = 0; i < d; i++) printf(" "); printf("%c ", idx % 2 == 1 ? 'l' : 'r'); if (me->size <= idx || !me->nodes[idx].key) { printf("\n"); return; } printf("%lx\n", (unsigned long int)me->nodes[idx].key); __print(me, __child_l(idx), d + 1); __print(me, __child_r(idx), d + 1); }
void closeVolume( const char * device,const char * msg ) { process_t p ; __print( msg ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-q","-d",device,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; }
void restoreHeaderBackup( const char * device,const char * msg ) { process_t p ; __print( msg ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-R","-k","-d",device,"-f",headerBackUp,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; }
void checkKeySlotsInUse( const char * device ) { process_t p ; __print( "check key slots in use: " ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-b","-d",device,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResultANDPrint( p ) ; }
void openVolumeWithPlugIn( const char * device,const char * msg ) { process_t p ; __print( msg ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-o","-d",device,"-m",mount_point,"-G",pluginPath,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; }
static int _print(const char* format, ...) { int r; va_list ap; va_start(ap, format); r = __print(CMD_PRINT, format, ap); if (0 > r) printf("PRINT fails\n"); va_end(ap); return r; }
void cint_ast_dump_single(cint_ast_t* ast, int indent) { cint_ast_type_t t; if(ast == NULL) { __print(indent, "NULL\n"); } else if (ast == CINT_AST_PTR_VOID) { __print(indent, "VOID *\n"); } else if (ast == CINT_AST_PTR_AUTO) { __print(indent, "AUTO\n"); } else { t = ast->ntype; if(!CINT_AST_TYPE_VALID(t)) { __print(indent, "INVALID AST TYPE %d", t); } else { __print(indent, "{ %s\n", __ast_table[t].name); __ast_table[t].dump(ast, indent+4); __print(indent, "}\n"); } } }
void createVolume( const char * device,const char * msg,const char * keysource,const char * type ) { process_t p ; __print( msg ) ; p = Process( zuluCryptExe ) ; if( strcmp( keysource,"-p" ) == 0 ){ ProcessSetArgumentList( p,"-c","-k","-d",device,"-t",type,keysource,key,ENDLIST ) ; }else{ ProcessSetArgumentList( p,"-c","-k","-d",device,"-t",type,keysource,keyfile,ENDLIST ) ; } ProcessStart( p ) ; __ProcessGetResult( p ) ; }
void checkIfDeviceIsLuks( const char * device ) { int st ; process_t p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-i","-d",device,ENDLIST ) ; ProcessStart( p ) ; st = ProcessExitStatus( p ) ; ProcessDelete( &p ) ; if( st ){ __print( "check if a luks volume is a luks volume: PASSED\n" ) ; } }
int main() { expr_t *stack[STACKSIZE]; int sptr; while(finished != 1) { sptr = rpn_read(stack); // pop everything off the stack and output it for(; sptr >= 0; sptr--) { __print(stdout, stack[sptr]); } } }
static void __cint_ast_dump_LongLong(cint_ast_t* ast, int indent) { long long i = ast->utype._longlong.i; char buf1[50], *s1; char buf2[50], *s2; char buf3[50], *s3; s1 = cint_lltoa(buf1, sizeof(buf1), i, 0, 16, 16); s2 = cint_lltoa(buf2, sizeof(buf2), i, 0, 10, 0); s3 = cint_lltoa(buf3, sizeof(buf3), i, 0, 10, 0); __print(indent, "0x%s - %s - %s\n", s1, s2, s3); }
void openVolume( const char * device,const char * msg,const char * keysource ) { process_t p ; __print( msg ) ; p = Process( zuluCryptExe ) ; if( strcmp( keysource,"-p" ) == 0 ){ ProcessSetArgumentList( p,"-o","-d",device,"-m",mount_point,keysource,key,ENDLIST ) ; }else{ ProcessSetArgumentList( p,"-o","-d",device,"-m",mount_point,keysource,keyfile,ENDLIST ) ; } ProcessStart( p ) ; __ProcessGetResult( p ) ; }
//______________________________________________________________________________________ int readI2C(_i2c *p, char* dBuffer, int length) { static int nrpt=3; int to=__time__+25; if(p) { p->nrx=length; if(dBuffer[1]) writeI2C(p,dBuffer,2); else writeI2C(p,dBuffer,1); while(p->nrx && __time__< to) _proc_loop(); if(p->nrx) { Reset_I2C(p); if(--nrpt) return readI2C(p, dBuffer, length); } nrpt=3; memcpy(dBuffer,p->rxbuf,length); if(p->nrx) { return(0); } } else while(length--) dBuffer[length]=0; _CLEAR_ERROR(pfm,PFM_I2C_ERR); if(_DBG(pfm,_DBG_I2C_RX)) { _io *io=_stdio(__dbug); int i; __print(":%04d",__time__ % 10000); for(i=0;i<length;++i) __print(" %02X",p->rxbuf[i]); __print("\r\n>"); _stdio(io); } return(-1); }
static void _log(int lv, const char* format, ...) { int r; va_list ap; if (lv < _loglv) return; va_start(ap, format); r = __print(CMD_LOG, format, ap); if (0 > r) printf("LOG fails\n"); va_end(ap); return; }
void addKeysToLuks( const char * device ) { process_t p ; __print( "add a key to a luks volume using a key and a key: " ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-a","-d",device,"-y",key,"-l",key1,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; __print( "add key to luks volume using keyfile and keyfile: " ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-a","-d",device,"-u",keyfile,"-n",keyfile1,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; __print( "add key to luks volume using passphrase and keyfile: " ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-a","-d",device,"-y",key,"-n",keyfile,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; __print( "add key to luks volume using keyfile and passphrase: " ) ; p = Process( zuluCryptExe ) ; ProcessSetArgumentList( p,"-a","-d",device,"-u",keyfile1,"-l",key1,ENDLIST ) ; ProcessStart( p ) ; __ProcessGetResult( p ) ; }
void __ProcessGetResultANDPrint( process_t p ) { char * e = NULL ; int st ; ProcessGetOutPut( p,&e,STDOUT ) ; st = ProcessExitStatus( p ) ; ProcessDelete( &p ) ; if( st ){ puts( "FAILED" ) ; EXIT( 1,e ) ; }else{ if( e ){ __print( e ) ; free( e ) ; } } }
static pn_object *PnStdio_Print(pn_world *world, pn_object *object, pn_object *params[], int length) { PN_ASSERT(world != NULL); PN_ASSERT(object != NULL); PN_ASSERT(length == 1); pn_object *a_param = NULL; if (IS_STRING(params[0])) a_param = params[0]; else a_param = PnFunction_ExecuteByObject("to_str", world, params[0], NULL, 0); PN_ASSERT(IS_STRING(a_param)); __print(a_param->val.str_val); pn_object *ret = PnString_Create(world, a_param->val.str_val); PN_ASSERT(ret != NULL); PN_ASSERT(IS_STRING(ret)); return ret; }
/*! Formated output to console (lightweight version of printf) */ int kprint ( char *format, ... ) { return __print ( k_stdout, KERNEL_FONT, &format ); }
void avltree_print(avltree_t* me) { printf("AVL Tree:\n"); __print(me, 0, 0); }
static void __cint_ast_dump_Double(cint_ast_t* ast, int indent) { double d = ast->utype._double.d; __print(indent, "%f\n", d); }
static void __cint_ast_dump_Type(cint_ast_t* ast, int indent) { __print(indent, "'%s'\n", ast->utype.type.s); }
//dodani atributi za znak i pozadinu int printattr ( int chattr, int bgattr, char *format, ... ) { int attr = (bgattr << 4) | (chattr); return __print ( u_stdout, attr, &format ); }
int print ( char *format, ... ) { return __print ( u_stdout, USER_FONT, &format ); }
void __printLine( void ) { sleep( 1 ) ; __print( "\n" ) ; }
static void __cint_ast_dump_Identifier(cint_ast_t* ast, int indent) { __print(indent, "'%s'\n", ast->utype.identifier.s); }
static int __start_member(int indent, const char* str) { return __print(indent, "{ %s\n", str); }
static int __end_member(int indent) { return __print(indent, "}\n"); }