Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Read a string with leading spaces and find the length of the string Post 302257872 by dayamatrix on Thursday 13th of November 2008 09:08:34 AM
Old 11-13-2008
Java Thank you very much

HI
Thank you very much for the timely reply
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

2. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies

3. Shell Programming and Scripting

ksh - read file with leading spaces

Hi, Could someone has any suggestions on this? When read a line from a file, I need to check the first char in the line, it could be a space or any char. But the leading spaces are removed by read. Thanks. (2 Replies)
Discussion started by: momi
2 Replies

4. Shell Programming and Scripting

Awk:Find length of string omitting quotes

Hi , I have a file named "sample" having the data as follows. "663005487","USD",0,1,"NR" If i give like a=`awk -F ',' '{printf length($2)}' sample` (Trying to find length of second field)I should get the output for the above as 3 (Omitting double quotes) not 5. How to do this..... (2 Replies)
Discussion started by: jayakumarrt
2 Replies

5. Shell Programming and Scripting

find the string length in solaris

how to find the string length in solaris machine. (4 Replies)
Discussion started by: din_annauniv
4 Replies

6. Programming

How to find length of string and pass into char array in C?

Hi All I want to take a Hexadecimal number as input and i want to find lenth of the input and pass it to char s ( char s ). I have a program to convert hexadecial to binary but it is taking limited input but i want to return binary number based on input. How? (1 Reply)
Discussion started by: atharalikhan
1 Replies

7. Programming

Fastest way to find the length of string in c

Hi all, We use strlen() fun provided by library to find the length of a string. Looking inside of it, it has some different mechanism to find the length of string. Normally, we scan the string byte by byte until the '\0' character. It takes a logn time to count length. The Library strlen()... (2 Replies)
Discussion started by: yogeshrl9072
2 Replies

8. Shell Programming and Scripting

sed delete leading spaces in a .csv if not in a string

Solaris, ksh I have a .csv file I am trying to clean up before loading into the database. The file contains comma separated columns that have leading spaces which I need to remove. The trouble is, some columns that should not be touched are strings which happen to have the same pattern in them. ... (4 Replies)
Discussion started by: gary_w
4 Replies

9. Shell Programming and Scripting

Help to find length of string avoiding trailing spaces

Hi, I have a record of length 200 bytes and values filled is only 100 bytes and remaining 100 spaces is occupied by spaces. In script wen i try to find the length of the entire record it should get as 200 not 100. i tried using length and wc -c but it doesnt work can anyone have any idea on... (3 Replies)
Discussion started by: Pranaveen
3 Replies

10. Shell Programming and Scripting

How to find and replace a string with spaces and / recursively?

Hi all, I wanted to find and replace an email id from entire directory structure on a Linux server. I found that find . -type f -print0 | xargs -0 sed -i 's/abc@yahoo.com/xyz@gmail.com/g' would do it perfectly. But my search criteria has extended and now I want to search for a string1 like... (2 Replies)
Discussion started by: pat_pramod
2 Replies
xpc_main(3)						   BSD Library Functions Manual 					       xpc_main(3)

NAME
xpc_main -- XPC service runtime SYNOPSIS
#include <xpc/xpc.h> void xpc_main(xpc_connection_handler_t handler); void xpc_transaction_begin(void); void xpc_transaction_end(void); DESCRIPTION
The xpc_main() function is called by an XPC service to initialize the runtime and start listening for incoming connections. HANDLER
The handler provided to xpc_main() will be invoked when a new connection has been established with the service. For each new connection, an xpc_connection_t will be passed as the parameter to the handler. Each connection corresponds to a call to xpc_connection_create(3) made by a client of the service. The service is responsible for setting an event handler on the new connection and resuming it in the same fashion as new connections returned by xpc_connection_create(3). Important: The new connection passed to handler() must be retained using xpc_retain(3) if it will be stored in data structures that persist beyond the scope of that function. static void new_connection_handler(xpc_connection_t peer) { xpc_connection_set_event_handler(peer, ^(xpc_object_t event) { // Handle messages and errors. }); xpc_connection_resume(peer); } int main(void) { xpc_main(new_connection_handler); exit(EXIT_FAILURE); } launchd jobs which advertise MachServices may not call xpc_main(). RUNTIME MANAGEMENT
The XPC runtime automatically keeps track of message activity to determine whether a service is busy or idle. If the service remains idle after a period of inactivity (defined by the system), xpc_main() will exit the process. This behavior is automatically enabled for XPC ser- vices, but launchd(8) jobs wishing to opt into the same behavior may do so by adding the EnablePressuredExit key to their launchd.plist(5). Activity is tracked with a transaction count maintained by the XPC runtime. A service is deemed idle when its transaction count is zero. The transaction count is incremented immediately before the receipt and delivery of a message to a peer connection's event handler. The transaction count is correspondingly decremented when the event handler returns. The transaction count is also incremented when a reply message is created with xpc_dictionary_create_reply(3), and decremented when the reply is sent. As a result, a service with outstanding reply messages is not considered idle. Services may extend the default behavior using xpc_transaction_begin() and xpc_transaction_end(), which increment and decrement the transac- tion count respectively. This may be necessary for services that send periodic messages to their clients, not in direct reply to a received message. If the service has a non-zero transaction count at a time when the system deems it necessary to terminate the service, peer connections in the service may receive the XPC_ERROR_TERMINATION_IMMINENT event. This event indicates that the service should unwind all outstanding work as quickly as possible and not begin any new work, as the system will terminate the process if it does not exit in a timely fashion. After this event is received, no further messages will be delivered to the peers, and the end of the service's last outstanding transaction will auto- matically terminate the process. The XPC runtime will also automatically manage the service's priority based on where a message came from. If an app sends a message to the service, the act of sending that message will boost the destination service's priority and resource limits so that it can more quickly fill the request. If, however, a service gets a message from a background process, the service stays at a lower priority so as not to interfere with work initiated as a direct result of user interaction. The lifetime of these boosts is tied to the lifetime of the message or reply object, just like transactions. So while the service maintains a reference to a message which boosted it, the boost will remain. If a reply message is created using xpc_dictionary_create_reply(3), the boost transfers to the reply object and will remain with the process until until the reply has been sent or deallocated. Note that boosts happen as a result of a message-send operation. So even if the service isn't running when a boosting message is sent, it will be launched on-demand at the elevated priority necessary to receive the message in a timely fashion. launchd jobs which use XPC for their IPC may opt into priority boosting by specifying their ProcessType as Adaptive. This will apply priority boosting behavior only to the MachServices that are in the launchd.plist. See launchd.plist(5) for more details. DEFAULT ENVIRONMENT
The execution environment for XPC services bundled with applications is tightly controlled. By default, services are executed in a new secu- rity audit session and therefore do not have access to the current user's keychain or the ability to draw UI. This behavior may be overrid- den with the JoinExistingSession key in the service's Info.plist. By default, the xpc_main() function will call the dispatch_main(3) function to manage the service's main event loop. This behavior may be overridden with the RunLoopType key in the service's Info.plist. See xpcservice.plist(5) for more information about these keys. SEE ALSO
xpc(3), xpc_connection_create(3) Darwin 1 July, 2011 Darwin
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy